19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:29:53 +01:00
parent 6e54c1af6c
commit 3ca647e428
1087 changed files with 132065 additions and 108499 deletions

View file

@ -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());
});

View file

@ -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);
});

View file

@ -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(),
});

View file

@ -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,
},
];
}