From faebb4a1e2802a5f90fc8b24dbabe72dd75f39ef Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 31 Aug 2016 16:05:27 +0200 Subject: [PATCH] [IMP] website_form_editor: convert test to web_tour --- static/src/js/website_form_editor_tour.js | 1243 ++++++++++----------- tests/test_website_form_editor.py | 6 +- 2 files changed, 619 insertions(+), 630 deletions(-) diff --git a/static/src/js/website_form_editor_tour.js b/static/src/js/website_form_editor_tour.js index a56115d2cd1..7bb36a2125f 100644 --- a/static/src/js/website_form_editor_tour.js +++ b/static/src/js/website_form_editor_tour.js @@ -2,644 +2,633 @@ odoo.define('website_form_editor.tour', function(require) { 'use strict'; var base = require('web_editor.base'); - var Tour = require('web.Tour'); + var tour = require("web_tour.tour"); var Model = require('web.Model'); - base.ready().done(function () { - Tour.register({ - id: 'website_form_editor_tour', - name: "Try to create some forms", - path: '/', - mode: 'test', - steps: [ - // Drop a form builder snippet and configure it - { - title: "Enter edit mode", - element: "a[data-action=edit]" - }, - { - title: "Drop the form snippet", - snippet: "#snippet_feature .oe_snippet[name='Form Builder']" - }, - { - title: "Check if the snippet is dropped and if the modal is opened", - waitFor: "body:has(form[action*='/website_form/'])" + - ":has(.modal-body:has(select[name='model_selection'])" + - ":has(input[name='success_page']))" - }, - { - title: "Change the action to create issues", - element: ".modal-body select", - sampleText: "project.issue" + tour.register("website_form_editor_tour", { + test: true, + wait_for: base.ready() + }, [ + // Drop a form builder snippet and configure it + { + content: "Enter edit mode", + trigger: "a[data-action=edit]" + }, + { + content: "Drop the form snippet", + trigger: "#oe_snippets .oe_snippet:has(.s_website_form) .oe_snippet_thumbnail", + run: "drag_and_drop", + }, + { + content: "Check if the snippet is dropped and if the modal is opened", + trigger: "body:has(form[action*='/website_form/'])" + + ":has(.modal-body:has(select[name='model_selection'])" + + ":has(input[name='success_page']))", + run: function () {}, + in_modal: false, + }, + { + content: "Change the action to create issues", + trigger: ".modal-body select", + run: "text project.issue" + }, + { + content: "Change the action to Send an E-mail", + trigger: ".modal-body select", + run: "text mail.mail" + }, + { + content: "Complete Recipient E-mail", + extra_trigger: ".modal-body input[name='email_to']", + trigger: ".modal-body input[name='email_to']", + run: "text test@test.test" + }, + { + content: "Click on Save", + trigger: ".modal-footer #modal-save" + }, + // Add the subject field + { + content: "Click on Form snippet", + trigger: ".s_website_form[data-model_name]" + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Add a model field", + trigger: ".oe_overlay_options:visible li[data-website_form_field_modal] a" + }, + { + content: "Select the subject field", + trigger: "select[name='field_selection']", + run: "text subject" + }, + { + content: "Click on Save", + trigger: ".modal-footer #modal-save" + }, - }, - { - title: "Change the action to Send an E-mail", - // waitFor: ".modal-body .o_form-action-mailto:hidden", - element: ".modal-body select", - sampleText: "mail.mail" - }, - { - title: "Complete Recipient E-mail", - waitFor: ".modal-body input[name='email_to']", - element: ".modal-body input[name='email_to']", - sampleText: "test@test.test" - }, - { - title: "Click on Save", - element: ".modal-footer #modal-save" - }, - // Add the subject field - { - title: "Click on Form snippet", - element: ".s_website_form[data-model_name]" - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Add a model field", - element: ".oe_overlay_options:visible li[data-website_form_field_modal] a" - }, - { - title: "Select the subject field", - element: "select[name='field_selection']", - sampleText: "subject" - }, - { - title: "Click on Save", - element: ".modal-footer #modal-save" - }, + // Customize subject field + { + content: "Change the label", + trigger: ".control-label[for='subject']", + run: "text Name" + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Required", + trigger: ".oe_overlay_options:visible li[data-website_form_field_require] a" + }, + { + content: "Check the resulting field", + trigger: ".form-field.o_website_form_required_custom" + + ":has(input[type=text][name=subject][required])" + + ":has(label:contains('Name'))", + run: function () {}, + }, - // Customize subject field - { - title: "Change the label", - element: ".control-label[for='subject']", - sampleText: "Name" - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Required", - element: ".oe_overlay_options:visible li[data-website_form_field_require] a" - }, - { - title: "Check the resulting field", - waitFor: ".form-field.o_website_form_required_custom" + - ":has(input[type=text][name=subject][required])" + - ":has(label:contains('Name'))" - }, + // Add record_name field + { + content: "Click on Form snippet", + trigger: ".s_website_form[data-model_name]" + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Add a model field", + trigger: ".oe_overlay_options:visible li[data-website_form_field_modal] a" + }, + { + content: "Select the record_name field", + trigger: "select[name='field_selection']", + run: "text record_name" + }, + { + content: "Click on Save", + trigger: ".modal-footer #modal-save" + }, - // Add record_name field - { - title: "Click on Form snippet", - element: ".s_website_form[data-model_name]" - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Add a model field", - element: ".oe_overlay_options:visible li[data-website_form_field_modal] a" - }, - { - title: "Select the record_name field", - element: "select[name='field_selection']", - sampleText: "record_name" - }, - { - title: "Click on Save", - element: ".modal-footer #modal-save" - }, - - // Customize record_name field - { - title: "Change the label", - element: ".control-label[for='record_name']", - sampleText: "Awesome Label" - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Hidden", - element: ".oe_overlay_options:visible li[data-toggle_class='o_website_form_field_hidden'] a" - }, - { - title: "Check the resulting field", - waitFor: ".form-field.o_website_form_field_hidden" + - ":has(input:not([required])[type=text][name=record_name])" + - ":has(label:contains('Awesome Label'))" - }, + // Customize record_name field + { + content: "Change the label", + trigger: ".control-label[for='record_name']", + run: "text Awesome Label" + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Hidden", + trigger: ".oe_overlay_options:visible li[data-toggle_class='o_website_form_field_hidden'] a" + }, + { + content: "Check the resulting field", + trigger: ".form-field.o_website_form_field_hidden" + + ":has(input:not([required])[type=text][name=record_name])" + + ":has(label:contains('Awesome Label'))", + run: function () {}, + }, - // Add body_html field - { - title: "Click on Form snippet", - element: ".s_website_form[data-model_name]" - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Add a model field", - element: ".oe_overlay_options:visible li[data-website_form_field_modal] a" - }, - { - title: "Select the body_html field", - element: "select[name='field_selection']", - sampleText: "body_html" - }, - { - title: "Click on Save", - element: ".modal-footer #modal-save" - }, + // Add body_html field + { + content: "Click on Form snippet", + trigger: ".s_website_form[data-model_name]" + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Add a model field", + trigger: ".oe_overlay_options:visible li[data-website_form_field_modal] a" + }, + { + content: "Select the body_html field", + trigger: "select[name='field_selection']", + run: "text body_html" + }, + { + content: "Click on Save", + trigger: ".modal-footer #modal-save" + }, - // Customize subject field - { - title: "Change the label", - element: ".control-label[for='body_html']", - sampleText: "Your Message" - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Required", - element: ".oe_overlay_options:visible li[data-website_form_field_require] a" - }, - { - title: "Check the resulting field", - waitFor: ".form-field.o_website_form_required_custom" + - ":has(textarea[name=body_html][required])" + - ":has(label:contains('Your Message'))" - }, + // Customize subject field + { + content: "Change the label", + trigger: ".control-label[for='body_html']", + run: "text Your Message" + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Required", + trigger: ".oe_overlay_options:visible li[data-website_form_field_require] a" + }, + { + content: "Check the resulting field", + trigger: ".form-field.o_website_form_required_custom" + + ":has(textarea[name=body_html][required])" + + ":has(label:contains('Your Message'))", + run: function () {}, + }, - // Add recipient_ids relational field - { - title: "Click on Form snippet", - element: ".s_website_form[data-model_name]" - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Add a model field", - element: ".oe_overlay_options:visible li[data-website_form_field_modal] a" - }, - { - title: "Select the recipient_ids field", - element: "select[name='field_selection']", - sampleText: "recipient_ids" - }, - { - title: "Click on Save", - element: ".modal-footer #modal-save" - }, - { - title: "Check the resulting field", - waitFor: ".form-field:has(.control-label:contains('To (Partners)'))" - }, + // Add recipient_ids relational field + { + content: "Click on Form snippet", + trigger: ".s_website_form[data-model_name]" + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Add a model field", + trigger: ".oe_overlay_options:visible li[data-website_form_field_modal] a" + }, + { + content: "Select the recipient_ids field", + trigger: "select[name='field_selection']", + run: "text recipient_ids" + }, + { + content: "Click on Save", + trigger: ".modal-footer #modal-save" + }, + { + content: "Check the resulting field", + trigger: ".form-field:has(.control-label:contains('To (Partners)'))", + run: function () {}, + }, - // Add a custom multiple checkboxes field - { - title: "Click on Form snippet", - element: ".s_website_form[data-model_name]", - onend: function() { - // I didn't find any other way to make that submenu element appear - $(".oe_options > ul > li:has(ul) > ul").css("display", "block"); + // Add a custom multiple checkboxes field + { + content: "Click on Form snippet", + trigger: ".s_website_form[data-model_name]", + run: function (actions) { + actions.auto(); + // I didn't find any other way to make that submenu element appear + $(".oe_options > ul > li:has(ul) > ul").css("display", "block"); + } + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Multiple Checkboxes in menu Add a custom field", + trigger: ".oe_options li a:contains('Multiple Checkboxes')" + }, + + // Customize custom multiple checkboxes field + { + content: "Change the label", + trigger: ".control-label[for='Custom Multiple Checkboxes']", + run: "text Products" + }, + { + content: "Change Option 1 label", + trigger: "label:contains('Option 1') span", + run: "text Iphone" + }, + { + content: "Change Option 2 label", + trigger: "label:contains('Option 2') span", + run: "text Galaxy S" + }, + { + content: "Click on Option 3", + trigger: "label:contains('Option 3') span", + }, + { + content: "Duplicate Option 3", + trigger: ".oe_overlay_options:visible .oe_snippet_clone", + }, + { + content: "Change first Option 3 label", + trigger: "label:contains('Option 3'):first span", + run: "text Xperia" + }, + { + content: "Change last Option label", + trigger: "label:contains('Option 3') span", + run: "text Wiko Stairway" + }, + { + content: "Click on field", + trigger: ".control-label:contains('Products')" + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Required", + trigger: ".oe_overlay_options:visible li[data-website_form_field_require] a" + }, + { + content: "Check the resulting field", + trigger: ".form-field.o_website_form_custom.o_website_form_required_custom" + + ":has(.control-label:contains('Products'))" + + ":has(.checkbox label:contains('Iphone'):has(input[type='checkbox'][required]))" + + ":has(.checkbox label:contains('Galaxy S'):has(input[type='checkbox'][required]))" + + ":has(.checkbox label:contains('Xperia'):has(input[type='checkbox'][required]))" + + ":has(.checkbox label:contains('Wiko Stairway'):has(input[type='checkbox'][required]))", + run: function () {}, + }, + + // Add a custom radio field + { + content: "Click on Form snippet", + trigger: ".s_website_form[data-model_name]", + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Radio Buttons in menu Add a custom field", + trigger: ".oe_options li a:contains('Radio Buttons')" + }, + + // Customize custom multiple checkboxes field + { + content: "Change the label", + trigger: ".control-label[for='Custom Radio Buttons']", + run: "text Service" + }, + { + content: "Change Option 1 label", + trigger: "label:contains('Option 1') span", + run: "text After-sales Service" + }, + { + content: "Change Option 2 label", + trigger: "label:contains('Option 2') span", + run: "text Invoicing Service" + }, + { + content: "Click on Option 3", + trigger: "label:contains('Option 3') span", + }, + { + content: "Duplicate Option 3", + trigger: ".oe_overlay_options:visible .oe_snippet_clone", + }, + { + content: "Change first Option 3 label", + trigger: "label:contains('Option 3'):first span", + run: "text Development Service" + }, + { + content: "Change last Option label", + trigger: "label:contains('Option 3') span", + run: "text Management Service" + }, + { + content: "Click on field", + trigger: ".control-label:contains('Service')" + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Required", + trigger: ".oe_overlay_options:visible li[data-website_form_field_require] a" + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Required", + trigger: ".oe_overlay_options:visible li[data-website_form_field_require] a" + }, + { + content: "Check the resulting field", + trigger: ".form-field.o_website_form_custom:not(.o_website_form_required_custom)" + + ":has(.control-label:contains('Service'))" + + ":has(.radio label:contains('After-sales Service'):has(input[type='radio']:not([required])))" + + ":has(.radio label:contains('Invoicing Service'):has(input[type='radio']:not([required])))" + + ":has(.radio label:contains('Development Service'):has(input[type='radio']:not([required])))" + + ":has(.radio label:contains('Management Service'):has(input[type='radio']:not([required])))", + run: function () {}, + }, + + + // Add a custom selection field + { + content: "Click on Form snippet", + trigger: ".s_website_form[data-model_name]", + onend: function() { + // I didn't find any other way to make that submenu element appear + $(".oe_options > ul > li:has(ul) > ul").css("display", "block"); + } + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Selection in menu Add a custom field", + trigger: ".oe_options li a:contains('Selection')" + }, + + // Customize custom selection field + { + content: "Change the label", + trigger: ".control-label[for='Custom Selection']", + run: "text State" + }, + { + content: "Change Option 1 Label", + trigger: ".o_website_form_select_item:contains('Option 1')", + run: "text Germany" + }, + { + content: "Change Option 2 Label", + trigger: ".o_website_form_select_item:contains('Option 2')", + run: "text Belgium" + }, + { + content: "Click on Option 3", + trigger: ".o_website_form_select_item:contains('Option 3')", + }, + { + content: "Duplicate Option 3", + trigger: ".oe_overlay_options:visible .oe_snippet_clone", + }, + { + content: "Change first Option 3 label", + trigger: ".o_website_form_select_item:contains('Option 3'):first", + run: "text France" + }, + { + content: "Change last Option label", + trigger: ".o_website_form_select_item:contains('Option 3')", + run: "text Canada" + }, + { + content: "Click on Germany Option", + trigger: ".o_website_form_select_item:contains('Germany')", + }, + { + content: "Remove Germany Option", + trigger: ".oe_overlay_options:visible .oe_snippet_remove", + }, + { + content: "Click on field", + trigger: ".control-label:contains('State')" + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Required", + trigger: ".oe_overlay_options:visible li[data-website_form_field_require] a" + }, + { + content: "Check the resulting snippet", + trigger: ".form-field.o_website_form_custom.o_website_form_required_custom" + + ":has(label:contains('State'))" + + ":has(select[required]:hidden)" + + ":has(.o_website_form_select_item:contains('Belgium'))" + + ":has(.o_website_form_select_item:contains('France'))" + + ":has(.o_website_form_select_item:contains('Canada'))" + + ":not(:has(.o_website_form_select_item:contains('Germany')))", + run: function () {}, + }, + + // Add attachment_ids field + { + content: "Click on Form snippet", + trigger: ".s_website_form[data-model_name]" + }, + { + content: "Click on Customize", + trigger: ".oe_overlay_options:visible a[title='Customize']" + }, + { + content: "Click on Add a model field", + trigger: ".oe_overlay_options:visible li[data-website_form_field_modal] a" + }, + { + content: "Select the attachment_ids field", + trigger: "select[name='field_selection']", + run: "text attachment_ids" + }, + { + content: "Click on Save", + trigger: ".modal-footer #modal-save" + }, + + // Customize attachment_ids field + { + content: "Change the label", + trigger: ".control-label[for='attachment_ids']", + run: "text Invoice Scan" + }, + { + content: "Check the resulting field", + trigger: ".form-field" + + ":has(input[type=file][name=attachment_ids])" + + ":has(label:contains('Invoice Scan'))", + run: function () { + $('body').append('
'); + }, + }, + + // Save the page + { + content: "Save the page", + trigger: "button[data-action=save]", + }, + { + content: "Wait reloading...", + trigger: "html:not(:has(#completlyloaded)) div", + } + ]); + + tour.register("website_form_editor_tour_submit", { + test: true, + wait_for: base.ready() + },[ + { + content: "Try to send empty form", + extra_trigger: "form[data-model_name='mail.mail']" + + "[data-success_page='']" + + ":has(.form-field:has(label:contains('Name')):has(input[type='text'][name='subject'][required]))" + + ":has(.form-field:has(label:contains('Awesome Label')):hidden)" + + ":has(.form-field:has(label:contains('Your Message')):has(textarea[name='body_html'][required]))" + + ":has(.form-field:has(label:contains('Products')):has(input[type='checkbox'][name='Products'][value='Iphone'][required]))" + + ":has(.form-field:has(label:contains('Products')):has(input[type='checkbox'][name='Products'][value='Galaxy S'][required]))" + + ":has(.form-field:has(label:contains('Products')):has(input[type='checkbox'][name='Products'][value='Xperia'][required]))" + + ":has(.form-field:has(label:contains('Products')):has(input[type='checkbox'][name='Products'][value='Wiko Stairway'][required]))" + + ":has(.form-field:has(label:contains('Service')):has(input[type='radio'][name='Service'][value='After-sales Service']:not([required])))" + + ":has(.form-field:has(label:contains('Service')):has(input[type='radio'][name='Service'][value='Invoicing Service']:not([required])))" + + ":has(.form-field:has(label:contains('Service')):has(input[type='radio'][name='Service'][value='Development Service']:not([required])))" + + ":has(.form-field:has(label:contains('Service')):has(input[type='radio'][name='Service'][value='Management Service']:not([required])))" + + ":has(.form-field:has(label:contains('State')):has(select[name='State'][required]:has(option[value='Belgium'])))" + + ":has(.form-field.o_website_form_required_custom:has(label:contains('State')):has(select[name='State'][required]:has(option[value='France'])))" + + ":has(.form-field:has(label:contains('State')):has(select[name='State'][required]:has(option[value='Canada'])))" + + ":has(.form-field:has(label:contains('Invoice Scan')))" + + ":has(input.form-field[name='email_to'][value='test@test.test'])", + trigger: ".o_website_form_send" + }, + { + content: "Check if required fields were detected and complete the Name field", + extra_trigger: "form:has(#o_website_form_result.text-danger)" + + ":has(.form-field:has(label:contains('Name')).has-error)" + + ":has(.form-field:has(label:contains('Your Message')).has-error)" + + ":has(.form-field:has(label:contains('Products')).has-error)" + + ":has(.form-field:has(label:contains('Service')):not(.has-error))" + + ":has(.form-field:has(label:contains('State')):not(.has-error))" + + ":has(.form-field:has(label:contains('Invoice Scan')):not(.has-error))", + trigger: "input[name=subject]", + run: "text Jane Smith" + }, + { + content: "Update required field status by trying to Send again", + trigger: ".o_website_form_send" + }, + { + content: "Check if required fields were detected and complete the Message field", + extra_trigger: "form:has(#o_website_form_result.text-danger)" + + ":has(.form-field:has(label:contains('Name')):not(.has-error))" + + ":has(.form-field:has(label:contains('Your Message')).has-error)" + + ":has(.form-field:has(label:contains('Products')).has-error)" + + ":has(.form-field:has(label:contains('Service')):not(.has-error))" + + ":has(.form-field:has(label:contains('State')):not(.has-error))" + + ":has(.form-field:has(label:contains('Invoice Scan')):not(.has-error))", + trigger: "textarea[name=body_html]", + run: "text A useless message" + }, + { + content: "Update required field status by trying to Send again", + trigger: ".o_website_form_send" + }, + { + content: "Check if required fields was detected and check a product. If this fails, you probably broke the clean_for_save.", + extra_trigger: "form:has(#o_website_form_result.text-danger)" + + ":has(.form-field:has(label:contains('Name')):not(.has-error))" + + ":has(.form-field:has(label:contains('Your Message')):not(.has-error))" + + ":has(.form-field:has(label:contains('Products')).has-error)" + + ":has(.form-field:has(label:contains('Service')):not(.has-error))" + + ":has(.form-field:has(label:contains('State')):not(.has-error))" + + ":has(.form-field:has(label:contains('Invoice Scan')):not(.has-error))", + trigger: "input[name=Products][value='Wiko Stairway']" + }, + { + content: "Check another product", + trigger: "input[name='Products'][value='Xperia']" + }, + { + content: "Check a service", + trigger: "input[name='Service'][value='Development Service']" + }, + { + content: "Send the form", + trigger: ".o_website_form_send" + }, + { + content: "Check form is submitted without errors", + trigger: "form:has(#o_website_form_result.text-success)" + + ":has(.form-field:has(label:contains('Name')):not(.has-error))" + + ":has(.form-field:has(label:contains('Your Message')):not(.has-error))" + + ":has(.form-field:has(label:contains('Products')):not(.has-error))" + + ":has(.form-field:has(label:contains('Service')):not(.has-error))" + + ":has(.form-field:has(label:contains('State')):not(.has-error))" + + ":has(.form-field:has(label:contains('Invoice Scan')):not(.has-error))" + } + ]); + + tour.register("website_form_editor_tour_results", { + test: true, + wait_for: base.ready() + }, [ + { + content: "Check mail.mail records have been created", + trigger: "body", + run: function () { + var mailDef = new Model("mail.mail").call( + "search_read", + [ + // TODO: add other fields in domain ! + [ + ['email_to', '=', 'test@test.test'], + ['body_html', 'like', 'A useless message'], + ['body_html', 'like', 'Service : Development Service'], + ['body_html', 'like', 'State : Belgium'], + ['body_html', 'like', 'Products : Xperia,Wiko Stairway'] + ], + [] + ] + ); + var success = function(model, data) { + if(data.length) { + $('body').append('
'); } - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Multiple Checkboxes in menu Add a custom field", - element: ".oe_options li a:contains('Multiple Checkboxes')" - }, - - // Customize custom multiple checkboxes field - { - title: "Change the label", - element: ".control-label[for='Custom Multiple Checkboxes']", - sampleText: "Products" - }, - { - title: "Change Option 1 label", - element: "label:contains('Option 1') span", - sampleText: "Iphone" - }, - { - title: "Change Option 2 label", - element: "label:contains('Option 2') span", - sampleText: "Galaxy S" - }, - { - title: "Click on Option 3", - element: "label:contains('Option 3') span", - }, - { - title: "Duplicate Option 3", - element: ".oe_overlay_options:visible .oe_snippet_clone", - }, - { - title: "Change first Option 3 label", - element: "label:contains('Option 3'):first span", - sampleText: "Xperia" - }, - { - title: "Change last Option label", - element: "label:contains('Option 3') span", - sampleText: "Wiko Stairway" - }, - { - title: "Click on field", - element: ".control-label:contains('Products')" - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Required", - element: ".oe_overlay_options:visible li[data-website_form_field_require] a" - }, - { - title: "Check the resulting field", - waitFor: ".form-field.o_website_form_custom.o_website_form_required_custom" + - ":has(.control-label:contains('Products'))" + - ":has(.checkbox label:contains('Iphone'):has(input[type='checkbox'][required]))" + - ":has(.checkbox label:contains('Galaxy S'):has(input[type='checkbox'][required]))" + - ":has(.checkbox label:contains('Xperia'):has(input[type='checkbox'][required]))" + - ":has(.checkbox label:contains('Wiko Stairway'):has(input[type='checkbox'][required]))" - }, - - // Add a custom radio field - { - title: "Click on Form snippet", - element: ".s_website_form[data-model_name]", - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Radio Buttons in menu Add a custom field", - element: ".oe_options li a:contains('Radio Buttons')" - }, - - // Customize custom multiple checkboxes field - { - title: "Change the label", - element: ".control-label[for='Custom Radio Buttons']", - sampleText: "Service" - }, - { - title: "Change Option 1 label", - element: "label:contains('Option 1') span", - sampleText: "After-sales Service" - }, - { - title: "Change Option 2 label", - element: "label:contains('Option 2') span", - sampleText: "Invoicing Service" - }, - { - title: "Click on Option 3", - element: "label:contains('Option 3') span", - }, - { - title: "Duplicate Option 3", - element: ".oe_overlay_options:visible .oe_snippet_clone", - }, - { - title: "Change first Option 3 label", - element: "label:contains('Option 3'):first span", - sampleText: "Development Service" - }, - { - title: "Change last Option label", - element: "label:contains('Option 3') span", - sampleText: "Management Service" - }, - { - title: "Click on field", - element: ".control-label:contains('Service')" - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Required", - element: ".oe_overlay_options:visible li[data-website_form_field_require] a" - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Required", - element: ".oe_overlay_options:visible li[data-website_form_field_require] a" - }, - { - title: "Check the resulting field", - waitFor: ".form-field.o_website_form_custom:not(.o_website_form_required_custom)" + - ":has(.control-label:contains('Service'))" + - ":has(.radio label:contains('After-sales Service'):has(input[type='radio']:not([required])))" + - ":has(.radio label:contains('Invoicing Service'):has(input[type='radio']:not([required])))" + - ":has(.radio label:contains('Development Service'):has(input[type='radio']:not([required])))" + - ":has(.radio label:contains('Management Service'):has(input[type='radio']:not([required])))" - }, - - - // Add a custom selection field - { - title: "Click on Form snippet", - element: ".s_website_form[data-model_name]", - onend: function() { - // I didn't find any other way to make that submenu element appear - $(".oe_options > ul > li:has(ul) > ul").css("display", "block"); - } - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Selection in menu Add a custom field", - element: ".oe_options li a:contains('Selection')" - }, - - // Customize custom selection field - { - title: "Change the label", - element: ".control-label[for='Custom Selection']", - sampleText: "State" - }, - { - title: "Change Option 1 Label", - element: ".o_website_form_select_item:contains('Option 1')", - sampleText: "Germany" - }, - { - title: "Change Option 2 Label", - element: ".o_website_form_select_item:contains('Option 2')", - sampleText: "Belgium" - }, - { - title: "Click on Option 3", - element: ".o_website_form_select_item:contains('Option 3')", - }, - { - title: "Duplicate Option 3", - element: ".oe_overlay_options:visible .oe_snippet_clone", - }, - { - title: "Change first Option 3 label", - element: ".o_website_form_select_item:contains('Option 3'):first", - sampleText: "France" - }, - { - title: "Change last Option label", - element: ".o_website_form_select_item:contains('Option 3')", - sampleText: "Canada" - }, - { - title: "Click on Germany Option", - element: ".o_website_form_select_item:contains('Germany')", - }, - { - title: "Remove Germany Option", - element: ".oe_overlay_options:visible .oe_snippet_remove", - }, - { - title: "Click on field", - element: ".control-label:contains('State')" - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Required", - element: ".oe_overlay_options:visible li[data-website_form_field_require] a" - }, - { - title: "Check the resulting snippet", - waitFor: ".form-field.o_website_form_custom.o_website_form_required_custom" + - ":has(label:contains('State'))" + - ":has(select[required]:hidden)" + - ":has(.o_website_form_select_item:contains('Belgium'))" + - ":has(.o_website_form_select_item:contains('France'))" + - ":has(.o_website_form_select_item:contains('Canada'))" + - ":not(:has(.o_website_form_select_item:contains('Germany')))" - }, - - // Add attachment_ids field - { - title: "Click on Form snippet", - element: ".s_website_form[data-model_name]" - }, - { - title: "Click on Customize", - element: ".oe_overlay_options:visible a[title='Customize']" - }, - { - title: "Click on Add a model field", - element: ".oe_overlay_options:visible li[data-website_form_field_modal] a" - }, - { - title: "Select the attachment_ids field", - element: "select[name='field_selection']", - sampleText: "attachment_ids" - }, - { - title: "Click on Save", - element: ".modal-footer #modal-save" - }, - - // Customize attachment_ids field - { - title: "Change the label", - element: ".control-label[for='attachment_ids']", - sampleText: "Invoice Scan" - }, - { - title: "Check the resulting field", - waitFor: ".form-field" + - ":has(input[type=file][name=attachment_ids])" + - ":has(label:contains('Invoice Scan'))" - }, - - // Save the page - { - title: "Save the page", - element: "button[data-action=save]", - onload: function (tour) { - setTimeout(function(){ - $('html').append('
'); - }, 1000); - } - }, - { - title: "Wait reloading...", - waitFor: "#completlyloaded", - onload: function (tour) { - $("#completlyloaded").remove(); - } - } - ] - }); - - Tour.register({ - id: 'website_form_editor_tour_submit', - name: "Check created form works correctly", - path: '/', - mode: 'test', - steps: [ - { - title: "Try to send empty form", - waitFor: "form[data-model_name='mail.mail']" + - "[data-success_page='']" + - ":has(.form-field:has(label:contains('Name')):has(input[type='text'][name='subject'][required]))" + - ":has(.form-field:has(label:contains('Awesome Label')):hidden)" + - ":has(.form-field:has(label:contains('Your Message')):has(textarea[name='body_html'][required]))" + - ":has(.form-field:has(label:contains('Products')):has(input[type='checkbox'][name='Products'][value='Iphone'][required]))" + - ":has(.form-field:has(label:contains('Products')):has(input[type='checkbox'][name='Products'][value='Galaxy S'][required]))" + - ":has(.form-field:has(label:contains('Products')):has(input[type='checkbox'][name='Products'][value='Xperia'][required]))" + - ":has(.form-field:has(label:contains('Products')):has(input[type='checkbox'][name='Products'][value='Wiko Stairway'][required]))" + - ":has(.form-field:has(label:contains('Service')):has(input[type='radio'][name='Service'][value='After-sales Service']:not([required])))" + - ":has(.form-field:has(label:contains('Service')):has(input[type='radio'][name='Service'][value='Invoicing Service']:not([required])))" + - ":has(.form-field:has(label:contains('Service')):has(input[type='radio'][name='Service'][value='Development Service']:not([required])))" + - ":has(.form-field:has(label:contains('Service')):has(input[type='radio'][name='Service'][value='Management Service']:not([required])))" + - ":has(.form-field:has(label:contains('State')):has(select[name='State'][required]:has(option[value='Belgium'])))" + - ":has(.form-field.o_website_form_required_custom:has(label:contains('State')):has(select[name='State'][required]:has(option[value='France'])))" + - ":has(.form-field:has(label:contains('State')):has(select[name='State'][required]:has(option[value='Canada'])))" + - ":has(.form-field:has(label:contains('Invoice Scan')))" + - ":has(input.form-field[name='email_to'][value='test@test.test'])", - element: ".o_website_form_send" - }, - { - title: "Check if required fields were detected and complete the Name field", - waitFor: "form:has(#o_website_form_result.text-danger)" + - ":has(.form-field:has(label:contains('Name')).has-error)" + - ":has(.form-field:has(label:contains('Your Message')).has-error)" + - ":has(.form-field:has(label:contains('Products')).has-error)" + - ":has(.form-field:has(label:contains('Service')):not(.has-error))" + - ":has(.form-field:has(label:contains('State')):not(.has-error))" + - ":has(.form-field:has(label:contains('Invoice Scan')):not(.has-error))", - element: "input[name=subject]", - sampleText: "Jane Smith" - }, - { - title: "Update required field status by trying to Send again", - element: ".o_website_form_send" - }, - { - title: "Check if required fields were detected and complete the Message field", - waitFor: "form:has(#o_website_form_result.text-danger)" + - ":has(.form-field:has(label:contains('Name')):not(.has-error))" + - ":has(.form-field:has(label:contains('Your Message')).has-error)" + - ":has(.form-field:has(label:contains('Products')).has-error)" + - ":has(.form-field:has(label:contains('Service')):not(.has-error))" + - ":has(.form-field:has(label:contains('State')):not(.has-error))" + - ":has(.form-field:has(label:contains('Invoice Scan')):not(.has-error))", - element: "textarea[name=body_html]", - sampleText: "A useless message" - }, - { - title: "Update required field status by trying to Send again", - element: ".o_website_form_send" - }, - { - title: "Check if required fields was detected and check a product. If this fails, you probably broke the clean_for_save.", - waitFor: "form:has(#o_website_form_result.text-danger)" + - ":has(.form-field:has(label:contains('Name')):not(.has-error))" + - ":has(.form-field:has(label:contains('Your Message')):not(.has-error))" + - ":has(.form-field:has(label:contains('Products')).has-error)" + - ":has(.form-field:has(label:contains('Service')):not(.has-error))" + - ":has(.form-field:has(label:contains('State')):not(.has-error))" + - ":has(.form-field:has(label:contains('Invoice Scan')):not(.has-error))", - element: "input[name=Products][value='Wiko Stairway']" - }, - { - title: "Check another product", - element: "input[name='Products'][value='Xperia']" - }, - { - title: "Check a service", - element: "input[name='Service'][value='Development Service']" - }, - { - title: "Send the form", - element: ".o_website_form_send" - }, - { - title: "Check form is submitted without errors", - waitFor: "form:has(#o_website_form_result.text-success)" + - ":has(.form-field:has(label:contains('Name')):not(.has-error))" + - ":has(.form-field:has(label:contains('Your Message')):not(.has-error))" + - ":has(.form-field:has(label:contains('Products')):not(.has-error))" + - ":has(.form-field:has(label:contains('Service')):not(.has-error))" + - ":has(.form-field:has(label:contains('State')):not(.has-error))" + - ":has(.form-field:has(label:contains('Invoice Scan')):not(.has-error))" - } - ] - }); - - Tour.register({ - id: 'website_form_editor_tour_results', - name: "Check records have been created", - path: '/', - mode: 'test', - steps: [ - { - title: "Check mail.mail records have been created", - waitFor: ".o-apps", - onload: function (tour) { - var mailDef = new Model("mail.mail").call( - "search_read", - [ - // TODO: add other fields in domain ! - [ - ['email_to', '=', 'test@test.test'], - ['body_html', 'like', 'A useless message'], - ['body_html', 'like', 'Service : Development Service'], - ['body_html', 'like', 'State : Belgium'], - ['body_html', 'like', 'Products : Xperia,Wiko Stairway'] - ], - [] - ] - ); - var success = function(model, data) { - if(data.length) { - $('body').append('
'); - } - }; - mailDef.then(_.bind(success, this, 'mail_mail')); - } - }, - { - title: "Check mail.mail records have been created", - waitFor: "#website_form_editor_success_test_tour_mail_mail" - }, - { - title: "Final Step", - waitFor: "html" - } - ] - }); - }); + }; + mailDef.then(_.bind(success, this, 'mail_mail')); + } + }, + { + content: "Check mail.mail records have been created", + trigger: "#website_form_editor_success_test_tour_mail_mail" + } + ]); return {}; }); diff --git a/tests/test_website_form_editor.py b/tests/test_website_form_editor.py index a15147158ed..ea78099a7f5 100644 --- a/tests/test_website_form_editor.py +++ b/tests/test_website_form_editor.py @@ -8,6 +8,6 @@ import odoo.tests @odoo.tests.common.post_install(True) class TestWebsiteFormEditor(odoo.tests.HttpCase): def test_tour(self): - self.phantom_js("/", "odoo.__DEBUG__.services['web.Tour'].run('website_form_editor_tour', 'test')", "odoo.__DEBUG__.services['web.Tour'].tours.website_form_editor_tour", login="admin") - self.phantom_js("/", "odoo.__DEBUG__.services['web.Tour'].run('website_form_editor_tour_submit', 'test')", "odoo.__DEBUG__.services['web.Tour'].tours.website_form_editor_tour_submit") - self.phantom_js("/", "odoo.__DEBUG__.services['web.Tour'].run('website_form_editor_tour_results', 'test')", "odoo.__DEBUG__.services['web.Tour'].tours.website_form_editor_tour_results", login="admin") + self.phantom_js("/", "odoo.__DEBUG__.services['web_tour.tour'].run('website_form_editor_tour')", "odoo.__DEBUG__.services['web_tour.tour'].tours.website_form_editor_tour.ready", login="admin") + self.phantom_js("/", "odoo.__DEBUG__.services['web_tour.tour'].run('website_form_editor_tour_submit')", "odoo.__DEBUG__.services['web_tour.tour'].tours.website_form_editor_tour_submit.ready") + self.phantom_js("/", "odoo.__DEBUG__.services['web_tour.tour'].run('website_form_editor_tour_results')", "odoo.__DEBUG__.services['web_tour.tour'].tours.website_form_editor_tour_results.ready", login="admin")