summaryrefslogtreecommitdiff
path: root/addons/point_of_sale/static/tests/unit/test_ChromeWidgets.js
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/point_of_sale/static/tests/unit/test_ChromeWidgets.js
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/point_of_sale/static/tests/unit/test_ChromeWidgets.js')
-rw-r--r--addons/point_of_sale/static/tests/unit/test_ChromeWidgets.js89
1 files changed, 89 insertions, 0 deletions
diff --git a/addons/point_of_sale/static/tests/unit/test_ChromeWidgets.js b/addons/point_of_sale/static/tests/unit/test_ChromeWidgets.js
new file mode 100644
index 00000000..a0df97fd
--- /dev/null
+++ b/addons/point_of_sale/static/tests/unit/test_ChromeWidgets.js
@@ -0,0 +1,89 @@
+odoo.define('point_of_sale.tests.ChromeWidgets', function (require) {
+ 'use strict';
+
+ const PosComponent = require('point_of_sale.PosComponent');
+ const PopupControllerMixin = require('point_of_sale.PopupControllerMixin');
+ const testUtils = require('web.test_utils');
+ const makePosTestEnv = require('point_of_sale.test_env');
+ const { xml } = owl.tags;
+
+ QUnit.module('unit tests for Chrome Widgets', {});
+
+ QUnit.test('CashierName', async function (assert) {
+ assert.expect(1);
+
+ class Parent extends PosComponent {}
+ Parent.env = makePosTestEnv();
+ Parent.template = xml/* html */ `
+ <div><CashierName></CashierName></div>
+ `;
+ Parent.env.pos.employee.name = 'Test Employee';
+
+ const parent = new Parent();
+ await parent.mount(testUtils.prepareTarget());
+
+ assert.strictEqual(parent.el.querySelector('span.username').innerText, 'Test Employee');
+
+ parent.unmount();
+ parent.destroy();
+ });
+
+ QUnit.test('HeaderButton', async function (assert) {
+ assert.expect(1);
+
+ class Parent extends PosComponent {}
+ Parent.env = makePosTestEnv();
+ Parent.template = xml/* html */ `
+ <div><HeaderButton></HeaderButton></div>
+ `;
+
+ const parent = new Parent();
+ await parent.mount(testUtils.prepareTarget());
+
+ const headerButton = parent.el.querySelector('.header-button');
+ await testUtils.dom.click(headerButton);
+ await testUtils.nextTick();
+ assert.ok(headerButton.classList.contains('confirm'));
+
+ parent.unmount();
+ parent.destroy();
+ });
+
+ QUnit.test('SyncNotification', async function (assert) {
+ assert.expect(5);
+
+ class Parent extends PosComponent {}
+ Parent.env = makePosTestEnv();
+ Parent.template = xml/* html */ `
+ <div>
+ <SyncNotification></SyncNotification>
+ </div>
+ `;
+
+ const pos = Parent.env.pos;
+ pos.set('synch', { status: 'connected', pending: false });
+
+ const parent = new Parent();
+ await parent.mount(testUtils.prepareTarget());
+ assert.ok(parent.el.querySelector('i.fa').parentElement.classList.contains('js_connected'));
+
+ pos.set('synch', { status: 'connecting', pending: false });
+ await testUtils.nextTick();
+ assert.ok(parent.el.querySelector('i.fa').parentElement.classList.contains('js_connecting'));
+
+ pos.set('synch', { status: 'disconnected', pending: false });
+ await testUtils.nextTick();
+ assert.ok(parent.el.querySelector('i.fa').parentElement.classList.contains('js_disconnected'));
+
+ pos.set('synch', { status: 'error', pending: false });
+ await testUtils.nextTick();
+ assert.ok(parent.el.querySelector('i.fa').parentElement.classList.contains('js_error'));
+
+ pos.set('synch', { status: 'error', pending: 10 });
+ await testUtils.nextTick();
+ assert.ok(parent.el.querySelector('.js_msg').innerText.includes('10'));
+
+ parent.unmount();
+ parent.destroy();
+ });
+});