mirror of
https://github.com/bringout/oca-ocb-pos.git
synced 2026-04-23 20:21:59 +02:00
19.0 vanilla
This commit is contained in:
parent
6e54c1af6c
commit
3ca647e428
1087 changed files with 132065 additions and 108499 deletions
|
|
@ -1,84 +0,0 @@
|
|||
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();
|
||||
ProductScreen.do.confirmOpeningPopup();
|
||||
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());
|
||||
});
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
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-cashier',
|
||||
},
|
||||
];
|
||||
}
|
||||
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);
|
||||
});
|
||||
|
|
@ -0,0 +1,406 @@
|
|||
import * as PosHr from "@pos_hr/../tests/tours/utils/pos_hr_helpers";
|
||||
import * as ProductScreen from "@point_of_sale/../tests/pos/tours/utils/product_screen_util";
|
||||
import * as TicketScreen from "@point_of_sale/../tests/pos/tours/utils/ticket_screen_util";
|
||||
import * as ReceiptScreen from "@point_of_sale/../tests/pos/tours/utils/receipt_screen_util";
|
||||
import * as PaymentScreen from "@point_of_sale/../tests/pos/tours/utils/payment_screen_util";
|
||||
import * as Chrome from "@point_of_sale/../tests/pos/tours/utils/chrome_util";
|
||||
import * as NumberPopup from "@point_of_sale/../tests/generic_helpers/number_popup_util";
|
||||
import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util";
|
||||
import * as SelectionPopup from "@point_of_sale/../tests/generic_helpers/selection_popup_util";
|
||||
import * as BackendUtils from "@point_of_sale/../tests/pos/tours/utils/backend_utils";
|
||||
import * as Utils from "@point_of_sale/../tests/generic_helpers/utils";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { negate, scan_barcode } from "@point_of_sale/../tests/generic_helpers/utils";
|
||||
|
||||
registry.category("web_tour.tours").add("PosHrTour", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Pos Employee1"),
|
||||
SelectionPopup.has("Pos Employee2"),
|
||||
SelectionPopup.has("Mitchell Admin"),
|
||||
SelectionPopup.has("Pos Employee1", { run: "click" }),
|
||||
NumberPopup.enterValue("25"),
|
||||
NumberPopup.isShown("••"),
|
||||
{
|
||||
trigger: "body",
|
||||
run: () => {
|
||||
window.dispatchEvent(new KeyboardEvent("keyup", { key: "8" }));
|
||||
},
|
||||
},
|
||||
NumberPopup.isShown("•••"),
|
||||
NumberPopup.enterValue("1"),
|
||||
NumberPopup.isShown("••••"),
|
||||
Dialog.confirm(),
|
||||
// after trying to close the number popup, the error popup should be shown
|
||||
// successfully confirming the dialog would imply that the error popup is actually shown
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Pos Employee1", { run: "click" }),
|
||||
|
||||
NumberPopup.enterValue("25"),
|
||||
NumberPopup.isShown("••"),
|
||||
NumberPopup.enterValue("80"),
|
||||
NumberPopup.isShown("••••"),
|
||||
Dialog.confirm(),
|
||||
Dialog.confirm("Open Register"),
|
||||
ProductScreen.isShown(),
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Pos Employee2", { run: "click" }),
|
||||
NumberPopup.enterValue("12"),
|
||||
NumberPopup.isShown("••"),
|
||||
NumberPopup.enterValue("34"),
|
||||
NumberPopup.isShown("••••"),
|
||||
Dialog.confirm(),
|
||||
ProductScreen.isShown(),
|
||||
|
||||
// Create orders and check if the ticket list has the right employee for each order
|
||||
// order for employee 2
|
||||
ProductScreen.addOrderline("Desk Pad", "1"),
|
||||
ProductScreen.totalAmountIs("1.98"),
|
||||
Chrome.clickOrders(),
|
||||
TicketScreen.nthRowContains(1, "Pos Employee2", false),
|
||||
|
||||
// order for employee 1
|
||||
PosHr.clickLockButton(),
|
||||
Chrome.clickBtn("Unlock Register"),
|
||||
PosHr.login("Pos Employee1", "2580"),
|
||||
Chrome.createFloatingOrder(),
|
||||
ProductScreen.addOrderline("Desk Pad", "1"),
|
||||
ProductScreen.totalAmountIs("1.98"),
|
||||
Chrome.clickOrders(),
|
||||
TicketScreen.nthRowContains(1, "Pos Employee2", false),
|
||||
TicketScreen.nthRowContains(2, "Pos Employee1", false),
|
||||
|
||||
// Cash in/out should be accessible for all users.
|
||||
Chrome.clickMenuOption("Cash In/Out"),
|
||||
Dialog.discard(),
|
||||
|
||||
// order for admin
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Chrome.createFloatingOrder(),
|
||||
ProductScreen.addOrderline("Desk Pad", "1", "8"),
|
||||
ProductScreen.totalAmountIs("8.0"),
|
||||
Chrome.clickOrders(),
|
||||
TicketScreen.nthRowContains(3, "Mitchell Admin", false),
|
||||
|
||||
// Close register should be accessible by the admin user.
|
||||
Chrome.clickMenuOption("Close Register"),
|
||||
Dialog.is("Closing Register"),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("CashierStayLogged", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Pos Employee1"),
|
||||
SelectionPopup.has("Pos Employee2"),
|
||||
SelectionPopup.has("Mitchell Admin"),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Dialog.confirm("Open Register"),
|
||||
PosHr.refreshPage(),
|
||||
ProductScreen.isShown(),
|
||||
Chrome.clickMenuButton(),
|
||||
PosHr.clickLockButton(),
|
||||
PosHr.refreshPage(),
|
||||
PosHr.loginScreenIsShown(),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("CashierCanSeeProductInfo", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Dialog.confirm("Open Register"),
|
||||
ProductScreen.clickInfoProduct("product_a", [Dialog.confirm("Close")]),
|
||||
Dialog.isNot(),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("CashierCannotClose", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Test Employee 3", { run: "click" }),
|
||||
Dialog.confirm("Open Register"),
|
||||
Chrome.clickMenuButton(),
|
||||
{
|
||||
trigger: negate(`span.dropdown-item:contains("Close Register")`),
|
||||
},
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Chrome.clickMenuButton(),
|
||||
{
|
||||
trigger: `span.dropdown-item:contains("Close Register")`,
|
||||
},
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("test_basic_user_can_change_price", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Test Employee 3", { run: "click" }),
|
||||
Dialog.confirm("Open Register"),
|
||||
ProductScreen.addOrderline("Desk Pad", "1", "10", "10"),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("test_change_on_rights_reflected_directly", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Dialog.confirm("Open Register"),
|
||||
Chrome.clickMenuOption("Backend", { expectUnloadPage: true }),
|
||||
BackendUtils.editShopConfiguration("Shop"),
|
||||
{
|
||||
trigger: ".o_tag:contains('Pos Employee1') .o_delete",
|
||||
run: "click",
|
||||
},
|
||||
BackendUtils.saveConfiguration(),
|
||||
{
|
||||
trigger: ".o_main_navbar .o-dropdown-item:contains('Dashboard')",
|
||||
run: "click",
|
||||
},
|
||||
{
|
||||
trigger: ".btn:contains('Continue Selling')",
|
||||
run: "click",
|
||||
expectUnloadPage: true,
|
||||
},
|
||||
Chrome.clickBtn("Unlock Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
Utils.negateStep(...SelectionPopup.has("Pos Employee1")),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("test_minimal_employee_refund", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Unlock Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Minimal Employee", { run: "click" }),
|
||||
Chrome.clickOrders(),
|
||||
TicketScreen.selectFilter("Paid"),
|
||||
TicketScreen.selectOrder("001"),
|
||||
{
|
||||
trigger: negate(".subpads"),
|
||||
},
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
TicketScreen.selectFilter("Paid"),
|
||||
TicketScreen.selectOrder("001"),
|
||||
{
|
||||
trigger: ".subpads",
|
||||
},
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("test_cashier_changed_in_receipt", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Dialog.confirm("Open Register"),
|
||||
ProductScreen.addOrderline("product_a", "1"),
|
||||
ProductScreen.clickPayButton(),
|
||||
PaymentScreen.clickPaymentMethod("Bank"),
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Employee 3", { run: "click" }),
|
||||
PaymentScreen.clickValidate(),
|
||||
ReceiptScreen.cashierNameExists("Test"), // Test Employee 3 (Take the first word)
|
||||
ReceiptScreen.clickNextOrder(),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("test_cost_and_margin_visibility", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Dialog.confirm("Open Register"),
|
||||
ProductScreen.clickInfoProduct("product_a"),
|
||||
{
|
||||
trigger: ".section-financials :contains('Margin')",
|
||||
},
|
||||
Dialog.confirm("Close"),
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Employee 3", { run: "click" }),
|
||||
ProductScreen.clickInfoProduct("product_a"),
|
||||
{
|
||||
trigger: ".section-financials :contains('Margin')",
|
||||
},
|
||||
Dialog.confirm("Close"),
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Employee 4", { run: "click" }),
|
||||
ProductScreen.clickInfoProduct("product_a"),
|
||||
Utils.negateStep({
|
||||
trigger: ".section-financials :contains('Margin')",
|
||||
}),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("pos_hr_go_backend_closed_registered", {
|
||||
steps: () =>
|
||||
[
|
||||
// Admin --> 403: not the one that opened the session
|
||||
Chrome.clickBtn("Backend"),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
PosHr.loginScreenIsShown(),
|
||||
|
||||
// Employee with user --> 403
|
||||
Chrome.clickBtn("Backend"),
|
||||
SelectionPopup.has("Pos Employee1", { run: "click" }),
|
||||
PosHr.enterPin("2580"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
|
||||
// Employee without user --> 403
|
||||
Chrome.clickBtn("Backend"),
|
||||
SelectionPopup.has("Test Employee 3", { run: "click" }),
|
||||
PosHr.loginScreenIsShown(),
|
||||
|
||||
// Manager without user --> 403
|
||||
Chrome.clickBtn("Backend"),
|
||||
SelectionPopup.has("Test Manager 2", { run: "click" }),
|
||||
PosHr.enterPin("5652"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
|
||||
// Manager that opened the session --> access granted
|
||||
Chrome.clickBtn("Backend"),
|
||||
SelectionPopup.has("Test Manager 1", { run: "click" }),
|
||||
PosHr.enterPin("5651").map((step, index, array) => {
|
||||
if (index === array.length - 1) {
|
||||
return {
|
||||
...step,
|
||||
expectUnloadPage: true,
|
||||
};
|
||||
}
|
||||
return step;
|
||||
}),
|
||||
PosHr.loginScreenIsNotShown().map((step) => ({ ...step, expectUnloadPage: true })),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("pos_hr_go_backend_opened_registered", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.clickLoginButton(),
|
||||
|
||||
// Admin --> 403: not the one that opened the session
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Chrome.clickBtn("Open Register"),
|
||||
Chrome.existMenuOption("Close Register"),
|
||||
Chrome.notExistMenuOption("Backend"),
|
||||
|
||||
// Employee with user --> 403
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Pos Employee1", { run: "click" }),
|
||||
PosHr.enterPin("2580"),
|
||||
Chrome.notExistMenuOption("Close Register"),
|
||||
Chrome.notExistMenuOption("Backend"),
|
||||
|
||||
// Employee without user --> 403
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Employee 3", { run: "click" }),
|
||||
Chrome.notExistMenuOption("Close Register"),
|
||||
Chrome.notExistMenuOption("Backend"),
|
||||
|
||||
// Manager without user --> 403
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Manager 2", { run: "click" }),
|
||||
PosHr.enterPin("5652"),
|
||||
Chrome.existMenuOption("Close Register"),
|
||||
Chrome.notExistMenuOption("Backend"),
|
||||
|
||||
// Manager that opened the session --> access granted
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Manager 1", { run: "click" }),
|
||||
PosHr.enterPin("5651"),
|
||||
Chrome.existMenuOption("Close Register"),
|
||||
Chrome.clickMenuOption("Backend", { expectUnloadPage: true }),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry
|
||||
.category("web_tour.tours")
|
||||
.add("pos_hr_go_backend_opened_registered_different_user_logged", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Unlock Register"),
|
||||
PosHr.clickLoginButton(),
|
||||
|
||||
// Employee, connected user
|
||||
SelectionPopup.has("Pos Employee1", { run: "click" }),
|
||||
PosHr.enterPin("2580"),
|
||||
Chrome.existMenuOption("Backend"),
|
||||
|
||||
// Manager that opened the session, not connected user
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Manager 1", { run: "click" }),
|
||||
PosHr.enterPin("5651"),
|
||||
Chrome.notExistMenuOption("Backend"),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("test_maximum_closing_difference", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
ProductScreen.enterOpeningAmount("10"),
|
||||
Chrome.clickBtn("Open Register"),
|
||||
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Manager 2", { run: "click" }),
|
||||
PosHr.enterPin("5652"),
|
||||
Chrome.clickMenuOption("Close Register"),
|
||||
Chrome.clickBtn("Close Register"),
|
||||
{
|
||||
trigger: negate(`button:contains("Proceed anyway")`),
|
||||
},
|
||||
Chrome.clickBtn("Ok"),
|
||||
Chrome.clickBtn("Discard"),
|
||||
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Chrome.clickMenuOption("Close Register"),
|
||||
Chrome.clickBtn("Close Register"),
|
||||
Chrome.hasBtn("Proceed anyway"),
|
||||
Chrome.clickBtn("Proceed anyway", { expectUnloadPage: true }),
|
||||
PosHr.loginScreenIsShown(),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("test_scan_employee_barcode_with_pos_hr_disabled", {
|
||||
steps: () =>
|
||||
[
|
||||
// scan a barcode with 041 as prefix for cashiers
|
||||
scan_barcode("041123"),
|
||||
Chrome.clickBtn("Open Register"),
|
||||
ProductScreen.isShown(),
|
||||
].flat(),
|
||||
});
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
import * as SelectionPopup from "@point_of_sale/../tests/generic_helpers/selection_popup_util";
|
||||
import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util";
|
||||
import * as NumberPopup from "@point_of_sale/../tests/generic_helpers/number_popup_util";
|
||||
import { negate } from "@point_of_sale/../tests/generic_helpers/utils";
|
||||
|
||||
export function clickLoginButton() {
|
||||
return [
|
||||
{
|
||||
content: "click login button",
|
||||
trigger: ".login-overlay .select-cashier",
|
||||
run: "click",
|
||||
},
|
||||
];
|
||||
}
|
||||
export function clickCashierName() {
|
||||
return [
|
||||
{
|
||||
content: "click cashier name",
|
||||
trigger: ".cashier-name",
|
||||
run: "click",
|
||||
},
|
||||
];
|
||||
}
|
||||
export function loginScreenIsShown() {
|
||||
return [
|
||||
{
|
||||
content: "login screen is shown",
|
||||
trigger: ".login-overlay .screen-login",
|
||||
},
|
||||
];
|
||||
}
|
||||
export function loginScreenIsNotShown() {
|
||||
return [
|
||||
{
|
||||
content: "login screen is not shown",
|
||||
trigger: negate(".login-overlay .screen-login"),
|
||||
},
|
||||
];
|
||||
}
|
||||
export function cashierNameIs(name) {
|
||||
return [
|
||||
{
|
||||
isActive: ["desktop"],
|
||||
content: `logged cashier is '${name}'`,
|
||||
trigger: `.pos .oe_status .username:contains("${name}")`,
|
||||
},
|
||||
{
|
||||
isActive: ["mobile"],
|
||||
content: `logged cashier is '${name}'`,
|
||||
trigger: `.pos .oe_status img[alt="${name}"]`,
|
||||
},
|
||||
];
|
||||
}
|
||||
export function login(name, pin) {
|
||||
const res = [...clickLoginButton(), ...SelectionPopup.has(name, { run: "click" })];
|
||||
if (!pin) {
|
||||
return res;
|
||||
}
|
||||
return res.concat(enterPin(pin));
|
||||
}
|
||||
export function enterPin(pin) {
|
||||
return [...NumberPopup.enterValue(pin), ...NumberPopup.isShown("••••"), Dialog.confirm()];
|
||||
}
|
||||
export function clickLockButton() {
|
||||
return {
|
||||
content: "Click on the menu button",
|
||||
trigger: ".pos-rightheader i.fa-unlock",
|
||||
run: "click",
|
||||
};
|
||||
}
|
||||
|
||||
export function refreshPage() {
|
||||
return [
|
||||
{
|
||||
trigger: ".pos",
|
||||
run: () => {
|
||||
window.location.reload();
|
||||
},
|
||||
expectUnloadPage: true,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import { test, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { CashierName } from "@point_of_sale/app/components/navbar/cashier_name/cashier_name";
|
||||
import { mountWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
|
||||
definePosModels();
|
||||
|
||||
test("avatarAndCssClass", async () => {
|
||||
await setupPosEnv();
|
||||
const comp = await mountWithCleanup(CashierName, {});
|
||||
expect(comp.avatar).toBe("/web/image/hr.employee.public/2/avatar_128");
|
||||
expect(comp.cssClass).toMatchObject({ oe_status: true });
|
||||
});
|
||||
test("selectCashier", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const comp = await mountWithCleanup(CashierName, {});
|
||||
const result = await comp.selectCashier();
|
||||
expect(result.name).toBe("Employee1");
|
||||
expect(result.id).toBe(3);
|
||||
store.setCashier(result);
|
||||
const value = store.getCashier();
|
||||
expect(value.name).toBe("Employee1");
|
||||
expect(value.id).toBe(3);
|
||||
});
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import { test, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { Navbar } from "@point_of_sale/app/components/navbar/navbar";
|
||||
import { mountWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
|
||||
definePosModels();
|
||||
|
||||
test("showCreateProductButtonWithAdmin", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const admin = store.models["hr.employee"].get(2);
|
||||
store.setCashier(admin);
|
||||
const comp = await mountWithCleanup(Navbar, {});
|
||||
expect(comp.showCreateProductButton).toBe(true);
|
||||
});
|
||||
|
||||
test("showCreateProductButtonWithNonAdmin", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const emp = store.models["hr.employee"].get(3);
|
||||
store.setCashier(emp);
|
||||
const comp = await mountWithCleanup(Navbar, {});
|
||||
expect(comp.showCreateProductButton).toBe(false);
|
||||
});
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
import { test, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { CashMovePopup } from "@point_of_sale/app/components/popups/cash_move_popup/cash_move_popup";
|
||||
import { mountWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
|
||||
definePosModels();
|
||||
|
||||
test("_prepareTryCashInOutPayload", async () => {
|
||||
await setupPosEnv();
|
||||
const comp = await mountWithCleanup(CashMovePopup, {
|
||||
props: { close: () => {} },
|
||||
});
|
||||
const result = comp._prepareTryCashInOutPayload();
|
||||
const employee_id = result[result.length - 1].employee_id;
|
||||
expect(employee_id).toBe(2);
|
||||
});
|
||||
test("partnerId", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const comp = await mountWithCleanup(CashMovePopup, {
|
||||
props: { close: () => {} },
|
||||
});
|
||||
const emp = store.models["hr.employee"].get(2);
|
||||
store.setCashier(emp);
|
||||
expect(comp.partnerId).toBe(emp.work_contact_id.id);
|
||||
});
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import { test, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { ProductInfoPopup } from "@point_of_sale/app/components/popups/product_info_popup/product_info_popup";
|
||||
import { mountWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
|
||||
definePosModels();
|
||||
|
||||
test("allowProductEdition", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.addNewOrder();
|
||||
const admin = store.models["hr.employee"].get(2);
|
||||
store.setCashier(admin);
|
||||
const product = store.models["product.template"].get(5);
|
||||
const info = await store.getProductInfo(product, 1);
|
||||
const comp = await mountWithCleanup(ProductInfoPopup, {
|
||||
props: {
|
||||
productTemplate: product,
|
||||
info,
|
||||
close: () => {},
|
||||
},
|
||||
});
|
||||
expect(comp.allowProductEdition).toBe(true);
|
||||
const emp = store.models["hr.employee"].get(3);
|
||||
store.setCashier(emp);
|
||||
expect(comp.allowProductEdition).toBe(false);
|
||||
});
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
import { test, expect, describe } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { LoginScreen } from "@point_of_sale/app/screens/login_screen/login_screen";
|
||||
import { mountWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
|
||||
definePosModels();
|
||||
|
||||
describe("pos_login_screen.js", () => {
|
||||
test("openRegister", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const comp = await mountWithCleanup(LoginScreen, {});
|
||||
comp.openRegister();
|
||||
expect(store.login).toBe(true);
|
||||
});
|
||||
test("backBtnName", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.login = true;
|
||||
const comp = await mountWithCleanup(LoginScreen, {});
|
||||
expect(comp.backBtnName).toBe("Discard");
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import { test, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen";
|
||||
import { mountWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
|
||||
definePosModels();
|
||||
|
||||
test("validateOrder", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.addNewOrder();
|
||||
const orderUuid = store.getOrder().uuid;
|
||||
const comp = await mountWithCleanup(PaymentScreen, {
|
||||
props: { orderUuid },
|
||||
});
|
||||
await comp.validateOrder();
|
||||
const order = store.getOrder();
|
||||
expect(order.employee_id.id).toBe(2);
|
||||
});
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
import { patch } from "@web/core/utils/patch";
|
||||
import { hootPosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
import { models } from "@web/../tests/web_test_helpers";
|
||||
|
||||
export class HrEmployee extends models.ServerModel {
|
||||
_name = "hr.employee";
|
||||
|
||||
_load_pos_data_fields() {
|
||||
return ["name", "user_id", "work_contact_id"];
|
||||
}
|
||||
|
||||
_records = [
|
||||
{
|
||||
id: 2,
|
||||
name: "Administrator",
|
||||
user_id: 2,
|
||||
work_contact_id: 3,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Employee1",
|
||||
user_id: 3,
|
||||
work_contact_id: 3,
|
||||
},
|
||||
];
|
||||
|
||||
_load_pos_data_read(records) {
|
||||
records.forEach((emp) => {
|
||||
if (emp.id === 2) {
|
||||
emp._role = "manager";
|
||||
} else {
|
||||
emp._role = "cashier";
|
||||
}
|
||||
});
|
||||
return records;
|
||||
}
|
||||
}
|
||||
patch(hootPosModels, [...hootPosModels, HrEmployee]);
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import { PosConfig } from "@point_of_sale/../tests/unit/data/pos_config.data";
|
||||
|
||||
PosConfig._records = PosConfig._records.map((record) => ({
|
||||
...record,
|
||||
module_pos_hr: true,
|
||||
}));
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import { patch } from "@web/core/utils/patch";
|
||||
import { PosOrder } from "@point_of_sale/app/models/pos_order";
|
||||
|
||||
patch(PosOrder.prototype, {
|
||||
_load_pos_data_fields() {
|
||||
return [...super._load_pos_data_fields(), "employee_id"];
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import { patch } from "@web/core/utils/patch";
|
||||
import { PosPayment } from "@point_of_sale/../tests/unit/data/pos_payment.data";
|
||||
|
||||
patch(PosPayment.prototype, {
|
||||
_load_pos_data_fields() {
|
||||
return [...super._load_pos_data_fields(), "employee_id"];
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import { patch } from "@web/core/utils/patch";
|
||||
import { PosSession } from "@point_of_sale/../tests/unit/data/pos_session.data";
|
||||
|
||||
patch(PosSession.prototype, {
|
||||
_load_pos_data_models() {
|
||||
return [...super._load_pos_data_models(), "hr.employee"];
|
||||
},
|
||||
_load_pos_data_fields() {
|
||||
return [...super._load_pos_data_fields(), "employee_id"];
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import { test, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
|
||||
definePosModels();
|
||||
|
||||
test("getCashierName", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.addNewOrder();
|
||||
const emp = store.models["hr.employee"].get(3);
|
||||
store.setCashier(emp);
|
||||
const posOrder = store.getOrder();
|
||||
expect(posOrder.getCashierName()).toBe("Employee1");
|
||||
});
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
import { test, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
import { patchWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
|
||||
definePosModels();
|
||||
|
||||
test("createNewOrder", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.addNewOrder();
|
||||
const order = store.getOrder();
|
||||
expect(order.employee_id.id).toBe(2);
|
||||
});
|
||||
test("employeeIsAdmin", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const emp = store.models["hr.employee"].get(2);
|
||||
store.setCashier(emp);
|
||||
expect(store.employeeIsAdmin).toBe(true);
|
||||
});
|
||||
test("_getConnectedCashier", async () => {
|
||||
const store = await setupPosEnv();
|
||||
expect(store._getConnectedCashier().id).toBe(2);
|
||||
});
|
||||
test("shouldShowOpeningControl", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const emp = store.models["hr.employee"].get(2);
|
||||
store.setCashier(emp);
|
||||
store.hasLoggedIn = true;
|
||||
expect(store.shouldShowOpeningControl()).toBe(true);
|
||||
});
|
||||
test("allowProductCreation", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const admin = store.models["hr.employee"].get(2);
|
||||
store.setCashier(admin);
|
||||
expect(await store.allowProductCreation()).toBe(true);
|
||||
const emp = store.models["hr.employee"].get(3);
|
||||
store.setCashier(emp);
|
||||
expect(await store.allowProductCreation()).toBe(false);
|
||||
});
|
||||
test("addLineToCurrentOrder", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.addNewOrder();
|
||||
const admin = store.models["hr.employee"].get(2);
|
||||
store.setCashier(admin);
|
||||
const product_id = store.models["product.product"].get(5);
|
||||
const result = await store.addLineToCurrentOrder({
|
||||
product_id: product_id,
|
||||
product_tmpl_id: product_id.product_tmpl_id,
|
||||
});
|
||||
expect(result.order_id.employee_id.id).toBe(2);
|
||||
});
|
||||
test("canEditPayment", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.addNewOrder();
|
||||
const order = store.getOrder();
|
||||
const admin = store.models["hr.employee"].get(2);
|
||||
store.setCashier(admin);
|
||||
expect(store.canEditPayment(order)).toBe(true);
|
||||
const emp = store.models["hr.employee"].get(3);
|
||||
store.setCashier(emp);
|
||||
expect(store.canEditPayment(order)).toBe(false);
|
||||
});
|
||||
test("handleUrlParams prevents unauthorized access when POS is locked with pos_hr", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.config.module_pos_hr = true;
|
||||
odoo.from_backend = false;
|
||||
|
||||
store.resetCashier();
|
||||
expect(store.cashier).toBe(false);
|
||||
expect(store.config.module_pos_hr).toBe(true);
|
||||
store.router.state.current = "ProductScreen";
|
||||
store.router.state.params = {};
|
||||
|
||||
let navigateCalledWithLoginScreen = false;
|
||||
patchWithCleanup(store.router, {
|
||||
navigate(routeName, routeParams) {
|
||||
if (routeName === "LoginScreen") {
|
||||
navigateCalledWithLoginScreen = true;
|
||||
}
|
||||
return super.navigate(routeName, routeParams);
|
||||
},
|
||||
});
|
||||
|
||||
await store.handleUrlParams();
|
||||
expect(navigateCalledWithLoginScreen).toBe(true);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue