From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- .../static/tests/import_buttons_tests.js | 170 +++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 addons/base_import/static/tests/import_buttons_tests.js (limited to 'addons/base_import/static/tests') diff --git a/addons/base_import/static/tests/import_buttons_tests.js b/addons/base_import/static/tests/import_buttons_tests.js new file mode 100644 index 00000000..e561d021 --- /dev/null +++ b/addons/base_import/static/tests/import_buttons_tests.js @@ -0,0 +1,170 @@ +odoo.define('web.base_import_tests', function (require) { +"use strict"; + +const KanbanView = require('web.KanbanView'); +const ListView = require('web.ListView'); +const PivotView = require('web.PivotView'); +const testUtils = require('web.test_utils'); + +const createView = testUtils.createView; + +QUnit.module('Base Import Tests', { + beforeEach: function () { + this.data = { + foo: { + fields: { + foo: {string: "Foo", type: "char"}, + }, + records: [ + {id: 1, foo: "yop"}, + ] + }, + }; + } +}); + +QUnit.test('import in favorite dropdown in list', async function (assert) { + assert.expect(2); + + const list = await createView({ + View: ListView, + model: 'foo', + data: this.data, + arch: '', + }); + + testUtils.mock.intercept(list, 'do_action', function () { + assert.ok(true, "should have triggered a do_action"); + }); + + await testUtils.dom.click(list.$('.o_favorite_menu button')); + assert.containsOnce(list, '.o_import_menu'); + + await testUtils.dom.click(list.$('.o_import_menu button')); + + list.destroy(); +}); + +QUnit.test('import favorite dropdown item should not in list with create="0"', async function (assert) { + assert.expect(1); + + const list = await createView({ + View: ListView, + model: 'foo', + data: this.data, + arch: '', + }); + + await testUtils.dom.click(list.$('.o_favorite_menu button')); + assert.containsNone(list, '.o_import_menu'); + + list.destroy(); +}); + +QUnit.test('import favorite dropdown item should not in list with import="0"', async function (assert) { + assert.expect(1); + + const list = await createView({ + View: ListView, + model: 'foo', + data: this.data, + arch: '', + }); + + await testUtils.dom.click(list.$('.o_favorite_menu button')); + assert.containsNone(list, '.o_import_menu'); + + list.destroy(); +}); + +QUnit.test('import in favorite dropdown in kanban', async function (assert) { + assert.expect(2); + + const kanban = await createView({ + View: KanbanView, + model: 'foo', + data: this.data, + arch: ` + + +
+
+
+
`, + }); + + testUtils.mock.intercept(kanban, 'do_action', function () { + assert.ok(true, "should have triggered a do_action"); + }); + + await testUtils.dom.click(kanban.$('.o_favorite_menu button')); + assert.containsOnce(kanban, '.o_import_menu'); + + await testUtils.dom.click(kanban.$('.o_import_menu button')); + + kanban.destroy(); +}); + +QUnit.test('import favorite dropdown item should not in list with create="0"', async function (assert) { + assert.expect(1); + + const kanban = await createView({ + View: KanbanView, + model: 'foo', + data: this.data, + arch: ` + + +
+
+
+
`, + }); + + await testUtils.dom.click(kanban.$('.o_favorite_menu button')); + assert.containsNone(kanban, '.o_import_menu'); + + kanban.destroy(); +}); + +QUnit.test('import dropdown favorite should not in kanban with import="0"', async function (assert) { + assert.expect(1); + + const kanban = await createView({ + View: KanbanView, + model: 'foo', + data: this.data, + arch: ` + + +
+
+
+
`, + }); + + await testUtils.dom.click(kanban.$('.o_favorite_menu button')); + assert.containsNone(kanban, '.o_import_menu'); + + kanban.destroy(); +}); + +QUnit.test('import should not available in favorite dropdown in pivot (other than kanban or list)', async function (assert) { + assert.expect(1); + + this.data.foo.fields.foobar = { string: "Fubar", type: "integer", group_operator: 'sum' }; + + const pivot = await createView({ + View: PivotView, + model: 'foo', + data: this.data, + arch: '', + }); + + await testUtils.dom.click(pivot.$('.o_favorite_menu button')); + assert.containsNone(pivot, '.o_import_menu'); + + pivot.destroy(); +}); + +}); -- cgit v1.2.3