mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-21 19:12:01 +02:00
Initial commit: Core packages
This commit is contained in:
commit
12c29a983b
9512 changed files with 8379910 additions and 0 deletions
|
|
@ -0,0 +1,89 @@
|
|||
/** @odoo-module */
|
||||
|
||||
import { click, getFixture } from "@web/../tests/helpers/utils";
|
||||
import { makeView, setupViewRegistries } from "@web/../tests/views/helpers";
|
||||
|
||||
QUnit.module("DescriptionPageField", (hooks) => {
|
||||
let serverData;
|
||||
let target;
|
||||
|
||||
hooks.beforeEach(() => {
|
||||
target = getFixture();
|
||||
|
||||
serverData = {
|
||||
models: {
|
||||
partner: {
|
||||
fields: { lines: { type: "one2many", relation: "lines_sections" } },
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
lines: [1, 2],
|
||||
},
|
||||
],
|
||||
},
|
||||
lines_sections: {
|
||||
fields: {
|
||||
is_page: { type: "boolean" },
|
||||
title: { type: "char", string: "Title" },
|
||||
random_questions_count: { type: "number", string: "Question Count" },
|
||||
},
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
is_page: true,
|
||||
title: "firstSectionTitle",
|
||||
random_questions_count: 4,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
is_page: false,
|
||||
title: "recordTitle",
|
||||
random_questions_count: 5,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
views: {
|
||||
"lines_sections,false,form": `
|
||||
<form>
|
||||
<field name="title" />
|
||||
</form>
|
||||
`,
|
||||
},
|
||||
};
|
||||
|
||||
setupViewRegistries();
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"button is visible in the edited record and allows to open that record",
|
||||
async (assert) => {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 1,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="lines" widget="question_page_one2many">
|
||||
<tree>
|
||||
<field name="is_page" invisible="1" />
|
||||
<field name="title" widget="survey_description_page"/>
|
||||
<field name="random_questions_count" />
|
||||
</tree>
|
||||
</field>
|
||||
</form>
|
||||
`,
|
||||
});
|
||||
assert.containsN(target, "td.o_survey_description_page_cell", 2);
|
||||
assert.containsNone(target, "button.o_icon_button");
|
||||
|
||||
await click(target.querySelector(".o_data_cell"));
|
||||
assert.containsOnce(target.querySelector(".o_data_row"), "button.o_icon_button");
|
||||
assert.containsNone(target, ".modal .o_form_view");
|
||||
|
||||
await click(target, "button.o_icon_button");
|
||||
assert.containsOnce(target, ".modal .o_form_view");
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
@ -0,0 +1,207 @@
|
|||
/** @odoo-module */
|
||||
|
||||
import { click, getFixture } from "@web/../tests/helpers/utils";
|
||||
import { makeView, setupViewRegistries } from "@web/../tests/views/helpers";
|
||||
|
||||
QUnit.module("QuestionPageListRenderer", (hooks) => {
|
||||
let serverData;
|
||||
let target;
|
||||
|
||||
hooks.beforeEach(() => {
|
||||
target = getFixture();
|
||||
|
||||
serverData = {
|
||||
models: {
|
||||
partner: {
|
||||
fields: { lines: { type: "one2many", relation: "lines_sections" } },
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
lines: [1, 2],
|
||||
},
|
||||
],
|
||||
},
|
||||
lines_sections: {
|
||||
fields: {
|
||||
sequence: { type: "number" },
|
||||
is_page: { type: "boolean" },
|
||||
title: { type: "char", string: "Title" },
|
||||
question_type: { type: "string" },
|
||||
random_questions_count: { type: "number", string: "Question Count" },
|
||||
},
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
sequence: 1,
|
||||
is_page: true,
|
||||
question_type: false,
|
||||
title: "firstSectionTitle",
|
||||
random_questions_count: 4,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
sequence: 2,
|
||||
is_page: false,
|
||||
question_type: 'simple_choice',
|
||||
title: "recordTitle",
|
||||
random_questions_count: 5,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
views: {
|
||||
"lines_sections,false,form": `
|
||||
<form>
|
||||
<field name="title" />
|
||||
</form>
|
||||
`,
|
||||
},
|
||||
};
|
||||
|
||||
setupViewRegistries();
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"normal list view",
|
||||
async (assert) => {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 1,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="lines" widget="question_page_one2many">
|
||||
<tree>
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="title" widget="survey_description_page"/>
|
||||
<field name="question_type" />
|
||||
<field name="is_page" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</form>
|
||||
`,
|
||||
});
|
||||
assert.containsN(target, "td.o_survey_description_page_cell", 2); // Check if we have the two rows in the list
|
||||
|
||||
assert.containsOnce(target, "tr.o_is_section"); // Check if we have only one section row
|
||||
const section = target.querySelector("tr.o_is_section > td.o_survey_description_page_cell");
|
||||
assert.strictEqual(section.colSpan, 2, 'The section should have a colspan of 1');
|
||||
|
||||
await click(section);
|
||||
assert.containsOnce(section, 'div.input-group');
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"list view with random count",
|
||||
async (assert) => {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 1,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="lines" widget="question_page_one2many">
|
||||
<tree>
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="title" widget="survey_description_page"/>
|
||||
<field name="question_type" />
|
||||
<field name="is_page" invisible="1"/>
|
||||
<field name="random_questions_count"/>
|
||||
</tree>
|
||||
</field>
|
||||
</form>
|
||||
`,
|
||||
});
|
||||
assert.containsN(target, "td.o_survey_description_page_cell", 2); // Check if we have the two rows in the list
|
||||
|
||||
assert.containsOnce(target, "tr.o_is_section"); // Check if we have only one section row
|
||||
const section = target.querySelector("tr.o_is_section > td.o_survey_description_page_cell");
|
||||
assert.strictEqual(section.colSpan, 2, 'The section should have a colspan of 2');
|
||||
|
||||
// We can edit the section title
|
||||
await click(section);
|
||||
assert.containsOnce(section, 'div.input-group');
|
||||
|
||||
//We can edit the number of random questions selected
|
||||
const numberQuestions = target.querySelector("tr.o_is_section > [name='random_questions_count']");
|
||||
await click(numberQuestions);
|
||||
assert.containsOnce(numberQuestions, 'div');
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"list view with random but with question_type at the left of the title",
|
||||
async (assert) => {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 1,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="lines" widget="question_page_one2many">
|
||||
<tree>
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="question_type" />
|
||||
<field name="title" widget="survey_description_page"/>
|
||||
<field name="is_page" invisible="1"/>
|
||||
<field name="random_questions_count"/>
|
||||
</tree>
|
||||
</field>
|
||||
</form>
|
||||
`,
|
||||
});
|
||||
assert.containsN(target, "td.o_survey_description_page_cell", 2); // Check if we have the two rows in the list
|
||||
|
||||
assert.containsOnce(target, "tr.o_is_section"); // Check if we have only one section row
|
||||
const section = target.querySelector("tr.o_is_section > td.o_survey_description_page_cell");
|
||||
assert.strictEqual(section.colSpan, 1, 'The section should have a colspan of 1');
|
||||
|
||||
await click(section);
|
||||
assert.containsOnce(section, 'div.input-group');
|
||||
|
||||
const numberQuestions = target.querySelector("tr.o_is_section > [name='random_questions_count']");
|
||||
await click(numberQuestions);
|
||||
assert.containsOnce(numberQuestions, 'div');
|
||||
}
|
||||
);
|
||||
QUnit.test(
|
||||
"list view with random and question_type at the beginning of row",
|
||||
async (assert) => {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 1,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="lines" widget="question_page_one2many">
|
||||
<tree>
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="random_questions_count"/>
|
||||
<field name="question_type" />
|
||||
<field name="title" widget="survey_description_page"/>
|
||||
<field name="is_page" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</form>
|
||||
`,
|
||||
});
|
||||
assert.containsN(target, "td.o_survey_description_page_cell", 2); // Check if we have the two rows in the list
|
||||
|
||||
assert.containsOnce(target, "tr.o_is_section"); // Check if we have only one section row
|
||||
const section = target.querySelector("tr.o_is_section > td.o_survey_description_page_cell");
|
||||
assert.strictEqual(section.colSpan, 1, 'The section should have a colspan of 1');
|
||||
|
||||
await click(section);
|
||||
assert.containsOnce(section, 'div.input-group');
|
||||
|
||||
const numberQuestions = target.querySelector("tr.o_is_section > [name='random_questions_count']");
|
||||
await click(numberQuestions);
|
||||
assert.containsOnce(numberQuestions, 'div');
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
@ -0,0 +1,247 @@
|
|||
/** @odoo-module */
|
||||
|
||||
import { click, editInput, getFixture, nextTick, triggerHotkey } from "@web/../tests/helpers/utils";
|
||||
import { makeView, setupViewRegistries } from "@web/../tests/views/helpers";
|
||||
|
||||
QUnit.module("QuestionPageOneToManyField", (hooks) => {
|
||||
let serverData;
|
||||
let target;
|
||||
|
||||
hooks.beforeEach(() => {
|
||||
target = getFixture();
|
||||
|
||||
serverData = {
|
||||
models: {
|
||||
partner: {
|
||||
fields: { lines: { type: "one2many", relation: "lines_sections" } },
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
lines: [1, 2],
|
||||
},
|
||||
],
|
||||
},
|
||||
lines_sections: {
|
||||
fields: {
|
||||
is_page: { type: "boolean" },
|
||||
title: { type: "char", string: "Title" },
|
||||
random_questions_count: { type: "number", string: "Question Count" },
|
||||
},
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
is_page: true,
|
||||
title: "firstSectionTitle",
|
||||
random_questions_count: 4,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
is_page: false,
|
||||
title: "recordTitle",
|
||||
random_questions_count: 5,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
views: {
|
||||
"lines_sections,false,form": `
|
||||
<form>
|
||||
<field name="title" />
|
||||
</form>
|
||||
`,
|
||||
},
|
||||
};
|
||||
|
||||
setupViewRegistries();
|
||||
});
|
||||
|
||||
QUnit.test("basic rendering", async (assert) => {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 1,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="lines" widget="question_page_one2many">
|
||||
<tree>
|
||||
<field name="is_page" invisible="1" />
|
||||
<field name="title" />
|
||||
<field name="random_questions_count" />
|
||||
</tree>
|
||||
</field>
|
||||
</form>
|
||||
`,
|
||||
});
|
||||
assert.containsOnce(target, ".o_field_x2many .o_list_renderer table.o_section_list_view");
|
||||
assert.containsN(target, ".o_data_row", 2);
|
||||
const rows = target.querySelectorAll(".o_data_row");
|
||||
assert.hasClass(rows[0], "o_is_section");
|
||||
assert.hasClass(rows[0], "fw-bold");
|
||||
assert.strictEqual(rows[0].textContent, "firstSectionTitle4");
|
||||
assert.strictEqual(rows[1].textContent, "recordTitle5");
|
||||
assert.strictEqual(rows[0].querySelector("td[name=title]").getAttribute("colspan"), "1");
|
||||
assert.strictEqual(rows[1].querySelector("td[name=title]").getAttribute("colspan"), null);
|
||||
});
|
||||
|
||||
QUnit.test("click on section behaves as usual in readonly mode", async (assert) => {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 1,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="lines" widget="question_page_one2many">
|
||||
<tree>
|
||||
<field name="is_page" invisible="1" />
|
||||
<field name="title" />
|
||||
<field name="random_questions_count" />
|
||||
</tree>
|
||||
</field>
|
||||
</form>
|
||||
`,
|
||||
mode: "readonly",
|
||||
});
|
||||
|
||||
await click(target.querySelector(".o_data_cell"));
|
||||
assert.containsNone(target, ".o_selected_row");
|
||||
assert.containsOnce(target, ".modal .o_form_view");
|
||||
});
|
||||
|
||||
QUnit.test("click on section edit the section in place", async (assert) => {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 1,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="lines" widget="question_page_one2many">
|
||||
<tree>
|
||||
<field name="is_page" invisible="1" />
|
||||
<field name="title" />
|
||||
<field name="random_questions_count" />
|
||||
</tree>
|
||||
</field>
|
||||
</form>`,
|
||||
});
|
||||
await click(target.querySelector(".o_data_cell"));
|
||||
assert.hasClass(target.querySelector(".o_is_section"), "o_selected_row");
|
||||
assert.containsNone(target, ".modal .o_form_view");
|
||||
});
|
||||
|
||||
QUnit.test("click on real line opens a dialog", async (assert) => {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 1,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="lines" widget="question_page_one2many">
|
||||
<tree>
|
||||
<field name="is_page" invisible="1" />
|
||||
<field name="title" />
|
||||
<field name="random_questions_count" />
|
||||
</tree>
|
||||
</field>
|
||||
</form>
|
||||
`,
|
||||
});
|
||||
await click(target.querySelector(".o_data_row:nth-child(2) .o_data_cell"));
|
||||
assert.containsNone(target, ".o_selected_row");
|
||||
assert.containsOnce(target, ".modal .o_form_view");
|
||||
});
|
||||
|
||||
QUnit.test("can create section inline", async (assert) => {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 1,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="lines" widget="question_page_one2many">
|
||||
<tree>
|
||||
<field name="is_page" invisible="1" />
|
||||
<field name="title" />
|
||||
<field name="random_questions_count" />
|
||||
<control>
|
||||
<create string="add line" />
|
||||
<create string="add section" context="{'default_is_page': true}" />
|
||||
</control>
|
||||
</tree>
|
||||
</field>
|
||||
</form>
|
||||
`,
|
||||
});
|
||||
|
||||
assert.containsNone(target, ".o_selected_row");
|
||||
|
||||
await click(target.querySelectorAll(".o_field_x2many_list_row_add a")[1]);
|
||||
assert.containsOnce(target, ".o_selected_row.o_is_section");
|
||||
assert.containsNone(target, ".modal .o_form_view");
|
||||
});
|
||||
|
||||
QUnit.test("creates real record in form dialog", async (assert) => {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 1,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="lines" widget="question_page_one2many">
|
||||
<tree>
|
||||
<field name="is_page" invisible="1" />
|
||||
<field name="title" />
|
||||
<field name="random_questions_count" />
|
||||
<control>
|
||||
<create string="add line" />
|
||||
<create string="add section" context="{'default_is_page': true}" />
|
||||
</control>
|
||||
</tree>
|
||||
</field>
|
||||
</form>
|
||||
`,
|
||||
});
|
||||
|
||||
await click(target.querySelector(".o_field_x2many_list_row_add a"));
|
||||
assert.containsNone(target, ".o_selected_row");
|
||||
assert.containsOnce(target, ".modal .o_form_view");
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"press enter with focus in a edited section pass the section in readonly mode",
|
||||
async (assert) => {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 1,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="lines" widget="question_page_one2many">
|
||||
<tree>
|
||||
<field name="is_page" invisible="1" />
|
||||
<field name="title" />
|
||||
<field name="random_questions_count" />
|
||||
</tree>
|
||||
</field>
|
||||
</form>
|
||||
`,
|
||||
});
|
||||
await click(target.querySelector(".o_data_row .o_data_cell"));
|
||||
assert.containsOnce(target, ".o_selected_row.o_is_section");
|
||||
|
||||
await editInput(target, "[name='title'] input", "a");
|
||||
|
||||
triggerHotkey("Enter");
|
||||
await nextTick();
|
||||
|
||||
assert.containsNone(target, ".o_selected_row.o_is_section");
|
||||
assert.strictEqual(target.querySelector(".o_is_section [name=title]").innerText, "a");
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
odoo.define('survey.tour_test_certification_failure', function (require) {
|
||||
'use strict';
|
||||
|
||||
var SurveyFormWidget = require('survey.form');
|
||||
/**
|
||||
* Speed up fade-in fade-out to avoid useless delay in tests.
|
||||
*/
|
||||
SurveyFormWidget.include({
|
||||
_submitForm: function () {
|
||||
this.fadeInOutDelay = 0;
|
||||
return this._super.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* This tour will test that, for the demo certification allowing 2 attempts, a user can
|
||||
* try and fail twice and will no longer be able to take the certification.
|
||||
*/
|
||||
|
||||
var tour = require('web_tour.tour');
|
||||
|
||||
var failSteps = [{ // Page-1
|
||||
content: "Clicking on Start Certification",
|
||||
trigger: 'button.btn.btn-primary.btn-lg:contains("Start Certification")',
|
||||
}, { // Question: Do we sell Acoustic Bloc Screens?
|
||||
content: "Selecting answer 'No'",
|
||||
trigger: 'div.js_question-wrapper:contains("Do we sell Acoustic Bloc Screens") label:contains("No")',
|
||||
}, { // Question: Select all the existing products
|
||||
content: "Ticking answer 'Fanta'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the existing products") label:contains("Fanta")'
|
||||
}, {
|
||||
content: "Ticking answer 'Drawer'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the existing products") label:contains("Drawer")'
|
||||
}, {
|
||||
content: "Ticking answer 'Conference chair'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the existing products") label:contains("Conference chair")'
|
||||
}, { // Question: Select all the available customizations for our Customizable Desk
|
||||
content: "Ticking answer 'Color'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the available customizations for our Customizable Desk") label:contains("Color")'
|
||||
}, {
|
||||
content: "Ticking answer 'Height'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the available customizations for our Customizable Desk") label:contains("Height")'
|
||||
}, { // Question: How many versions of the Corner Desk do we have?
|
||||
content: "Selecting answer '2'",
|
||||
trigger: 'div.js_question-wrapper:contains("How many versions of the Corner Desk do we have") label:contains("2")',
|
||||
}, { // Question: Do you think we have missing products in our catalog? (not rated)
|
||||
content: "Missing products",
|
||||
trigger: 'div.js_question-wrapper:contains("Do you think we have missing products in our catalog") textarea',
|
||||
run: "text I don't know products enough to be able to answer that",
|
||||
}, { // Page-2 Question: How much do we sell our Cable Management Box?
|
||||
content: "Selecting answer '$80'",
|
||||
trigger: 'div.js_question-wrapper:contains("How much do we sell our Cable Management Box") label:contains("$80")',
|
||||
}, { // Question: Select all the products that sell for $100 or more
|
||||
content: "Ticking answer 'Corner Desk Right Sit'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the products that sell for $100 or more") label:contains("Corner Desk Right Sit")'
|
||||
}, {
|
||||
content: "Ticking answer 'Desk Combination'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the products that sell for $100 or more") label:contains("Desk Combination")'
|
||||
}, {
|
||||
content: "Ticking answer 'Office Chair Black'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the products that sell for $100 or more") label:contains("Office Chair Black")'
|
||||
}, { // Question: What do you think about our prices (not rated)?
|
||||
trigger: 'div.js_question-wrapper:contains("What do you think about our prices") label:contains("Correctly priced")',
|
||||
}, { // Page-3 Question: How many days is our money-back guarantee?
|
||||
content: "Inputting answer '60'",
|
||||
trigger: 'div.js_question-wrapper:contains("How many days is our money-back guarantee") input',
|
||||
run: 'text 60'
|
||||
}, { // Question: If a customer purchases a product on 6 January 2020, what is the latest day we expect to ship it?
|
||||
content: "Inputting answer '01/06/2020'",
|
||||
trigger: 'div.js_question-wrapper:contains("If a customer purchases a product on 6 January 2020, what is the latest day we expect to ship it") input',
|
||||
run: 'text 01/06/2020'
|
||||
}, { // Question: If a customer purchases a 1 year warranty on 6 January 2020, when do we expect the warranty to expire?
|
||||
content: "Inputting answer '01/06/2021 00:00:01'",
|
||||
trigger: 'div.js_question-wrapper:contains("If a customer purchases a 1 year warranty on 6 January 2020, when do we expect the warranty to expire") input',
|
||||
run: 'text 01/06/2021 00:00:01'
|
||||
}, { // Question: What day to you think is best for us to start having an annual sale (not rated)?
|
||||
trigger: 'div.js_question-wrapper:contains("What day to you think is best for us to start having an annual sale (not rated)") input',
|
||||
}, { // Question: What day and time do you think most customers are most likely to call customer service (not rated)?
|
||||
trigger: 'div.js_question-wrapper:contains("What day and time do you think most customers are most likely to call customer service (not rated)") input',
|
||||
}, { // Question: How many chairs do you think we should aim to sell in a year (not rated)?
|
||||
content: "Inputting answer '0'",
|
||||
trigger: 'div.js_question-wrapper:contains("How many chairs do you think we should aim to sell in a year (not rated)") input',
|
||||
run: 'text 0'
|
||||
}, {
|
||||
content: "Finish Survey",
|
||||
trigger: 'button[type="submit"]',
|
||||
}];
|
||||
|
||||
var retrySteps = [{
|
||||
trigger: 'a:contains("Retry")'
|
||||
}];
|
||||
|
||||
var lastSteps = [{
|
||||
trigger: 'h1:contains("Thank you!")',
|
||||
run: function () {
|
||||
if ($('a:contains("Retry")').length === 0) {
|
||||
$('h1:contains("Thank you!")').addClass('tour_success');
|
||||
}
|
||||
}
|
||||
}, {
|
||||
trigger: 'h1.tour_success',
|
||||
}];
|
||||
|
||||
tour.register('test_certification_failure', {
|
||||
test: true,
|
||||
url: '/survey/start/4ead4bc8-b8f2-4760-a682-1fde8daaaaac'
|
||||
}, [].concat(failSteps, retrySteps, failSteps, lastSteps));
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
odoo.define('survey.tour_test_certification_success', function (require) {
|
||||
'use strict';
|
||||
|
||||
var SurveyFormWidget = require('survey.form');
|
||||
/**
|
||||
* Speed up fade-in fade-out to avoid useless delay in tests.
|
||||
*/
|
||||
SurveyFormWidget.include({
|
||||
_submitForm: function () {
|
||||
this.fadeInOutDelay = 0;
|
||||
return this._super.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
|
||||
var tour = require('web_tour.tour');
|
||||
|
||||
tour.register('test_certification_success', {
|
||||
test: true,
|
||||
url: '/survey/start/4ead4bc8-b8f2-4760-a682-1fde8daaaaac'
|
||||
},
|
||||
[{ // Page-1
|
||||
content: "Clicking on Start Certification",
|
||||
trigger: 'button.btn.btn-primary.btn-lg:contains("Start Certification")',
|
||||
}, { // Question: Do we sell Acoustic Bloc Screens?
|
||||
content: "Selecting answer 'Yes'",
|
||||
trigger: 'div.js_question-wrapper:contains("Do we sell Acoustic Bloc Screens") label:contains("Yes")',
|
||||
}, { // Question: Select all the existing products
|
||||
content: "Ticking answer 'Chair floor protection'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the existing products") label:contains("Chair floor protection")'
|
||||
}, {
|
||||
content: "Ticking answer 'Drawer'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the existing products") label:contains("Drawer")'
|
||||
}, {
|
||||
content: "Ticking answer 'Conference chair'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the existing products") label:contains("Conference chair")'
|
||||
}, { // Question: Select all the available customizations for our Customizable Desk
|
||||
content: "Ticking answer 'Color'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the available customizations for our Customizable Desk") label:contains("Color")'
|
||||
}, {
|
||||
content: "Ticking answer 'Legs'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the available customizations for our Customizable Desk") label:contains("Legs")'
|
||||
}, { // Question: How many versions of the Corner Desk do we have?
|
||||
content: "Selecting answer '2'",
|
||||
trigger: 'div.js_question-wrapper:contains("How many versions of the Corner Desk do we have") label:contains("2")',
|
||||
}, { // Question: Do you think we have missing products in our catalog? (not rated)
|
||||
content: "Missing products",
|
||||
trigger: 'div.js_question-wrapper:contains("Do you think we have missing products in our catalog") textarea',
|
||||
run: "text I think we should make more versions of the customizable desk, it's such an amazing product!",
|
||||
}, { // Page-2 Question: How much do we sell our Cable Management Box?
|
||||
content: "Selecting answer '$80' (wrong one)",
|
||||
trigger: 'div.js_question-wrapper:contains("How much do we sell our Cable Management Box") label:contains("$80")',
|
||||
}, { // Question: Select all the products that sell for $100 or more
|
||||
content: "Ticking answer 'Corner Desk Right Sit'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the products that sell for $100 or more") label:contains("Corner Desk Right Sit")'
|
||||
}, {
|
||||
content: "Ticking answer 'Desk Combination'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the products that sell for $100 or more") label:contains("Desk Combination")'
|
||||
}, {
|
||||
content: "Ticking answer 'Large Desk'",
|
||||
trigger: 'div.js_question-wrapper:contains("Select all the products that sell for $100 or more") label:contains("Large Desk")'
|
||||
}, { // Question: What do you think about our prices (not rated)?
|
||||
content: "Selecting answer 'Underpriced'",
|
||||
trigger: 'div.js_question-wrapper:contains("What do you think about our prices") label:contains("Underpriced")',
|
||||
}, { // Page-3 Question: How many days is our money-back guarantee?
|
||||
content: "Inputting answer '30'",
|
||||
trigger: 'div.js_question-wrapper:contains("How many days is our money-back guarantee") input',
|
||||
run: 'text 30'
|
||||
}, { // Question: If a customer purchases a product on 6 January 2020, what is the latest day we expect to ship it?
|
||||
content: "Inputting answer '01/08/2020'",
|
||||
trigger: 'div.js_question-wrapper:contains("If a customer purchases a product on 6 January 2020, what is the latest day we expect to ship it") input',
|
||||
run: 'text 01/08/2020'
|
||||
}, { // Question: If a customer purchases a 1 year warranty on 6 January 2020, when do we expect the warranty to expire?
|
||||
content: "Inputting answer '01/07/2021 00:00:01'",
|
||||
trigger: 'div.js_question-wrapper:contains("If a customer purchases a 1 year warranty on 6 January 2020, when do we expect the warranty to expire") input',
|
||||
run: 'text 01/07/2021 00:00:01'
|
||||
}, { // Question: What day to you think is best for us to start having an annual sale (not rated)?
|
||||
content: "Inputting answer '01/01/2021'",
|
||||
trigger: 'div.js_question-wrapper:contains("What day to you think is best for us to start having an annual sale (not rated)") input',
|
||||
run: 'text 01/01/2021'
|
||||
}, { // Question: What day and time do you think most customers are most likely to call customer service (not rated)?
|
||||
content: "Inputting answer '01/01/2021 13:00:01'",
|
||||
trigger: 'div.js_question-wrapper:contains("What day and time do you think most customers are most likely to call customer service (not rated)") input',
|
||||
run: 'text 01/01/2021 13:00:01'
|
||||
}, { // Question: How many chairs do you think we should aim to sell in a year (not rated)?
|
||||
content: "Inputting answer '1000'",
|
||||
trigger: 'div.js_question-wrapper:contains("How many chairs do you think we should aim to sell in a year (not rated)") input',
|
||||
run: 'text 1000'
|
||||
}, {
|
||||
content: "Finish Survey",
|
||||
trigger: 'button[type="submit"]',
|
||||
}, {
|
||||
content: "Thank you",
|
||||
trigger: 'h1:contains("Thank you!")',
|
||||
}, {
|
||||
content: "test passed",
|
||||
trigger: 'div:contains("Congratulations, you have passed the test!")',
|
||||
}
|
||||
]);
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
odoo.define('survey.tour_test_survey', function (require) {
|
||||
'use strict';
|
||||
|
||||
var tour = require('web_tour.tour');
|
||||
|
||||
tour.register('test_survey', {
|
||||
test: true,
|
||||
url: '/survey/start/b137640d-14d4-4748-9ef6-344caaaaaae',
|
||||
}, [
|
||||
// Page-1
|
||||
{
|
||||
content: 'Click on Start',
|
||||
trigger: 'button.btn:contains("Start")',
|
||||
}, {
|
||||
content: 'Answer Where do you live',
|
||||
trigger: 'div.js_question-wrapper:contains("Where do you live") input',
|
||||
run: 'text Mordor-les-bains',
|
||||
}, {
|
||||
content: 'Answer Where do you live',
|
||||
trigger: 'div.js_question-wrapper:contains("When is your date of birth") input',
|
||||
run: 'text 05/05/1980',
|
||||
}, {
|
||||
content: 'Answer How frequently do you buy products online',
|
||||
trigger: 'div.js_question-wrapper:contains("How frequently do you buy products online") label:contains("Once a month")',
|
||||
}, {
|
||||
content: 'Answer How many times did you order products on our website',
|
||||
trigger: 'div.js_question-wrapper:contains("How many times did you order products on our website") input',
|
||||
run: 'text 12',
|
||||
}, {
|
||||
content: 'Submit and go to Next Page',
|
||||
trigger: 'button[value="next"]',
|
||||
},
|
||||
// Page-2
|
||||
{
|
||||
content: 'Answer Which of the following words would you use to describe our products (High Quality)',
|
||||
trigger: 'div.js_question-wrapper:contains("Which of the following words would you use to describe our products") label:contains("High quality")',
|
||||
}, {
|
||||
content: 'Answer Which of the following words would you use to describe our products (Good value for money)',
|
||||
trigger: 'div.js_question-wrapper:contains("Which of the following words would you use to describe our products") label:contains("Good value for money")',
|
||||
}, {
|
||||
content: 'Answer What do your think about our new eCommerce (The new layout and design is fresh and up-to-date)',
|
||||
trigger: 'div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("The new layout and design is fresh and up-to-date") td:first',
|
||||
}, {
|
||||
content: 'Answer What do your think about our new eCommerce (It is easy to find the product that I want)',
|
||||
trigger: 'div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("It is easy to find the product that I want") td:eq(2)',
|
||||
}, {
|
||||
content: 'Answer What do your think about our new eCommerce (The tool to compare the products is useful to make a choice)',
|
||||
trigger: 'div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("The tool to compare the products is useful to make a choice") td:eq(3)',
|
||||
}, {
|
||||
content: 'Answer What do your think about our new eCommerce (The checkout process is clear and secure)',
|
||||
trigger: 'div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("The checkout process is clear and secure") td:eq(2)',
|
||||
}, {
|
||||
content: 'Answer What do your think about our new eCommerce (I have added products to my wishlist)',
|
||||
trigger: 'div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("I have added products to my wishlist") td:last',
|
||||
}, {
|
||||
content: 'Answer Do you have any other comments, questions, or concerns',
|
||||
trigger: 'div.js_question-wrapper:contains("Do you have any other comments, questions, or concerns") textarea',
|
||||
run: 'text This is great. Really.',
|
||||
}, {
|
||||
content: 'Click Submit and finish the survey',
|
||||
trigger: 'button[value="finish"]',
|
||||
},
|
||||
// Final page
|
||||
{
|
||||
content: 'Thank you',
|
||||
trigger: 'h1:contains("Thank you!")',
|
||||
}
|
||||
]);
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
odoo.define('survey.tour_test_survey_chained_conditional_questions', function (require) {
|
||||
'use strict';
|
||||
|
||||
const tour = require('web_tour.tour');
|
||||
|
||||
tour.register('test_survey_chained_conditional_questions', {
|
||||
test: true,
|
||||
url: '/survey/start/3cfadce3-3f7e-41da-920d-10fa0eb19527',
|
||||
}, [
|
||||
{
|
||||
content: 'Click on Start',
|
||||
trigger: 'button.btn:contains("Start")',
|
||||
}, {
|
||||
content: 'Answer Q1 with Answer 2',
|
||||
trigger: 'div.js_question-wrapper:contains("Q1") label:contains("Answer 2")',
|
||||
}, {
|
||||
content: 'Check that Q4 and Q5 are visible',
|
||||
trigger: 'div.js_question-wrapper:contains(Q4)',
|
||||
extra_trigger: 'div.js_question-wrapper:contains(Q5)',
|
||||
run: () => {
|
||||
const selector = 'div.js_question-wrapper.d-none';
|
||||
if (document.querySelectorAll(selector).length !== 2) {
|
||||
throw new Error('Q2 and Q3 should be hidden.');
|
||||
}
|
||||
},
|
||||
}, {
|
||||
content: 'Answer Q1 with Answer 1',
|
||||
trigger: 'div.js_question-wrapper:contains("Q1") label:contains("Answer 1")',
|
||||
}, {
|
||||
content: 'Answer Q2 with Answer 1',
|
||||
trigger: 'div.js_question-wrapper:contains("Q2") label:contains("Answer 1")',
|
||||
run: function (actions) {
|
||||
const selector = 'div.js_question-wrapper.d-none';
|
||||
if (document.querySelectorAll(selector).length !== 3) {
|
||||
throw new Error('Q3, Q4 and Q5 should be hidden.');
|
||||
}
|
||||
// Select Answer 1, in order to trigger the display of Q3.
|
||||
actions.click(this.$anchor);
|
||||
}
|
||||
}, {
|
||||
content: 'Answer Q3 with Answer 1',
|
||||
trigger: 'div.js_question-wrapper:contains("Q3") label:contains("Answer 1")',
|
||||
}, {
|
||||
content: 'Answer Q1 with Answer 3', // This should hide all remaining questions.
|
||||
trigger: 'div.js_question-wrapper:contains("Q1") label:contains("Answer 3")',
|
||||
}, {
|
||||
content: 'Check that only question 1 is now visible',
|
||||
trigger: 'div.js_question-wrapper:contains("Q1")',
|
||||
run: () => {
|
||||
const selector = 'div.js_question-wrapper.d-none';
|
||||
if (document.querySelectorAll(selector).length !== 4) {
|
||||
throw new Error('Q2, Q3, Q4 and Q5 should have been hidden.');
|
||||
}
|
||||
}
|
||||
}, {
|
||||
content: 'Click Submit and finish the survey',
|
||||
trigger: 'button[value="finish"]',
|
||||
},
|
||||
// Final page
|
||||
{
|
||||
content: 'Thank you',
|
||||
trigger: 'h1:contains("Thank you!")',
|
||||
}
|
||||
|
||||
]);
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
odoo.define('survey.tour_test_survey_prefill', function (require) {
|
||||
'use strict';
|
||||
|
||||
var tour = require('web_tour.tour');
|
||||
|
||||
tour.register('test_survey_prefill', {
|
||||
test: true,
|
||||
url: '/survey/start/b137640d-14d4-4748-9ef6-344caaaaaae'
|
||||
},
|
||||
[{ // Page-1
|
||||
trigger: 'button.btn.btn-primary.btn-lg:contains("Start Survey")',
|
||||
}, { // Question: Where do you live ?
|
||||
trigger: 'div.js_question-wrapper:contains("Where do you live ?") input',
|
||||
run: 'text Grand-Rosiere',
|
||||
}, { // Question: When is your date of birth ?
|
||||
trigger: 'div.js_question-wrapper:contains("When is your date of birth ?") input',
|
||||
run: 'text 05/05/1980',
|
||||
}, { // Question: How frequently do you buy products online ?
|
||||
trigger: 'div.js_question-wrapper:contains("How frequently do you buy products online ?") label:contains("Once a week")',
|
||||
}, { // Question: How many times did you order products on our website ?
|
||||
trigger: 'div.js_question-wrapper:contains("How many times did you order products on our website ?") input',
|
||||
run: 'text 42',
|
||||
}, {
|
||||
content: 'Click on Next Page',
|
||||
trigger: 'button[value="next"]',
|
||||
},
|
||||
// Page-2
|
||||
{ // Question: Which of the following words would you use to describe our products ?
|
||||
content: 'Answer Which of the following words would you use to describe our products (High Quality)',
|
||||
trigger: 'div.js_question-wrapper:contains("Which of the following words would you use to describe our products") label:contains("High quality")',
|
||||
}, {
|
||||
content: 'Answer Which of the following words would you use to describe our products (Good value for money)',
|
||||
trigger: 'div.js_question-wrapper:contains("Which of the following words would you use to describe our products") label:contains("Good value for money")',
|
||||
}, {
|
||||
content: 'Answer What do your think about our new eCommerce (The new layout and design is fresh and up-to-date)',
|
||||
trigger: 'div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("The new layout and design is fresh and up-to-date") td:first',
|
||||
}, {
|
||||
content: 'Answer What do your think about our new eCommerce (It is easy to find the product that I want)',
|
||||
trigger: 'div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("It is easy to find the product that I want") td:eq(2)',
|
||||
}, {
|
||||
content: 'Answer What do your think about our new eCommerce (The tool to compare the products is useful to make a choice)',
|
||||
trigger: 'div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("The tool to compare the products is useful to make a choice") td:eq(3)',
|
||||
}, {
|
||||
content: 'Answer What do your think about our new eCommerce (The checkout process is clear and secure)',
|
||||
trigger: 'div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("The checkout process is clear and secure") td:eq(2)',
|
||||
}, {
|
||||
content: 'Answer What do your think about our new eCommerce (I have added products to my wishlist)',
|
||||
trigger: 'div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("I have added products to my wishlist") td:last',
|
||||
}, {
|
||||
content: 'Answer Do you have any other comments, questions, or concerns',
|
||||
trigger: 'div.js_question-wrapper:contains("Do you have any other comments, questions, or concerns") textarea',
|
||||
run: 'text Is the prefill working?',
|
||||
}, {
|
||||
// Go back to previous page
|
||||
content: 'Click on the previous page name in the breadcrumb',
|
||||
trigger: 'ol.breadcrumb a:first',
|
||||
}, {
|
||||
trigger: 'div.js_question-wrapper:contains("How many times did you order products on our website ?") input',
|
||||
run: function () {
|
||||
var $inputQ3 = $('div.js_question-wrapper:contains("How many times did you order products on our website ?") input');
|
||||
if ($inputQ3.val() === '42.0') {
|
||||
$('.o_survey_title').addClass('prefilled');
|
||||
}
|
||||
}
|
||||
}, {
|
||||
trigger: '.o_survey_title.prefilled',
|
||||
run: function () {
|
||||
// check that all the answers are prefilled in Page 1
|
||||
var $inputQ1 = $('div.js_question-wrapper:contains("Where do you live ?") input');
|
||||
if ($inputQ1.val() !== 'Grand-Rosiere') {
|
||||
return;
|
||||
}
|
||||
|
||||
var $inputQ2 = $('div.js_question-wrapper:contains("When is your date of birth ?") input');
|
||||
if ($inputQ2.val() !== '05/05/1980') {
|
||||
return;
|
||||
}
|
||||
|
||||
var $inputQ3 = $('div.js_question-wrapper:contains("How frequently do you buy products online ?") label:contains("Once a week") input');
|
||||
if (!$inputQ3.is(':checked')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $inputQ4 = $('div.js_question-wrapper:contains("How many times did you order products on our website ?") input');
|
||||
if ($inputQ4.val() !== '42.0') {
|
||||
return;
|
||||
}
|
||||
|
||||
$('.o_survey_title').addClass('tour_success');
|
||||
}
|
||||
}, {
|
||||
trigger: '.o_survey_title.tour_success'
|
||||
}, {
|
||||
content: 'Click on Next Page',
|
||||
trigger: 'button[value="next"]',
|
||||
}, {
|
||||
trigger: 'div.js_question-wrapper:contains("Do you have any other comments, questions, or concerns") textarea',
|
||||
run: function () {
|
||||
var $inputQ3 = $('div.js_question-wrapper:contains("Do you have any other comments, questions, or concerns") textarea');
|
||||
if ($inputQ3.val() === "Is the prefill working?") {
|
||||
$('.o_survey_title').addClass('prefilled2');
|
||||
}
|
||||
}
|
||||
}, {
|
||||
trigger: '.o_survey_title.prefilled2',
|
||||
run: function () {
|
||||
// check that all the answers are prefilled in Page 2
|
||||
var $input1Q1 = $('div.js_question-wrapper:contains("Which of the following words would you use to describe our products") label:contains("High quality") input');
|
||||
if (!$input1Q1.is(':checked')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $input2Q1 = $('div.js_question-wrapper:contains("Which of the following words would you use to describe our products") label:contains("Good value for money") input');
|
||||
if (!$input2Q1.is(':checked')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $input1Q2 = $('div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("The new layout and design is fresh and up-to-date") input:first');
|
||||
if (!$input1Q2.is(':checked')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $input2Q2 = $('div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("It is easy to find the product that I want") input:eq(2)');
|
||||
if (!$input2Q2.is(':checked')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $input3Q2 = $('div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("The tool to compare the products is useful to make a choice") input:eq(3)');
|
||||
if (!$input3Q2.is(':checked')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $input4Q2 = $('div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("The checkout process is clear and secure") input:eq(2)');
|
||||
if (!$input4Q2.is(':checked')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $input5Q2 = $('div.js_question-wrapper:contains("What do your think about our new eCommerce") tr:contains("I have added products to my wishlist") input:last');
|
||||
if (!$input5Q2.is(':checked')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $inputQ3 = $('div.js_question-wrapper:contains("Do you have any other comments, questions, or concerns") textarea');
|
||||
if ($inputQ3.val() !== "Is the prefill working?") {
|
||||
return;
|
||||
}
|
||||
|
||||
$('.o_survey_title').addClass('tour_success_2');
|
||||
}
|
||||
}, {
|
||||
trigger: '.o_survey_title.tour_success_2'
|
||||
}
|
||||
]);
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue