summaryrefslogtreecommitdiff
path: root/addons/base_import/static/tests
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/base_import/static/tests
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/base_import/static/tests')
-rw-r--r--addons/base_import/static/tests/import_buttons_tests.js170
1 files changed, 170 insertions, 0 deletions
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: '<tree><field name="foo"/></tree>',
+ });
+
+ 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: '<tree create="0"><field name="foo"/></tree>',
+ });
+
+ 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: '<tree import="0"><field name="foo"/></tree>',
+ });
+
+ 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: `<kanban>
+ <templates>
+ <t t-name="kanban-box">
+ <div><field name="foo"/></div>
+ </t>
+ </templates>
+ </kanban>`,
+ });
+
+ 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: `<kanban create="0">
+ <templates>
+ <t t-name="kanban-box">
+ <div><field name="foo"/></div>
+ </t>
+ </templates>
+ </kanban>`,
+ });
+
+ 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: `<kanban import="0">
+ <templates>
+ <t t-name="kanban-box">
+ <div><field name="foo"/></div>
+ </t>
+ </templates>
+ </kanban>`,
+ });
+
+ 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: '<pivot><field name="foobar" type="measure"/></pivot>',
+ });
+
+ await testUtils.dom.click(pivot.$('.o_favorite_menu button'));
+ assert.containsNone(pivot, '.o_import_menu');
+
+ pivot.destroy();
+});
+
+});