From cc7daf27c9ea6eb2cff9464f2f76928bde6f00c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 17 May 2023 08:04:33 +0000 Subject: [PATCH] [MOV] (website_)mass_mailing: reorder, rename and link UI tests / tours Rename tours, reorder tests and test files, perform a quick linting of UI or tours related tests. Purpose is to prepare files to add some new tests in mass mailing. Each tour now belongs to a single file to ease maintenance and update as well as seeing feature coverage. No real change should occur with this commit except some test data (setup, test input). Prepares Task-2150462 (Mass Mailing: Improve subscription management) Part-of: odoo/odoo#122106 --- .../static/tests/tours/mailing_campaign.js | 61 +++++ .../static/tests/tours/mailing_editor.js | 58 +++++ .../tests/tours/mailing_editor_theme.js | 101 +++++++++ .../tests/tours/mass_mailing_editor_tour.js | 212 ------------------ .../tours/mass_mailing_snippets_menu_tabs.js | 194 ---------------- .../tests/tours/snippets_mailing_menu_tabs.js | 53 +++++ .../tours/snippets_mailing_menu_toolbar.js | 78 +++++++ .../snippets_mailing_menu_toolbar_mobile.js | 69 ++++++ addons/mass_mailing/tests/common.py | 7 +- addons/mass_mailing/tests/test_mailing_ui.py | 70 +++--- ... => snippet_newsletter_block_with_edit.js} | 2 +- ...js => snippet_newsletter_popup_edition.js} | 6 +- ...pup.js => snippet_newsletter_popup_use.js} | 4 +- .../tests/test_snippets.py | 24 +- 14 files changed, 487 insertions(+), 452 deletions(-) create mode 100644 addons/mass_mailing/static/tests/tours/mailing_campaign.js create mode 100644 addons/mass_mailing/static/tests/tours/mailing_editor.js create mode 100644 addons/mass_mailing/static/tests/tours/mailing_editor_theme.js delete mode 100644 addons/mass_mailing/static/tests/tours/mass_mailing_editor_tour.js delete mode 100644 addons/mass_mailing/static/tests/tours/mass_mailing_snippets_menu_tabs.js create mode 100644 addons/mass_mailing/static/tests/tours/snippets_mailing_menu_tabs.js create mode 100644 addons/mass_mailing/static/tests/tours/snippets_mailing_menu_toolbar.js create mode 100644 addons/mass_mailing/static/tests/tours/snippets_mailing_menu_toolbar_mobile.js rename addons/website_mass_mailing/static/tests/tours/{newsletter_block.js => snippet_newsletter_block_with_edit.js} (96%) rename addons/website_mass_mailing/static/tests/tours/{newsletter_popup_edition.js => snippet_newsletter_popup_edition.js} (72%) rename addons/website_mass_mailing/static/tests/tours/{newsletter_popup.js => snippet_newsletter_popup_use.js} (90%) diff --git a/addons/mass_mailing/static/tests/tours/mailing_campaign.js b/addons/mass_mailing/static/tests/tours/mailing_campaign.js new file mode 100644 index 00000000000..e849e3cff46 --- /dev/null +++ b/addons/mass_mailing/static/tests/tours/mailing_campaign.js @@ -0,0 +1,61 @@ +/** @odoo-module **/ + +import { registry } from "@web/core/registry"; +import { stepUtils } from "@web_tour/tour_service/tour_utils"; + +registry.category('web_tour.tours').add('mailing_campaign', { + test: true, + url: '/web', + steps: [ + stepUtils.showAppsMenuItem(), + { + content: 'Select the "Email Marketing" app', + trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]', + }, + { + content: 'Select "Campaings" Navbar item', + trigger: '.o_nav_entry[data-menu-xmlid="mass_mailing.menu_email_campaigns"]', + }, + { + content: 'Select "Newsletter" campaign', + trigger: '.oe_kanban_card:contains("Newsletter")', + }, + { + content: 'Add a line (create new mailing)', + trigger: '.o_field_x2many_list_row_add a', + }, + { + content: 'Pick the basic theme', + trigger: 'iframe', + run(actions) { + // For some reason the selectors inside the iframe cannot be triggered. + const link = this.$anchor[0].contentDocument.querySelector('#basic'); + actions.click(link); + } + }, + { + content: 'Fill in Subject', + trigger: '#subject_0', + run: 'text TestFromTour', + }, + { + content: 'Fill in Mailing list', + trigger: '#contact_list_ids_0', + run: 'text Newsletter', + }, + { + content: 'Pick "Newsletter" option', + trigger: '.o_input_dropdown a:contains(Newsletter)', + }, + { + content: 'Save form', + trigger: '.o_form_button_save', + }, + { + content: 'Check that newly created record is on the list', + trigger: '[name="mailing_mail_ids"] td[name="subject"]:contains("TestFromTour")', + run: () => null, + }, + ...stepUtils.saveForm(), + ] +}); diff --git a/addons/mass_mailing/static/tests/tours/mailing_editor.js b/addons/mass_mailing/static/tests/tours/mailing_editor.js new file mode 100644 index 00000000000..4ac652d3be1 --- /dev/null +++ b/addons/mass_mailing/static/tests/tours/mailing_editor.js @@ -0,0 +1,58 @@ +/** @odoo-module **/ + +import { registry } from "@web/core/registry"; +import { stepUtils } from "@web_tour/tour_service/tour_utils"; + +registry.category("web_tour.tours").add('mailing_editor', { + url: '/web', + test: true, + steps: [stepUtils.showAppsMenuItem(), { + trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]', +}, { + trigger: 'button.o_list_button_add', +}, { + trigger: 'div[name="contact_list_ids"] .o_input_dropdown input[type="text"]', +}, { + trigger: 'div[name="contact_list_ids"] .ui-state-active' +}, { + content: 'choose the theme "empty" to edit the mailing with snippets', + trigger: '[name="body_arch"] iframe #empty', +}, { + content: 'wait for the editor to be rendered', + trigger: '[name="body_arch"] iframe .o_editable[data-editor-message="DRAG BUILDING BLOCKS HERE"]', + run: () => {}, +}, { + content: 'drag the "Title" snippet from the design panel and drop it in the editor', + trigger: '[name="body_arch"] iframe #email_designer_default_body [name="Title"] .ui-draggable-handle', + run: function (actions) { + actions.drag_and_drop('[name="body_arch"] iframe .o_editable', this.$anchor); + } +}, { + content: 'wait for the snippet menu to finish the drop process', + trigger: '[name="body_arch"] iframe #email_designer_header_elements:not(:has(.o_we_already_dragging))', + run: () => {} +}, { + content: 'verify that the title was inserted properly in the editor', + trigger: '[name="body_arch"] iframe .o_editable h1', + run: () => {}, +}, { + trigger: 'button.o_form_button_save', +}, { + content: 'verify that the save failed (since the field "subject" was not set and it is required)', + trigger: 'label.o_field_invalid', + run: () => {}, +}, { + content: 'verify that the edited mailing body was not lost during the failed save', + trigger: '[name="body_arch"] iframe .o_editable h1', + run: () => {}, +}, { + trigger: 'input#subject_0', + run: 'text TestFromTour', +}, { + trigger: '.o_form_view', // blur previous input +}, +...stepUtils.saveForm(), +{ + trigger: 'iframe .o_editable', + run: () => {}, +}]}); diff --git a/addons/mass_mailing/static/tests/tours/mailing_editor_theme.js b/addons/mass_mailing/static/tests/tours/mailing_editor_theme.js new file mode 100644 index 00000000000..29a7bbb9061 --- /dev/null +++ b/addons/mass_mailing/static/tests/tours/mailing_editor_theme.js @@ -0,0 +1,101 @@ +/** @odoo-module **/ + +import { registry } from "@web/core/registry"; +import { stepUtils } from "@web_tour/tour_service/tour_utils"; +import { boundariesIn, setSelection } from "@web_editor/js/editor/odoo-editor/src/utils/utils"; + +registry.category("web_tour.tours").add('mailing_editor_theme', { + test: true, + url: '/web', + steps: [ + stepUtils.showAppsMenuItem(), + { + content: "Select the 'Email Marketing' app.", + trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]', + }, + { + content: "Click on the create button to create a new mailing.", + trigger: 'button.o_list_button_add', + }, + { + content: "Wait for the theme selector to load and pick the basic theme.", + trigger: 'iframe #basic', + extra_trigger: 'iframe .o_mail_theme_selector_new', + }, + { + content: "Make sure the snippets menu is hidden", + trigger: 'iframe html:has(#oe_snippets.d-none)', + run: () => null, // no click, just check + }, + { + content: "Add some content to be selected afterwards", + trigger: 'iframe p', + run: 'text content', + }, + { + content: "Select text", + trigger: 'iframe p:contains(content)', + run() { + setSelection(...boundariesIn(this.$anchor[0]), false); + } + }, + { + content: "Make sure the floating toolbar is visible", + trigger: '#toolbar.oe-floating[style*="visible"]', + run: () => null, + }, + { + content: "Open the color picker", + trigger: '#toolbar #oe-text-color', + }, + { + content: "Pick a color", + trigger: '#toolbar button[data-color="o-color-1"]', + }, + { + content: "Check that color was applied", + trigger: 'iframe p font.text-o-color-1', + run: () => null, + }, + { + content: "Fill in Subject", + trigger: '[name="subject"] input', + run: 'text TestFromTour', + }, + { + content: "Fill in Mailing list", + trigger: '[name="contact_list_ids"] input', + run: 'text Newsletter', + }, + { + content: "Pick 'Newsletter' option", + trigger: '.o_input_dropdown a:contains(Newsletter)', + }, + { + content: "Save and go to 'Mailings' list view", + trigger: '.breadcrumb a:contains(Mailings)' + }, + { + content: "Open newly created mailing", + trigger: 'td:contains(TestFromTour)', + }, + { + content: "Make sure the snippets menu is hidden", + trigger: 'iframe html:has(#oe_snippets.d-none)', + run: () => null, + }, + { + content: "Select content", + trigger: 'iframe p:contains(content)', + run() { + setSelection(...boundariesIn(this.$anchor[0]), false); + } + }, + { + content: "Make sure the floating toolbar is visible", + trigger: '#toolbar.oe-floating[style*="visible"]', + run: () => null, + }, + ...stepUtils.discardForm(), + ] +}); diff --git a/addons/mass_mailing/static/tests/tours/mass_mailing_editor_tour.js b/addons/mass_mailing/static/tests/tours/mass_mailing_editor_tour.js deleted file mode 100644 index 4d9958b0d32..00000000000 --- a/addons/mass_mailing/static/tests/tours/mass_mailing_editor_tour.js +++ /dev/null @@ -1,212 +0,0 @@ -/** @odoo-module **/ - - import { registry } from "@web/core/registry"; - import { stepUtils } from "@web_tour/tour_service/tour_utils"; - import { boundariesIn, setSelection } from "@web_editor/js/editor/odoo-editor/src/utils/utils"; - - registry.category("web_tour.tours").add('mass_mailing_editor_tour', { - url: '/web', - test: true, - steps: [stepUtils.showAppsMenuItem(), { - trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]', - }, { - trigger: 'button.o_list_button_add', - }, { - trigger: 'div[name="contact_list_ids"] .o_input_dropdown input[type="text"]', - }, { - trigger: 'div[name="contact_list_ids"] .ui-state-active' - }, { - content: 'choose the theme "empty" to edit the mailing with snippets', - trigger: '[name="body_arch"] iframe #empty', - }, { - content: 'wait for the editor to be rendered', - trigger: '[name="body_arch"] iframe .o_editable[data-editor-message="DRAG BUILDING BLOCKS HERE"]', - run: () => {}, - }, { - content: 'drag the "Title" snippet from the design panel and drop it in the editor', - trigger: '[name="body_arch"] iframe #email_designer_default_body [name="Title"] .ui-draggable-handle', - run: function (actions) { - actions.drag_and_drop('[name="body_arch"] iframe .o_editable', this.$anchor); - } - }, { - content: 'wait for the snippet menu to finish the drop process', - trigger: '[name="body_arch"] iframe #email_designer_header_elements:not(:has(.o_we_already_dragging))', - run: () => {} - }, { - content: 'verify that the title was inserted properly in the editor', - trigger: '[name="body_arch"] iframe .o_editable h1', - run: () => {}, - }, { - trigger: 'button.o_form_button_save', - }, { - content: 'verify that the save failed (since the field "subject" was not set and it is required)', - trigger: 'label.o_field_invalid', - run: () => {}, - }, { - content: 'verify that the edited mailing body was not lost during the failed save', - trigger: '[name="body_arch"] iframe .o_editable h1', - run: () => {}, - }, { - trigger: 'input#subject_0', - run: 'text Test', - }, { - trigger: '.o_form_view', // blur previous input - }, - ...stepUtils.saveForm(), - { - trigger: 'iframe .o_editable', - run: () => {}, - }]}); - -registry.category("web_tour.tours").add('mass_mailing_basic_theme_toolbar', { - test: true, - url: '/web', - steps: [ - stepUtils.showAppsMenuItem(), - { - content: "Select the 'Email Marketing' app.", - trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]', - }, - { - content: "Click on the create button to create a new mailing.", - trigger: 'button.o_list_button_add', - }, - { - content: "Wait for the theme selector to load and pick the basic theme.", - trigger: 'iframe #basic', - extra_trigger: 'iframe .o_mail_theme_selector_new', - }, - { - content: "Make sure the snippets menu is hidden", - trigger: 'iframe html:has(#oe_snippets.d-none)', - run: () => null, // no click, just check - }, - { - content: "Add some content to be selected afterwards", - trigger: 'iframe p', - run: 'text content', - }, - { - content: "Select text", - trigger: 'iframe p:contains(content)', - run() { - setSelection(...boundariesIn(this.$anchor[0]), false); - } - }, - { - content: "Make sure the floating toolbar is visible", - trigger: '#toolbar.oe-floating[style*="visible"]', - run: () => null, - }, - { - content: "Open the color picker", - trigger: '#toolbar #oe-text-color', - }, - { - content: "Pick a color", - trigger: '#toolbar button[data-color="o-color-1"]', - }, - { - content: "Check that color was applied", - trigger: 'iframe p font.text-o-color-1', - run: () => null, - }, - { - content: "Fill in Subject", - trigger: '[name="subject"] input', - run: 'text Test', - }, - { - content: "Fill in Mailing list", - trigger: '[name="contact_list_ids"] input', - run: 'text Newsletter', - }, - { - content: "Pick 'Newsletter' option", - trigger: '.o_input_dropdown a:contains(Newsletter)', - }, - { - content: "Save and go to 'Mailings' list view", - trigger: '.breadcrumb a:contains(Mailings)' - }, - { - content: "Open newly created mailing", - trigger: 'td:contains(Test)', - }, - { - content: "Make sure the snippets menu is hidden", - trigger: 'iframe html:has(#oe_snippets.d-none)', - run: () => null, - }, - { - content: "Select content", - trigger: 'iframe p:contains(content)', - run() { - setSelection(...boundariesIn(this.$anchor[0]), false); - } - }, - { - content: "Make sure the floating toolbar is visible", - trigger: '#toolbar.oe-floating[style*="visible"]', - run: () => null, - }, - ...stepUtils.discardForm(), - ] -}); - -registry.category('web_tour.tours').add('mass_mailing_campaing_new_mailing', { - test: true, - url: '/web', - steps: [ - stepUtils.showAppsMenuItem(), - { - content: 'Select the "Email Marketing" app', - trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]', - }, - { - content: 'Select "Campaings" Navbar item', - trigger: '.o_nav_entry[data-menu-xmlid="mass_mailing.menu_email_campaigns"]', - }, - { - content: 'Select "Newsletter" campaign', - trigger: '.oe_kanban_card:contains("Newsletter")', - }, - { - content: 'Add a line (create new mailing)', - trigger: '.o_field_x2many_list_row_add a', - }, - { - content: 'Pick the basic theme', - trigger: 'iframe', - run(actions) { - // For some reason the selectors inside the iframe cannot be triggered. - const link = this.$anchor[0].contentDocument.querySelector('#basic'); - actions.click(link); - } - }, - { - content: 'Fill in Subject', - trigger: '#subject_0', - run: 'text Test', - }, - { - content: 'Fill in Mailing list', - trigger: '#contact_list_ids_0', - run: 'text Newsletter', - }, - { - content: 'Pick "Newsletter" option', - trigger: '.o_input_dropdown a:contains(Newsletter)', - }, - { - content: 'Save form', - trigger: '.o_form_button_save', - }, - { - content: 'Check that newly created record is on the list', - trigger: '[name="mailing_mail_ids"] td[name="subject"]:contains("Test")', - run: () => null, - }, - ...stepUtils.saveForm(), - ] -}); diff --git a/addons/mass_mailing/static/tests/tours/mass_mailing_snippets_menu_tabs.js b/addons/mass_mailing/static/tests/tours/mass_mailing_snippets_menu_tabs.js deleted file mode 100644 index 6132435aa09..00000000000 --- a/addons/mass_mailing/static/tests/tours/mass_mailing_snippets_menu_tabs.js +++ /dev/null @@ -1,194 +0,0 @@ -/** @odoo-module **/ - -import { registry } from "@web/core/registry"; -import { stepUtils } from "@web_tour/tour_service/tour_utils"; - -registry.category("web_tour.tours").add('mass_mailing_snippets_menu_tabs', { - test: true, - url: '/web', - steps: [ - stepUtils.showAppsMenuItem(), { - content: "Select the 'Email Marketing' app.", - trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]', - }, - { - content: "Click on the create button to create a new mailing.", - trigger: 'button.o_list_button_add', - }, - { - content: "Click on the 'Start From Scratch' template.", - trigger: 'iframe #empty', - }, - { - content: "Click on the 'Design' tab.", - trigger: 'iframe .o_we_customize_design_btn', - }, - { - content: "Click on the empty 'DRAG BUILDING BLOCKS HERE' area.", - trigger: 'iframe .oe_structure.o_mail_no_options', - }, - { - content: "Click on the 'Design' tab.", - trigger: 'iframe .o_we_customize_design_btn', - }, - { - content: "Verify that the customize panel is not empty.", - trigger: 'iframe .o_we_customize_panel .snippet-option-DesignTab', - run: () => null, // it's a check - }, - { - content: "Click on the style tab.", - trigger: 'iframe .o_we_customize_snippet_btn', - }, - { - content: "Click on the 'Design' tab.", - trigger: 'iframe .o_we_customize_design_btn', - }, - { - content: "Verify that the customize panel is not empty.", - trigger: 'iframe .o_we_customize_panel .snippet-option-DesignTab', - run: () => null, // it's a check - }, - ...stepUtils.discardForm(), -]}); - - - -registry.category("web_tour.tours").add('mass_mailing_snippets_menu_toolbar_new_mailing_mobile', { - test: true, - url: '/web', - steps: [ - stepUtils.showAppsMenuItem(), { - content: "Select the 'Email Marketing' app.", - trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]', - }, - { - content: "Click on the create button to create a new mailing.", - trigger: 'button.o_list_button_add', - mobile: true, - }, - { - content: "Check templates available in theme selector", - trigger: 'iframe .o_mail_theme_selector_new', - run: function () { - if (this.$anchor[0].querySelector('#empty')) { - console.error('The empty template should not be visible on mobile.'); - } - }, - mobile: true, - }, - { - content: "Make sure the toolbar isn't floating", - trigger: 'iframe', - run: function () { - const iframeDocument = this.$anchor[0].contentDocument; - if (iframeDocument.querySelector('#toolbar.oe-floating')) { - console.error('There should not be a floating toolbar in the iframe'); - } - }, - mobile: true, - }, - { - content: "Click on the 'Start From Scratch' template.", - trigger: 'iframe #default', - mobile: true, - }, - { - content: "Select an editable element", - trigger: 'iframe .s_text_block', - mobile: true, - }, - { - content: "Make sure the snippets menu is hidden", - trigger: 'iframe', - run: function () { - const iframeDocument = this.$anchor[0].contentDocument; - if (!iframeDocument.querySelector('#oe_snippets.d-none')) { - console.error('The snippet menu should be hidden'); - } - }, - mobile: true, - }, - { - content: "Make sure the toolbar is there", - trigger: 'iframe #toolbar.oe-floating', - run: () => null, // it's a check - mobile: true, - }, - ...stepUtils.discardForm().map(command => ({...command, mobile: true})), - ] -}); - -registry.category("web_tour.tours").add('mass_mailing_snippets_menu_toolbar', { - test: true, - url: '/web', - steps: [ - stepUtils.showAppsMenuItem(), { - content: "Select the 'Email Marketing' app.", - trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]', - }, - { - content: "Click on the create button to create a new mailing.", - trigger: 'button.o_list_button_add', - }, - { - content: "Wait for the theme selector to load.", - trigger: 'iframe .o_mail_theme_selector_new', - }, - { - content: "Make sure there does not exist a floating toolbar", - trigger: 'iframe', - run: function () { - const iframeDocument = this.$anchor[0].contentDocument; - if (iframeDocument.querySelector('#toolbar.oe-floating')) { - console.error('There should not be a floating toolbar in the iframe'); - } - }, - }, - { - content: "Make sure the empty template is an option on non-mobile devices.", - trigger: 'iframe #empty', - run: () => null, - }, - { - content: "Click on the default 'welcome' template.", - trigger: 'iframe #default', - }, - { // necessary to wait for the cursor to be placed in the first p - // and to avoid leaving the page before the selection is added - content: "Wait for template selection event to be over.", - trigger: 'iframe .o_editable.theme_selection_done', - }, - { - content: "Make sure the snippets menu is not hidden", - trigger: 'iframe #oe_snippets:not(.d-none)', - run: () => null, - }, - { - content: "Wait for .s_text_block to be populated", - trigger: 'iframe .s_text_block p', - run: () => null, - }, - { - content: "Click and select p block inside the editor", - trigger: 'iframe', - run: function () { - const iframeWindow = this.$anchor[0].contentWindow; - const iframeDocument = iframeWindow.document; - const p = iframeDocument.querySelector('.s_text_block p'); - p.click(); - const selection = iframeWindow.getSelection(); - const range = iframeDocument.createRange(); - range.selectNodeContents(p); - selection.removeAllRanges(); - selection.addRange(range); - }, - }, - { - content: "Make sure the toolbar is there", - trigger: 'iframe #oe_snippets .o_we_customize_panel #toolbar', - run: () => null, - }, - ...stepUtils.discardForm(), - ], -}); diff --git a/addons/mass_mailing/static/tests/tours/snippets_mailing_menu_tabs.js b/addons/mass_mailing/static/tests/tours/snippets_mailing_menu_tabs.js new file mode 100644 index 00000000000..b54c1d66059 --- /dev/null +++ b/addons/mass_mailing/static/tests/tours/snippets_mailing_menu_tabs.js @@ -0,0 +1,53 @@ +/** @odoo-module **/ + +import { registry } from "@web/core/registry"; +import { stepUtils } from "@web_tour/tour_service/tour_utils"; + +registry.category("web_tour.tours").add('snippets_mailing_menu_tabs', { + test: true, + url: '/web', + steps: [ + stepUtils.showAppsMenuItem(), { + content: "Select the 'Email Marketing' app.", + trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]', + }, + { + content: "Click on the create button to create a new mailing.", + trigger: 'button.o_list_button_add', + }, + { + content: "Click on the 'Start From Scratch' template.", + trigger: 'iframe #empty', + }, + { + content: "Click on the 'Design' tab.", + trigger: 'iframe .o_we_customize_design_btn', + }, + { + content: "Click on the empty 'DRAG BUILDING BLOCKS HERE' area.", + trigger: 'iframe .oe_structure.o_mail_no_options', + }, + { + content: "Click on the 'Design' tab.", + trigger: 'iframe .o_we_customize_design_btn', + }, + { + content: "Verify that the customize panel is not empty.", + trigger: 'iframe .o_we_customize_panel .snippet-option-DesignTab', + run: () => null, // it's a check + }, + { + content: "Click on the style tab.", + trigger: 'iframe .o_we_customize_snippet_btn', + }, + { + content: "Click on the 'Design' tab.", + trigger: 'iframe .o_we_customize_design_btn', + }, + { + content: "Verify that the customize panel is not empty.", + trigger: 'iframe .o_we_customize_panel .snippet-option-DesignTab', + run: () => null, // it's a check + }, + ...stepUtils.discardForm(), +]}); diff --git a/addons/mass_mailing/static/tests/tours/snippets_mailing_menu_toolbar.js b/addons/mass_mailing/static/tests/tours/snippets_mailing_menu_toolbar.js new file mode 100644 index 00000000000..d0fd4a1a29f --- /dev/null +++ b/addons/mass_mailing/static/tests/tours/snippets_mailing_menu_toolbar.js @@ -0,0 +1,78 @@ +/** @odoo-module **/ + +import { registry } from "@web/core/registry"; +import { stepUtils } from "@web_tour/tour_service/tour_utils"; + +registry.category("web_tour.tours").add('snippets_mailing_menu_toolbar', { + test: true, + url: '/web', + steps: [ + stepUtils.showAppsMenuItem(), { + content: "Select the 'Email Marketing' app.", + trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]', + }, + { + content: "Click on the create button to create a new mailing.", + trigger: 'button.o_list_button_add', + }, + { + content: "Wait for the theme selector to load.", + trigger: 'iframe .o_mail_theme_selector_new', + }, + { + content: "Make sure there does not exist a floating toolbar", + trigger: 'iframe', + run: function () { + const iframeDocument = this.$anchor[0].contentDocument; + if (iframeDocument.querySelector('#toolbar.oe-floating')) { + console.error('There should not be a floating toolbar in the iframe'); + } + }, + }, + { + content: "Make sure the empty template is an option on non-mobile devices.", + trigger: 'iframe #empty', + run: () => null, + }, + { + content: "Click on the default 'welcome' template.", + trigger: 'iframe #default', + }, + { // necessary to wait for the cursor to be placed in the first p + // and to avoid leaving the page before the selection is added + content: "Wait for template selection event to be over.", + trigger: 'iframe .o_editable.theme_selection_done', + }, + { + content: "Make sure the snippets menu is not hidden", + trigger: 'iframe #oe_snippets:not(.d-none)', + run: () => null, + }, + { + content: "Wait for .s_text_block to be populated", + trigger: 'iframe .s_text_block p', + run: () => null, + }, + { + content: "Click and select p block inside the editor", + trigger: 'iframe', + run: function () { + const iframeWindow = this.$anchor[0].contentWindow; + const iframeDocument = iframeWindow.document; + const p = iframeDocument.querySelector('.s_text_block p'); + p.click(); + const selection = iframeWindow.getSelection(); + const range = iframeDocument.createRange(); + range.selectNodeContents(p); + selection.removeAllRanges(); + selection.addRange(range); + }, + }, + { + content: "Make sure the toolbar is there", + trigger: 'iframe #oe_snippets .o_we_customize_panel #toolbar', + run: () => null, + }, + ...stepUtils.discardForm(), + ], +}); diff --git a/addons/mass_mailing/static/tests/tours/snippets_mailing_menu_toolbar_mobile.js b/addons/mass_mailing/static/tests/tours/snippets_mailing_menu_toolbar_mobile.js new file mode 100644 index 00000000000..b26e35a541f --- /dev/null +++ b/addons/mass_mailing/static/tests/tours/snippets_mailing_menu_toolbar_mobile.js @@ -0,0 +1,69 @@ +/** @odoo-module **/ + +import { registry } from "@web/core/registry"; +import { stepUtils } from "@web_tour/tour_service/tour_utils"; + +registry.category("web_tour.tours").add('snippets_mailing_menu_toolbar_mobile', { + test: true, + url: '/web', + steps: [ + stepUtils.showAppsMenuItem(), { + content: "Select the 'Email Marketing' app.", + trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]', + }, + { + content: "Click on the create button to create a new mailing.", + trigger: 'button.o_list_button_add', + mobile: true, + }, + { + content: "Check templates available in theme selector", + trigger: 'iframe .o_mail_theme_selector_new', + run: function () { + if (this.$anchor[0].querySelector('#empty')) { + console.error('The empty template should not be visible on mobile.'); + } + }, + mobile: true, + }, + { + content: "Make sure the toolbar isn't floating", + trigger: 'iframe', + run: function () { + const iframeDocument = this.$anchor[0].contentDocument; + if (iframeDocument.querySelector('#toolbar.oe-floating')) { + console.error('There should not be a floating toolbar in the iframe'); + } + }, + mobile: true, + }, + { + content: "Click on the 'Start From Scratch' template.", + trigger: 'iframe #default', + mobile: true, + }, + { + content: "Select an editable element", + trigger: 'iframe .s_text_block', + mobile: true, + }, + { + content: "Make sure the snippets menu is hidden", + trigger: 'iframe', + run: function () { + const iframeDocument = this.$anchor[0].contentDocument; + if (!iframeDocument.querySelector('#oe_snippets.d-none')) { + console.error('The snippet menu should be hidden'); + } + }, + mobile: true, + }, + { + content: "Make sure the toolbar is there", + trigger: 'iframe #toolbar.oe-floating', + run: () => null, // it's a check + mobile: true, + }, + ...stepUtils.discardForm().map(command => ({...command, mobile: true})), + ] +}); diff --git a/addons/mass_mailing/tests/common.py b/addons/mass_mailing/tests/common.py index bc3dae83571..eb2934fa017 100644 --- a/addons/mass_mailing/tests/common.py +++ b/addons/mass_mailing/tests/common.py @@ -243,9 +243,12 @@ class MassMailCommon(MailCommon, MassMailCase): super(MassMailCommon, cls).setUpClass() cls.user_marketing = mail_new_test_user( - cls.env, login='user_marketing', + cls.env, groups='base.group_user,base.group_partner_manager,mass_mailing.group_mass_mailing_user', - name='Martial Marketing', signature='--\nMartial') + login='user_marketing', + name='Martial Marketing', + signature='--\nMartial', + ) cls.email_reply_to = 'MyCompany SomehowAlias ' diff --git a/addons/mass_mailing/tests/test_mailing_ui.py b/addons/mass_mailing/tests/test_mailing_ui.py index 0afdd08a7dc..08de1dcd281 100644 --- a/addons/mass_mailing/tests/test_mailing_ui.py +++ b/addons/mass_mailing/tests/test_mailing_ui.py @@ -1,42 +1,56 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -import odoo.tests -from odoo.addons.base.tests.common import HttpCaseWithUserDemo +from odoo.addons.mass_mailing.tests.common import MassMailCommon +from odoo.tests import HttpCase, tagged -@odoo.tests.tagged('-at_install', 'post_install') -class TestUi(HttpCaseWithUserDemo): - def setUp(self): - super().setUp() - self.user_demo.groups_id |= self.env.ref('mass_mailing.group_mass_mailing_user') - self.user_demo.groups_id |= self.env.ref('mail.group_mail_template_editor') - self.user_demo.groups_id |= self.env.ref('mass_mailing.group_mass_mailing_campaign') +@tagged('-at_install', 'post_install') +class TestMailingUi(MassMailCommon, HttpCase): - def test_01_mass_mailing_editor_tour(self): - self.start_tour("/web", 'mass_mailing_editor_tour', login="demo") - mail = self.env['mailing.mailing'].search([('subject', '=', 'Test')])[0] - # The tour created and saved an email. The edited version should be + @classmethod + def setUpClass(cls): + super(TestMailingUi, cls).setUpClass() + + cls.user_marketing.write({ + 'groups_id': [ + (4, cls.env.ref('mail.group_mail_template_editor').id), + ], + }) + + def test_mailing_campaign_tour(self): + self.user_marketing.write({ + 'groups_id': [ + (4, self.env.ref('mass_mailing.group_mass_mailing_campaign').id), + ], + }) + self.start_tour("/web", 'mailing_campaign', login="user_marketing") + + def test_mailing_editor_tour(self): + mailing = self.env['mailing.mailing'].search([('subject', '=', 'TestFromTour')], limit=1) + self.assertFalse(mailing) + self.start_tour("/web", 'mailing_editor', login="user_marketing") + + # The tour created and saved a mailing. The edited version should be # saved in body_arch, and its transpiled version (see convert_inline) # for email client compatibility should be saved in body_html. This # ensures both fields have different values (the mailing body should # have been converted to a table in body_html). - self.assertIn('data-snippet="s_title"', mail.body_arch) - self.assertTrue(mail.body_arch.startswith('