summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views
diff options
context:
space:
mode:
authorMohammed Shekha <msh@odoo.com>2020-04-07 12:32:43 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2020-08-20 12:37:36 +0000
commitce69db55f80777b95015c23dc4b3fa1a6db5daad (patch)
tree66675d808acc37302397eb6b28df6bed20c50479 /addons/web/static/tests/views
parent538b7f22cfdd39ce3dea66b36b46ced2de7ceaed (diff)
[IMP] web: set focus to first visible page when active page invisible
Before this commit: if there are modifiers based on field which hides one page and show another and if active page get invisible then instead of first page second page gets focus, consider following example, `<form> <field name="boolean"/> <page name="page1" attrs='{"invisible": [["bar", "=", false]]}'></page> <page name="page2" attrs='{"invisible": [["bar", "=", true]]}'></page> <page name="page3"></page> </form>` Consider the initial boolean value to be true; initially the first page will be visible. But when "bar" is unchecked then page1 will be hidden and page3 will get the focus as page2 is still not visible: it will be after the computaion/application of all modifiers, which is currently done after the rendering of a tab page. Now: the first visible tab is focused on rendering (same as before) but also after all modifiers have been updated. closes odoo/odoo#56209 X-original-commit: 10365572aa3629e9b19d2b29726b351275de9f52 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com> Co-authored-by: Ipsita Borisagar <ibo@odoo.com> Co-authored-by: Julien Mougenot <jum@odoo.com>
Diffstat (limited to 'addons/web/static/tests/views')
-rw-r--r--addons/web/static/tests/views/form_tests.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js
index 0dd958b6e17..8bbdae1e91f 100644
--- a/addons/web/static/tests/views/form_tests.js
+++ b/addons/web/static/tests/views/form_tests.js
@@ -785,6 +785,57 @@ QUnit.module('Views', {
form.destroy();
});
+ QUnit.test('notebook: pages with invisible modifiers', async function (assert) {
+ assert.expect(10);
+
+ const form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: `<form string="Partners">
+ <sheet>
+ <field name="bar"/>
+ <notebook>
+ <page string="First" attrs='{"invisible": [["bar", "=", false]]}'>
+ <field name="foo"/>
+ </page>
+ <page string="Second" attrs='{"invisible": [["bar", "=", true]]}'>
+ <field name="int_field"/>
+ </page>
+ <page string="Third">
+ <field name="qux"/>
+ </page>
+ </notebook>
+ </sheet>
+ </form>`,
+ res_id: 1,
+ });
+
+ await testUtils.form.clickEdit(form);
+
+ assert.containsOnce(form, ".o_notebook .nav .nav-link.active",
+ "There should be only one active tab"
+ );
+ assert.isVisible(form.$(".o_notebook .nav .nav-item:first"));
+ assert.hasClass(form.$(".o_notebook .nav .nav-link:first"), "active");
+
+ assert.isNotVisible(form.$(".o_notebook .nav .nav-item:eq(1)"));
+ assert.doesNotHaveClass(form.$(".o_notebook .nav .nav-link:eq(1)"), "active");
+
+ await testUtils.dom.click(form.$(".o_field_widget[name=bar] input"));
+
+ assert.containsOnce(form, ".o_notebook .nav .nav-link.active",
+ "There should be only one active tab"
+ );
+ assert.isNotVisible(form.$(".o_notebook .nav .nav-item:first"));
+ assert.doesNotHaveClass(form.$(".o_notebook .nav .nav-link:first"), "active");
+
+ assert.isVisible(form.$(".o_notebook .nav .nav-item:eq(1)"));
+ assert.hasClass(form.$(".o_notebook .nav .nav-link:eq(1)"), "active");
+
+ form.destroy();
+ });
+
QUnit.test('invisible attrs on first notebook page', async function (assert) {
assert.expect(6);