diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/pos_hr/static/tests | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/pos_hr/static/tests')
| -rw-r--r-- | addons/pos_hr/static/tests/tours/PosHrTour.js | 83 | ||||
| -rw-r--r-- | addons/pos_hr/static/tests/tours/PosHrTourMethods.js | 67 |
2 files changed, 150 insertions, 0 deletions
diff --git a/addons/pos_hr/static/tests/tours/PosHrTour.js b/addons/pos_hr/static/tests/tours/PosHrTour.js new file mode 100644 index 00000000..99f5057a --- /dev/null +++ b/addons/pos_hr/static/tests/tours/PosHrTour.js @@ -0,0 +1,83 @@ +odoo.define('point_of_sale.tour.PosHr', function (require) { + 'use strict'; + + const { PosHr } = require('pos_hr.tour.PosHrTourMethods'); + const { ProductScreen } = require('point_of_sale.tour.ProductScreenTourMethods'); + const { TicketScreen } = require('point_of_sale.tour.TicketScreenTourMethods'); + const { Chrome } = require('point_of_sale.tour.ChromeTourMethods'); + const { ErrorPopup } = require('point_of_sale.tour.ErrorPopupTourMethods'); + const { NumberPopup } = require('point_of_sale.tour.NumberPopupTourMethods'); + const { SelectionPopup } = require('point_of_sale.tour.SelectionPopupTourMethods'); + const { getSteps, startSteps } = require('point_of_sale.tour.utils'); + const Tour = require('web_tour.tour'); + + startSteps(); + + PosHr.check.loginScreenIsShown(); + PosHr.do.clickLoginButton(); + SelectionPopup.check.isShown(); + SelectionPopup.check.hasSelectionItem('Pos Employee1'); + SelectionPopup.check.hasSelectionItem('Pos Employee2'); + SelectionPopup.check.hasSelectionItem('Mitchell Admin'); + SelectionPopup.do.clickItem('Pos Employee1'); + NumberPopup.check.isShown(); + NumberPopup.do.pressNumpad('2 5'); + NumberPopup.check.inputShownIs('••'); + NumberPopup.do.pressNumpad('8 1'); + NumberPopup.check.inputShownIs('••••'); + NumberPopup.do.clickConfirm(); + ErrorPopup.check.isShown(); + ErrorPopup.do.clickConfirm(); + PosHr.do.clickLoginButton(); + SelectionPopup.do.clickItem('Pos Employee1'); + NumberPopup.check.isShown(); + NumberPopup.do.pressNumpad('2 5'); + NumberPopup.check.inputShownIs('••'); + NumberPopup.do.pressNumpad('8 0'); + NumberPopup.check.inputShownIs('••••'); + NumberPopup.do.clickConfirm(); + ProductScreen.check.isShown(); + PosHr.check.cashierNameIs('Pos Employee1'); + PosHr.do.clickCashierName(); + SelectionPopup.do.clickItem('Mitchell Admin'); + PosHr.check.cashierNameIs('Mitchell Admin'); + PosHr.do.clickLockButton(); + PosHr.do.clickLoginButton(); + SelectionPopup.do.clickItem('Pos Employee2'); + NumberPopup.do.pressNumpad('1 2'); + NumberPopup.check.inputShownIs('••'); + NumberPopup.do.pressNumpad('3 4'); + NumberPopup.check.inputShownIs('••••'); + NumberPopup.do.clickConfirm(); + ProductScreen.check.isShown(); + ProductScreen.do.clickHomeCategory(); + + // Create orders and check if the ticket list has the right employee for each order + // order for employee 2 + ProductScreen.exec.addOrderline('Desk Pad', '1', '2'); + ProductScreen.check.totalAmountIs('2.0') + Chrome.do.clickTicketButton(); + TicketScreen.check.nthRowContains(2, 'Pos Employee2'); + + // order for employee 1 + PosHr.do.clickLockButton(); + PosHr.exec.login('Pos Employee1', '2580'); + TicketScreen.do.clickNewTicket(); + ProductScreen.exec.addOrderline('Desk Pad', '1', '4'); + ProductScreen.check.totalAmountIs('4.0') + Chrome.do.clickTicketButton(); + TicketScreen.check.nthRowContains(2, 'Pos Employee2'); + TicketScreen.check.nthRowContains(3, 'Pos Employee1'); + + // order for admin + PosHr.do.clickCashierName(); + SelectionPopup.do.clickItem('Mitchell Admin'); + PosHr.check.cashierNameIs('Mitchell Admin'); + TicketScreen.do.clickNewTicket(); + ProductScreen.exec.addOrderline('Desk Pad', '1', '8'); + ProductScreen.check.totalAmountIs('8.0') + Chrome.do.clickTicketButton(); + TicketScreen.check.nthRowContains(4, 'Mitchell Admin'); + + Tour.register('PosHrTour', { test: true, url: '/pos/ui' }, getSteps()); +}); diff --git a/addons/pos_hr/static/tests/tours/PosHrTourMethods.js b/addons/pos_hr/static/tests/tours/PosHrTourMethods.js new file mode 100644 index 00000000..2ad6c1aa --- /dev/null +++ b/addons/pos_hr/static/tests/tours/PosHrTourMethods.js @@ -0,0 +1,67 @@ +odoo.define('pos_hr.tour.PosHrTourMethods', function (require) { + 'use strict'; + + const { createTourMethods } = require('point_of_sale.tour.utils'); + const { SelectionPopup } = require('point_of_sale.tour.SelectionPopupTourMethods'); + const { NumberPopup } = require('point_of_sale.tour.NumberPopupTourMethods'); + + class Do { + clickLoginButton() { + return [ + { + content: 'click login button', + trigger: '.login-overlay .login-button.select-employee', + }, + ]; + } + clickLockButton() { + return [ + { + content: 'click lock button', + trigger: '.header-button .lock-button', + }, + ]; + } + clickCashierName() { + return [ + { + content: 'click cashier name', + trigger: '.oe_status .username', + } + ] + } + } + class Check { + loginScreenIsShown() { + return [ + { + content: 'login screen is shown', + trigger: '.login-overlay .screen-login .login-body', + run: () => {}, + }, + ]; + } + cashierNameIs(name) { + return [ + { + content: `logged cashier is '${name}'`, + trigger: `.pos .oe_status .username:contains("${name}")`, + run: () => {}, + }, + ]; + } + } + class Execute { + login(name, pin) { + const res = this._do.clickLoginButton(); + res.push(...SelectionPopup._do.clickItem(name)); + if (pin) { + res.push(...NumberPopup._do.pressNumpad(pin.split('').join(' '))); + res.push(...NumberPopup._do.clickConfirm()); + } + return res; + } + } + + return createTourMethods('PosHr', Do, Check, Execute); +}); |
