diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/test_website/static/tests | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/test_website/static/tests')
4 files changed, 383 insertions, 0 deletions
diff --git a/addons/test_website/static/tests/tours/custom_snippets.js b/addons/test_website/static/tests/tours/custom_snippets.js new file mode 100644 index 00000000..22f15c9a --- /dev/null +++ b/addons/test_website/static/tests/tours/custom_snippets.js @@ -0,0 +1,96 @@ +odoo.define('test_website.custom_snippets', function (require) { +'use strict'; + +var tour = require('web_tour.tour'); + +/** + * The purpose of this tour is to check the custom snippets flow: + * + * -> go to edit mode + * -> drag a banner into page content + * -> customize banner (set text) + * -> save banner as custom snippet + * -> confirm name (remove in master when implicit default name feature is implemented) + * -> confirm save & reload (remove in master because reload is not needed anymore) + * -> ensure custom snippet is available + * -> drag custom snippet + * -> ensure block appears as banner + * -> ensure block appears as custom banner + * -> delete custom snippet + * -> confirm delete + * -> ensure it was deleted + */ + +tour.register('test_custom_snippet', { + url: '/', + test: true +}, [ + { + content: "enter edit mode", + trigger: "a[data-action=edit]" + }, + { + content: "drop a snippet", + trigger: "#oe_snippets .oe_snippet[name='Banner'] .oe_snippet_thumbnail:not(.o_we_already_dragging)", + extra_trigger: "body.editor_enable.editor_has_snippets", + moveTrigger: ".oe_drop_zone", + run: "drag_and_drop #wrap", + }, + { + content: "customize snippet", + trigger: "#wrapwrap .s_banner h1", + run: "text", + consumeEvent: "input", + }, + { + content: "save custom snippet", + trigger: ".snippet-option-SnippetSave we-button", + }, + { + content: "confirm save name", + trigger: ".modal-dialog button span:contains('Save')", + }, + { + content: "confirm save and reload", + trigger: ".modal-dialog button span:contains('Save and Reload')", + }, + { + content: "ensure custom snippet appeared", + trigger: "#oe_snippets .oe_snippet[name='Custom Banner']", + run: function() {}, // check + }, + { + content: "drop custom snippet", + trigger: ".oe_snippet[name='Custom Banner'] .oe_snippet_thumbnail:not(.o_we_already_dragging)", + extra_trigger: "body.editor_enable.editor_has_snippets", + moveTrigger: ".oe_drop_zone", + run: "drag_and_drop #wrap", + }, + { + content: "ensure banner section exists", + trigger: "#wrap section[data-name='Banner']", + run: function() {}, // check + }, + { + content: "ensure custom banner section exists", + trigger: "#wrap section[data-name='Custom Banner']", + run: function() {}, // check + }, + { + content: "delete custom snippet", + trigger: ".oe_snippet[name='Custom Banner'] we-button.o_delete_btn", + extra_trigger: ".oe_snippet[name='Custom Banner'] .oe_snippet_thumbnail:not(.o_we_already_dragging)", + }, + { + content: "confirm delete", + trigger: ".modal-dialog button:has(span:contains('Yes'))", + }, + { + content: "ensure custom snippet disappeared", + trigger: "#oe_snippets", + extra_trigger: "#oe_snippets:not(:has(.oe_snippet[name='Custom Banner']))", + run: function() {}, // check + }, +]); + +}); diff --git a/addons/test_website/static/tests/tours/error_views.js b/addons/test_website/static/tests/tours/error_views.js new file mode 100644 index 00000000..0d0d4961 --- /dev/null +++ b/addons/test_website/static/tests/tours/error_views.js @@ -0,0 +1,152 @@ +odoo.define('test_website.error_views', function (require) { +'use strict'; + +var tour = require('web_tour.tour'); + +tour.register('test_error_website', { + test: true, + url: '/test_error_view', +}, +[ + // RPC ERROR + { + content: "trigger rpc user error", + trigger: 'a[href="/test_user_error_json"]', + }, { + content: "rpc user error modal has message", + extra_trigger: 'div.toast-body:contains("This is a user rpc test")', + trigger: 'button.o_notification_close', + }, { + content: "trigger rpc access error", + trigger: 'a[href="/test_access_error_json"]', + }, { + content: "rpc access error modal has message", + extra_trigger: 'div.toast-body:contains("This is an access rpc test")', + trigger: 'button.o_notification_close', + }, { + content: "trigger validation rpc error", + trigger: 'a[href="/test_validation_error_json"]', + }, { + content: "rpc validation error modal has message", + extra_trigger: 'div.toast-body:contains("This is a validation rpc test")', + trigger: 'button.o_notification_close', + }, { + content: "trigger rpc missing error", + trigger: 'a[href="/test_missing_error_json"]', + }, { + content: "rpc missing error modal has message", + extra_trigger: 'div.toast-body:contains("This is a missing rpc test")', + trigger: 'button.o_notification_close', + }, { + content: "trigger rpc error 403", + trigger: 'a[href="/test_access_denied_json"]', + }, { + content: "rpc error 403 modal has message", + extra_trigger: 'div.toast-body:contains("This is an access denied rpc test")', + trigger: 'button.o_notification_close', + }, { + content: "trigger rpc error 500", + trigger: 'a[href="/test_internal_error_json"]', + }, { + content: "rpc error 500 modal is an ErrorDialog", + extra_trigger: 'div.o_dialog_error.modal-body div.alert.alert-warning', + trigger: 'button.btn.btn-primary[type="button"]', + }, + // HTTP ERROR + { + content: "trigger http user error", + trigger: 'body', + run: function () { + window.location.href = window.location.origin + '/test_user_error_http?debug=0'; + }, + }, { + content: "http user error page has title and message", + extra_trigger: 'h1:contains("Something went wrong.")', + trigger: 'div.container pre:contains("This is a user http test")', + run: function () { + window.location.href = window.location.origin + '/test_user_error_http?debug=1'; + }, + }, { + content: "http user error page debug has title and message open", + extra_trigger: 'h1:contains("Something went wrong.")', + trigger: 'div#error_main.collapse.show pre:contains("This is a user http test")', + run: function () {}, + }, { + content: "http user error page debug has traceback closed", + trigger: 'body:has(div#error_traceback.collapse:not(.show) pre#exception_traceback)', + run: function () { + window.location.href = window.location.origin + '/test_validation_error_http?debug=0'; + }, + }, { + content: "http validation error page has title and message", + extra_trigger: 'h1:contains("Something went wrong.")', + trigger: 'div.container pre:contains("This is a validation http test")', + run: function () { + window.location.href = window.location.origin + '/test_validation_error_http?debug=1'; + }, + }, { + content: "http validation error page debug has title and message open", + extra_trigger: 'h1:contains("Something went wrong.")', + trigger: 'div#error_main.collapse.show pre:contains("This is a validation http test")', + run: function () {}, + }, { + content: "http validation error page debug has traceback closed", + trigger: 'body:has(div#error_traceback.collapse:not(.show) pre#exception_traceback)', + run: function () { + window.location.href = window.location.origin + '/test_access_error_http?debug=0'; + }, + }, { + content: "http access error page has title and message", + extra_trigger: 'h1:contains("403: Forbidden")', + trigger: 'div.container pre:contains("This is an access http test")', + run: function () { + window.location.href = window.location.origin + '/test_access_error_http?debug=1'; + }, + }, { + content: "http access error page debug has title and message open", + extra_trigger: 'h1:contains("403: Forbidden")', + trigger: 'div#error_main.collapse.show pre:contains("This is an access http test")', + run: function () {}, + }, { + content: "http access error page debug has traceback closed", + trigger: 'body:has(div#error_traceback.collapse:not(.show) pre#exception_traceback)', + run: function () { + window.location.href = window.location.origin + '/test_missing_error_http?debug=0'; + }, + }, { + content: "http missing error page has title and message", + extra_trigger: 'h1:contains("Something went wrong.")', + trigger: 'div.container pre:contains("This is a missing http test")', + run: function () { + window.location.href = window.location.origin + '/test_missing_error_http?debug=1'; + }, + }, { + content: "http missing error page debug has title and message open", + extra_trigger: 'h1:contains("Something went wrong.")', + trigger: 'div#error_main.collapse.show pre:contains("This is a missing http test")', + run: function () {}, + }, { + content: "http missing error page debug has traceback closed", + trigger: 'body:has(div#error_traceback.collapse:not(.show) pre#exception_traceback)', + run: function () { + window.location.href = window.location.origin + '/test_access_denied_http?debug=0'; + }, + }, { + content: "http error 403 page has title but no message", + extra_trigger: 'h1:contains("403: Forbidden")', + trigger: 'div#wrap:not(:has(pre:contains("This is an access denied http test"))', //See ir_http.py handle_exception, the exception is replaced so there is no message ! + run: function () { + window.location.href = window.location.origin + '/test_access_denied_http?debug=1'; + }, + }, { + content: "http 403 error page debug has title but no message", + extra_trigger: 'h1:contains("403: Forbidden")', + trigger: 'div#debug_infos:not(:has(#error_main))', + run: function () {}, + }, { + content: "http 403 error page debug has traceback open", + trigger: 'body:has(div#error_traceback.collapse.show pre#exception_traceback)', + run: function () {}, + }, +]); +}); diff --git a/addons/test_website/static/tests/tours/json_auth.js b/addons/test_website/static/tests/tours/json_auth.js new file mode 100644 index 00000000..ba89bed4 --- /dev/null +++ b/addons/test_website/static/tests/tours/json_auth.js @@ -0,0 +1,26 @@ +odoo.define('test_website.json_auth', function (require) { +'use strict'; + +var tour = require('web_tour.tour'); +var session = require('web.session') + +tour.register('test_json_auth', { + test: true, +}, [{ + trigger: 'body', + run: async function () { + await session.rpc('/test_get_dbname').then( function (result){ + return session.rpc("/web/session/authenticate", { + db: result, + login: 'admin', + password: 'admin' + }); + }); + window.location.href = window.location.origin; + }, +}, { + trigger: 'span:contains(Mitchell Admin), span:contains(Administrator)', + run: function () {}, +} +]); +}); diff --git a/addons/test_website/static/tests/tours/reset_views.js b/addons/test_website/static/tests/tours/reset_views.js new file mode 100644 index 00000000..cf2853f4 --- /dev/null +++ b/addons/test_website/static/tests/tours/reset_views.js @@ -0,0 +1,109 @@ +odoo.define('test_website.reset_views', function (require) { +'use strict'; + +var tour = require("web_tour.tour"); + +var BROKEN_STEP = { + // because saving a broken template opens a recovery page with no assets + // there's no way for the tour to resume on the new page, and thus no way + // to properly wait for the page to be saved & reloaded in order to fix the + // race condition of a tour ending on a side-effect (with the possible + // exception of somehow telling the harness / browser to do it) + trigger: 'body', + run: function () {} +}; +tour.register('test_reset_page_view_complete_flow_part1', { + test: true, + url: '/test_page_view', +}, + [ + // 1. Edit the page through Edit Mode, it will COW the view + { + content: "enter edit mode", + trigger: "a[data-action=edit]" + }, + { + content: "drop a snippet", + trigger: "#oe_snippets .oe_snippet:has(.s_cover) .oe_snippet_thumbnail", + // id starting by 'oe_structure..' will actually create an inherited view + run: "drag_and_drop #oe_structure_test_website_page", + }, + { + content: "save the page", + extra_trigger: '#oe_structure_test_website_page.o_dirty', + trigger: "button[data-action=save]", + }, + // 2. Edit that COW'd view in the HTML editor to break it. + { + content: "open customize menu", + extra_trigger: "body:not(.editor_enable)", + trigger: '#customize-menu > a', + }, + { + content: "open html editor", + trigger: '#html_editor', + }, + { + content: "add a broken t-field in page DOM", + trigger: 'div.ace_line .ace_xml:contains("placeholder")', + run: function () { + ace.edit('ace-view-editor').getSession().insert({row: 4, column: 1}, '<t t-field="not.exist"/>\n'); + }, + }, + { + content: "save the html editor", + extra_trigger: '.ace_content:contains("not.exist")', + trigger: ".o_ace_view_editor button[data-action=save]", + }, + BROKEN_STEP + ] +); + +tour.register('test_reset_page_view_complete_flow_part2', { + test: true, + url: '/test_page_view', +}, + [ + { + content: "check that the view got fixed", + trigger: 'p:containsExact("Test Page View")', + run: function () {}, // it's a check + }, + { + content: "check that the inherited COW view is still there (created during edit mode)", + trigger: '#oe_structure_test_website_page .s_cover', + run: function () {}, // it's a check + }, + //4. Now break the inherited view created when dropping a snippet + { + content: "open customize menu", + trigger: '#customize-menu > a', + }, + { + content: "open html editor", + trigger: '#html_editor', + }, + { + content: "select oe_structure view", + trigger: '#s2id_ace-view-list', // use select2 version + run: function () { + var viewId = $('#ace-view-list option:contains("oe_structure_test_website_page")').val(); + $('#ace-view-list').val(viewId).trigger('change'); + }, + }, + { + content: "add a broken t-field in page DOM", + trigger: 'div.ace_line .ace_xml:contains("oe_structure_test_website_page")', + run: function () { + ace.edit('ace-view-editor').getSession().insert({row: 4, column: 1}, '<t t-field="not.exist"/>\n'); + }, + }, + { + content: "save the html editor", + trigger: ".o_ace_view_editor button[data-action=save]", + }, + BROKEN_STEP + ] +); + +}); |
