From 751ea9634a690bb1642be6d66d4124d6311766c7 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 25 Jan 2019 15:02:14 +0000 Subject: [PATCH] [IMP] website: add tests for scss edition on html editor As this behavior was recently broken (fixed in #30403), this commit adds a test tour for that flow. task-1934279 Fix #30447 --- .../website/static/src/js/html_editor.test.js | 67 +++++++++++++++++++ addons/website/tests/test_ui.py | 3 + 2 files changed, 70 insertions(+) diff --git a/addons/website/static/src/js/html_editor.test.js b/addons/website/static/src/js/html_editor.test.js index cfbcd896bde..a57e7d4ea22 100644 --- a/addons/website/static/src/js/html_editor.test.js +++ b/addons/website/static/src/js/html_editor.test.js @@ -72,4 +72,71 @@ tour.register('html_editor_multiple_templates', { }, ] ); + +tour.register('test_html_editor_scss', { + test: true, + url: '/aboutus', + wait_for: base.ready(), +}, + [ + // 1. Open Html Editor and select a scss file + { + content: "open customize menu", + extra_trigger: '#wrap:visible', // ensure state for later + trigger: '#customize-menu > a', + }, + { + content: "open html editor", + trigger: '#html_editor', + }, + { + content: "open type switcher", + trigger: '.o_ace_type_switcher button', + }, + { + content: "select scss files", + trigger: '.o_ace_type_switcher_choice[data-type="scss"]', + }, + { + content: "select 'website.ui.scss'", + trigger: '#ace-scss-list', + run: function () { + var scssId = $('#ace-scss-list option:contains("website.ui")').val(); + $('#ace-scss-list').val(scssId).trigger('change'); + }, + }, + // 2. Edit that file and ensure it was saved then reset it + { + content: "add some scss content in the file", + trigger: 'div.ace_line .ace_variable:contains("body.o_connected_user")', + run: function () { + ace.edit('ace-view-editor').getSession().insert({row: 2, column: 0}, '#wrap {display: none;}\n'); + }, + }, + { + content: "save the html editor", + extra_trigger: 'div.ace_line:contains("#wrap {display: none;}")', + trigger: ".o_ace_view_editor button[data-action=save]", + }, + { + content: "check that the scss modification got applied", + trigger: 'body:has(#wrap:hidden)', + run: function () {}, // it's a check + }, + { + content: "reset view (after reload, html editor should have been reopened where it was)", + trigger: '#ace-view-id button[data-action="reset"]', + }, + { + content: "confirm reset warning", + trigger: '.modal-footer .btn-primary', + }, + { + content: "check that the scss file was reset correctly, wrap content should now be visible again", + trigger: '#wrap:visible', + run: function () {}, // it's a check + }, + ] +); + }); diff --git a/addons/website/tests/test_ui.py b/addons/website/tests/test_ui.py index 9a306e1092c..a9e9d502dbf 100644 --- a/addons/website/tests/test_ui.py +++ b/addons/website/tests/test_ui.py @@ -29,6 +29,9 @@ class TestUiHtmlEditor(odoo.tests.HttpCase): self.assertTrue(specific_aboutus.arch != oe_structure_layout, "Specific Aboutus view should have been changed") self.assertEqual(len(specific_aboutus.inherit_children_ids.filtered(lambda v: 'oe_structure' in v.name)), 1, "oe_structure view should have been created on the specific tree") + def test_html_editor_scss(self): + self.phantom_js("/", "odoo.__DEBUG__.services['web_tour.tour'].run('test_html_editor_scss')", "odoo.__DEBUG__.services['web_tour.tour'].tours.test_html_editor_scss.ready", login='admin') + class TestUiTranslate(odoo.tests.HttpCase): def test_admin_tour_rte_translator(self):