This commit fixes the step trigger:
'#o_website_links_link_tracker_form
#generated_tracked_link:contains("/r/")' that was taking too long
because of a call to _get_title_from_url happening during the creation
of a 'link.tracker'.
Before this commit the automated tests of website_links did trigger an
http request on the 'contactus' page which sometimes took too long to
respond and reached the test failure timeout.
After this commit the information obtained from this request is
hard-coded to avoid the unpredictable timing of the test.
This commit is a manual port of #62479.
task-2397724
closes odoo/odoo#62582
X-original-commit: db3296c034fe4c82d19580418fd5cdecdf578395
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
82 lines
3.2 KiB
JavaScript
82 lines
3.2 KiB
JavaScript
odoo.define('website_links.website_links_tour', function (require) {
|
|
'use strict';
|
|
|
|
var tour = require("web_tour.tour");
|
|
|
|
tour.register('website_links_tour', {
|
|
test: true,
|
|
url: '/r',
|
|
},
|
|
[
|
|
// 1. Create a tracked URL
|
|
{
|
|
content: "check that existing links are shown",
|
|
trigger: '#o_website_links_recent_links .btn_shorten_url_clipboard',
|
|
run: function () {}, // it's a check
|
|
},
|
|
{
|
|
content: "fill the form and submit it",
|
|
trigger: '#o_website_links_link_tracker_form input#url',
|
|
run: function () {
|
|
var url = window.location.host + '/contactus';
|
|
$('#o_website_links_link_tracker_form input#url').val(url);
|
|
$('.o_website_links_utm_forms input#campaign-select').val(1).change();
|
|
$('.o_website_links_utm_forms input#channel-select').val(1).change();
|
|
$('.o_website_links_utm_forms input#source-select').val(1).change();
|
|
$('#btn_shorten_url').click();
|
|
},
|
|
},
|
|
// 2. Visit it
|
|
{
|
|
content: "check that link was created and visit it",
|
|
extra_trigger: '#o_website_links_recent_links .truncate_text:first():contains("Contact Us")',
|
|
trigger: '#o_website_links_link_tracker_form #generated_tracked_link:contains("/r/")',
|
|
run: function () {
|
|
window.location.href = $('#generated_tracked_link').text();
|
|
},
|
|
},
|
|
{
|
|
content: "check that we landed on correct page with correct query strings",
|
|
trigger: '.s_title h1:containsExact("Contact us")',
|
|
run: function () {
|
|
var expectedUrl = "/contactus?utm_campaign=Sale&utm_source=Search+engine&utm_medium=Website";
|
|
if (window.location.pathname + window.location.search !== expectedUrl) {
|
|
console.error("The link was not correctly created.");
|
|
}
|
|
window.location.href = '/r';
|
|
},
|
|
},
|
|
// 3. Check that counter got incremented and charts are correctly displayed
|
|
{
|
|
content: "filter recently used links",
|
|
trigger: '#filter-recently-used-links',
|
|
},
|
|
{
|
|
content: "visit link stats page",
|
|
trigger: '#o_website_links_recent_links a:containsExact("Stats"):first',
|
|
},
|
|
{
|
|
content: "check click number and ensure graphs are initialized",
|
|
extra_trigger: '.website_links_click_chart .title:contains("1 clicks")',
|
|
trigger: 'canvas',
|
|
run: function () {}, // it's a check
|
|
},
|
|
{
|
|
content: "click on Last Month tab",
|
|
trigger: '.o_website_links_chart .graph-tabs a:contains("Last Month")',
|
|
},
|
|
{
|
|
content: "ensure tab is correctly resized",
|
|
trigger: '#last_month_charts #last_month_clicks_chart',
|
|
run: function () {
|
|
var width = $('#last_month_charts #last_month_clicks_chart').width();
|
|
if (width < 50) {
|
|
console.error("The graphs are probably not resized on tab change.");
|
|
}
|
|
},
|
|
},
|
|
]
|
|
);
|
|
|
|
});
|