From cd82c87159109acdb15a4670feb87e6e36819e32 Mon Sep 17 00:00:00 2001 From: "Louis (loco)" Date: Fri, 26 May 2023 15:09:48 +0000 Subject: [PATCH] [FIX] website: enable to use addCustomField function with more types The goal of this commit is to be able to use the `addCustomField` function with a `type` argument that is different of `checkbox`, `radio` or `select`. opw-3246341 X-original-commit: 34b3770ad1ee9c872acaf4f82ac3c6cf52d5d333 Part-of: odoo/odoo#122782 --- .../website/static/tests/tours/website_form_editor.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/website/static/tests/tours/website_form_editor.js b/addons/website/static/tests/tours/website_form_editor.js index 42c90183620..51d218389b6 100644 --- a/addons/website/static/tests/tours/website_form_editor.js +++ b/addons/website/static/tests/tours/website_form_editor.js @@ -46,7 +46,9 @@ trigger: `we-select we-button[${data}]`, }]; }; - const addField = function (data, name, type, label, required, display = {visibility: VISIBLE, condition: ''}) { + const addField = function (name, type, label, required, isCustom, + display = {visibility: VISIBLE, condition: ""}) { + const data = isCustom ? `data-custom-field="${name}"` : `data-existing-field="${name}"`; const ret = [{ content: "Select form", extra_trigger: 'iframe .s_website_form_field', @@ -88,7 +90,8 @@ } if (type !== 'checkbox' && type !== 'radio' && type !== 'select') { let inputType = type === 'textarea' ? type : `input[type="${type}"]`; - testText += `:has(${inputType}[name="${name}"]${required ? '[required]' : ''})`; + const nameAttribute = isCustom && label ? label : name; + testText += `:has(${inputType}[name="${nameAttribute}"]${required ? "[required]" : ""})`; } ret.push({ content: "Check the resulting field", @@ -98,10 +101,10 @@ return ret; }; const addCustomField = function (name, type, label, required, display) { - return addField(`data-custom-field="${name}"`, name, type, label, required, display); + return addField(name, type, label, required, true, display); }; const addExistingField = function (name, type, label, required, display) { - return addField(`data-existing-field="${name}"`, name, type, label, required, display); + return addField(name, type, label, required, false, display); }; wTourUtils.registerWebsitePreviewTour("website_form_editor_tour", {