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

@ -0,0 +1,66 @@
import * as ProductScreen from "@point_of_sale/../tests/pos/tours/utils/product_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 TicketScreen from "@point_of_sale/../tests/pos/tours/utils/ticket_screen_util";
import * as Order from "@point_of_sale/../tests/generic_helpers/order_widget_util";
import * as Chrome from "@point_of_sale/../tests/pos/tours/utils/chrome_util";
import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util";
import { registry } from "@web/core/registry";
registry.category("web_tour.tours").add("test_pos_global_discount_sell_and_refund", {
steps: () =>
[
Chrome.startPoS(),
Dialog.confirm("Open Register"),
ProductScreen.addOrderline("Desk Pad", "1", "3"),
Chrome.clickOrders(),
Order.hasLine({
withoutClass: ".selected",
run: "click",
productName: "Desk Pad",
quantity: "1",
}),
// Check that the draft order's order line is not selected and not causing issues while
// comparing the line to the discount line
{
content: "Manually trigger keyup event",
trigger: ".ticket-screen",
run: function () {
window.dispatchEvent(new KeyboardEvent("keyup", { key: "9" }));
},
},
TicketScreen.loadSelectedOrder(),
ProductScreen.clickControlButton("Discount"),
{
content: `click discount numpad button: 5`,
trigger: `.o_dialog div.numpad button:contains(5)`,
run: "click",
},
Dialog.confirm(),
ProductScreen.selectedOrderlineHas("discount", 1, "-0.15"),
ProductScreen.totalAmountIs("2.85"),
ProductScreen.clickPayButton(),
PaymentScreen.clickPaymentMethod("Bank"),
PaymentScreen.clickValidate(),
ReceiptScreen.isShown(),
ReceiptScreen.clickNextOrder(),
...ProductScreen.clickRefund(),
TicketScreen.selectOrder("001"),
ProductScreen.clickNumpad("1"),
TicketScreen.toRefundTextContains("To Refund: 1"),
ProductScreen.clickLine("discount"),
ProductScreen.clickNumpad("1"),
Dialog.confirm(),
TicketScreen.confirmRefund(),
PaymentScreen.isShown(),
PaymentScreen.clickBack(),
ProductScreen.clickLine("discount"),
ProductScreen.clickNumpad("1"),
Dialog.is({ title: "price update not allowed" }),
Dialog.confirm(),
ProductScreen.clickPayButton(),
PaymentScreen.clickPaymentMethod("Bank"),
PaymentScreen.clickValidate(),
ReceiptScreen.isShown(),
].flat(),
});

View file

@ -0,0 +1,353 @@
import * as Chrome from "@point_of_sale/../tests/pos/tours/utils/chrome_util";
import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util";
import * as ProductScreen from "@point_of_sale/../tests/pos/tours/utils/product_screen_util";
import * as PaymentScreen from "@point_of_sale/../tests/pos/tours/utils/payment_screen_util";
import * as ReceiptScreen from "@point_of_sale/../tests/pos/tours/utils/receipt_screen_util";
import * as TicketScreen from "@point_of_sale/../tests/pos/tours/utils/ticket_screen_util";
import { escapeRegExp } from "@web/core/utils/strings";
import { registry } from "@web/core/registry";
export function addDocument(documentParams) {
const steps = [];
for (const values of documentParams) {
steps.push(...ProductScreen.addOrderline(values.product, values.quantity));
}
steps.push(...[ProductScreen.clickPartnerButton(), ProductScreen.clickCustomer("AAAAAA")]);
return steps;
}
export function clickDiscountNumpad(num) {
return {
content: `click discount numpad button: ${num}`,
trigger: `.o_dialog div.numpad button:contains(/^${escapeRegExp(num)}$/)`,
run: "click",
};
}
export function addDiscount(percentage) {
const steps = [ProductScreen.clickControlButton("Discount")];
for (const num of percentage.split("")) {
steps.push(clickDiscountNumpad(num));
}
steps.push({
trigger: `.popup-input:contains(/^${escapeRegExp(percentage)}$/)`,
run: "click",
});
steps.push(Dialog.confirm());
return steps;
}
export function payAndInvoice(totalAmount) {
return [
ProductScreen.clickPayButton(),
PaymentScreen.totalIs(totalAmount),
PaymentScreen.clickPaymentMethod("Bank"),
PaymentScreen.remainingIs("0.0"),
PaymentScreen.clickInvoiceButton(),
PaymentScreen.clickValidate(),
ReceiptScreen.receiptAmountTotalIs(totalAmount),
ReceiptScreen.clickNextOrder(),
];
}
registry
.category("web_tour.tours")
.add("test_taxes_l10n_in_pos_global_discount_round_per_line_price_excluded", {
steps: () =>
[
Chrome.startPoS(),
Dialog.confirm("Open Register"),
...addDocument([
{ product: "product_1_1", quantity: "1" },
{ product: "product_1_2", quantity: "1" },
]),
...addDiscount("2"),
ProductScreen.checkTotalAmount("35.91"),
ProductScreen.checkTaxAmount("4.76"),
...payAndInvoice("35.91"),
...addDocument([
{ product: "product_1_1", quantity: "1" },
{ product: "product_1_2", quantity: "1" },
]),
...addDiscount("7"),
ProductScreen.checkTotalAmount("34.08"),
ProductScreen.checkTaxAmount("4.53"),
...payAndInvoice("34.08"),
...addDocument([
{ product: "product_1_1", quantity: "1" },
{ product: "product_1_2", quantity: "1" },
]),
...addDiscount("18"),
ProductScreen.checkTotalAmount("30.04"),
ProductScreen.checkTaxAmount("3.99"),
...payAndInvoice("30.04"),
// On refund, check if the global discount line is correctly prorated in the refund order
...ProductScreen.clickRefund(),
TicketScreen.filterIs("Paid"),
TicketScreen.selectOrder("001"),
ProductScreen.clickNumpad("1"),
TicketScreen.confirmRefund(),
PaymentScreen.totalIs("-17.95"), // -18.32 (product_1_1) + 0.37 (discount)
].flat(),
});
registry
.category("web_tour.tours")
.add("test_taxes_l10n_in_pos_global_discount_round_globally_price_excluded", {
steps: () =>
[
Chrome.startPoS(),
Dialog.confirm("Open Register"),
...addDocument([
{ product: "product_2_1", quantity: "1" },
{ product: "product_2_2", quantity: "1" },
]),
...addDiscount("2"),
ProductScreen.checkTotalAmount("35.94"),
ProductScreen.checkTaxAmount("4.79"),
...payAndInvoice("35.94"),
...addDocument([
{ product: "product_2_1", quantity: "1" },
{ product: "product_2_2", quantity: "1" },
]),
...addDiscount("7"),
ProductScreen.checkTotalAmount("34.10"),
ProductScreen.checkTaxAmount("4.56"),
...payAndInvoice("34.10"),
...addDocument([
{ product: "product_2_1", quantity: "1" },
{ product: "product_2_2", quantity: "1" },
]),
...addDiscount("18"),
ProductScreen.checkTotalAmount("30.07"),
ProductScreen.checkTaxAmount("4.02"),
...payAndInvoice("30.07"),
].flat(),
});
registry
.category("web_tour.tours")
.add("test_taxes_l10n_in_pos_global_discount_round_per_line_price_included", {
steps: () =>
[
Chrome.startPoS(),
Dialog.confirm("Open Register"),
...addDocument([
{ product: "product_3_1", quantity: "1" },
{ product: "product_3_2", quantity: "1" },
]),
...addDiscount("2"),
ProductScreen.checkTotalAmount("35.91"),
ProductScreen.checkTaxAmount("4.76"),
...payAndInvoice("35.91"),
...addDocument([
{ product: "product_3_1", quantity: "1" },
{ product: "product_3_2", quantity: "1" },
]),
...addDiscount("7"),
ProductScreen.checkTotalAmount("34.08"),
ProductScreen.checkTaxAmount("4.53"),
...payAndInvoice("34.08"),
...addDocument([
{ product: "product_3_1", quantity: "1" },
{ product: "product_3_2", quantity: "1" },
]),
...addDiscount("18"),
ProductScreen.checkTotalAmount("30.04"),
ProductScreen.checkTaxAmount("3.99"),
...payAndInvoice("30.04"),
].flat(),
});
registry
.category("web_tour.tours")
.add("test_taxes_l10n_in_pos_global_discount_round_globally_price_included", {
steps: () =>
[
Chrome.startPoS(),
Dialog.confirm("Open Register"),
...addDocument([
{ product: "product_4_1", quantity: "1" },
{ product: "product_4_2", quantity: "1" },
]),
...addDiscount("2"),
ProductScreen.checkTotalAmount("35.93"),
ProductScreen.checkTaxAmount("4.79"),
...payAndInvoice("35.93"),
...addDocument([
{ product: "product_4_1", quantity: "1" },
{ product: "product_4_2", quantity: "1" },
]),
...addDiscount("7"),
ProductScreen.checkTotalAmount("34.09"),
ProductScreen.checkTaxAmount("4.56"),
...payAndInvoice("34.09"),
...addDocument([
{ product: "product_4_1", quantity: "1" },
{ product: "product_4_2", quantity: "1" },
]),
...addDiscount("18"),
ProductScreen.checkTotalAmount("30.06"),
ProductScreen.checkTaxAmount("4.02"),
...payAndInvoice("30.06"),
].flat(),
});
registry
.category("web_tour.tours")
.add("test_taxes_l10n_br_pos_global_discount_round_per_line_price_excluded", {
steps: () =>
[
Chrome.startPoS(),
Dialog.confirm("Open Register"),
...addDocument([
{ product: "product_1_1", quantity: "1" },
{ product: "product_1_2", quantity: "1" },
]),
...addDiscount("2"),
ProductScreen.checkTotalAmount("94.08"),
ProductScreen.checkTaxAmount("30.7"),
...payAndInvoice("94.08"),
].flat(),
});
registry
.category("web_tour.tours")
.add("test_taxes_l10n_br_pos_global_discount_round_globally_price_excluded", {
steps: () =>
[
Chrome.startPoS(),
Dialog.confirm("Open Register"),
...addDocument([
{ product: "product_2_1", quantity: "1" },
{ product: "product_2_2", quantity: "1" },
]),
...addDiscount("2"),
ProductScreen.checkTotalAmount("94.08"),
ProductScreen.checkTaxAmount("30.71"),
...payAndInvoice("94.08"),
].flat(),
});
registry
.category("web_tour.tours")
.add("test_taxes_l10n_br_pos_global_discount_round_per_line_price_included", {
steps: () =>
[
Chrome.startPoS(),
Dialog.confirm("Open Register"),
...addDocument([
{ product: "product_3_1", quantity: "1" },
{ product: "product_3_2", quantity: "1" },
]),
...addDiscount("2"),
ProductScreen.checkTotalAmount("94.08"),
ProductScreen.checkTaxAmount("30.7"),
...payAndInvoice("94.08"),
].flat(),
});
registry
.category("web_tour.tours")
.add("test_taxes_l10n_br_pos_global_discount_round_globally_price_included", {
steps: () =>
[
Chrome.startPoS(),
Dialog.confirm("Open Register"),
...addDocument([
{ product: "product_4_1", quantity: "1" },
{ product: "product_4_2", quantity: "1" },
]),
...addDiscount("2"),
ProductScreen.checkTotalAmount("94.08"),
ProductScreen.checkTaxAmount("30.71"),
...payAndInvoice("94.08"),
].flat(),
});
registry
.category("web_tour.tours")
.add("test_taxes_l10n_be_pos_global_discount_round_per_line_price_excluded", {
steps: () =>
[
Chrome.startPoS(),
Dialog.confirm("Open Register"),
...addDocument([
{ product: "product_1_1", quantity: "1" },
{ product: "product_1_2", quantity: "1" },
]),
...addDiscount("2"),
ProductScreen.checkTotalAmount("42.25"),
ProductScreen.checkTaxAmount("9.34"),
...payAndInvoice("42.25"),
].flat(),
});
registry
.category("web_tour.tours")
.add("test_taxes_l10n_be_pos_global_discount_round_globally_price_excluded", {
steps: () =>
[
Chrome.startPoS(),
Dialog.confirm("Open Register"),
...addDocument([
{ product: "product_2_1", quantity: "1" },
{ product: "product_2_2", quantity: "1" },
]),
...addDiscount("2"),
ProductScreen.checkTotalAmount("42.24"),
ProductScreen.checkTaxAmount("9.33"),
...payAndInvoice("42.24"),
].flat(),
});
registry
.category("web_tour.tours")
.add("test_taxes_l10n_be_pos_global_discount_round_per_line_price_included", {
steps: () =>
[
Chrome.startPoS(),
Dialog.confirm("Open Register"),
...addDocument([
{ product: "product_3_1", quantity: "1" },
{ product: "product_3_2", quantity: "1" },
]),
...addDiscount("2"),
ProductScreen.checkTotalAmount("42.25"),
ProductScreen.checkTaxAmount("9.34"),
...payAndInvoice("42.25"),
].flat(),
});
registry
.category("web_tour.tours")
.add("test_taxes_l10n_be_pos_global_discount_round_globally_price_included", {
steps: () =>
[
Chrome.startPoS(),
Dialog.confirm("Open Register"),
...addDocument([
{ product: "product_4_1", quantity: "1" },
{ product: "product_4_2", quantity: "1" },
]),
...addDiscount("2"),
ProductScreen.checkTotalAmount("42.25"),
ProductScreen.checkTaxAmount("9.33"),
...payAndInvoice("42.25"),
].flat(),
});