[IMP] point_of_sale: refactor tests for scanning barcodes

refactor 'scan_barcode' method to use barcodes function

task id: 3674936

closes odoo/odoo#153993

Signed-off-by: Vlad Stroia (vlst) <vlst@odoo.com>
This commit is contained in:
Manu Vaillant (manv)
2024-02-22 11:14:53 +00:00
parent 65617bd7ea
commit 35e807f424
5 changed files with 36 additions and 44 deletions
+1
View File
@@ -71,6 +71,7 @@
'point_of_sale/static/src/backend/debug_manager.js',
],
'web.assets_tests': [
'barcodes/static/tests/helpers.js',
'point_of_sale/static/tests/tours/**/*',
],
@@ -3,6 +3,7 @@
import * as ProductScreen from "@point_of_sale/../tests/tours/helpers/ProductScreenTourMethods";
import * as Chrome from "@point_of_sale/../tests/tours/helpers/ChromeTourMethods";
import { registry } from "@web/core/registry";
import { scan_barcode } from "@point_of_sale/../tests/tours/helpers/utils";
registry.category("web_tour.tours").add("BarcodeScanningTour", {
test: true,
@@ -16,21 +17,21 @@ registry.category("web_tour.tours").add("BarcodeScanningTour", {
ProductScreen.confirmOpeningPopup(),
// Add a product with its barcode
ProductScreen.scan_barcode("0123456789"),
scan_barcode("0123456789"),
ProductScreen.selectedOrderlineHas("Monitor Stand"),
ProductScreen.scan_barcode("0123456789"),
scan_barcode("0123456789"),
ProductScreen.selectedOrderlineHas("Monitor Stand", 2),
// Test "Prices product" EAN-13 `23.....{NNNDD}` barcode pattern
ProductScreen.scan_ean13_barcode("2305000000004"),
scan_barcode("2305000000004"),
ProductScreen.selectedOrderlineHas("Magnetic Board", 1, "0.00"),
ProductScreen.scan_ean13_barcode("2305000123451"),
scan_barcode("2305000123451"),
ProductScreen.selectedOrderlineHas("Magnetic Board", 1, "123.45"),
// Test "Weighted product" EAN-13 `21.....{NNDDD}` barcode pattern
ProductScreen.scan_ean13_barcode("2100005000000"),
scan_barcode("2100005000000"),
ProductScreen.selectedOrderlineHas("Wall Shelf Unit", 0, "0.00"),
ProductScreen.scan_ean13_barcode("2100005080002"),
scan_barcode("2100005080002"),
ProductScreen.selectedOrderlineHas("Wall Shelf Unit", 8),
Chrome.endTour(),
].flat(),
@@ -42,17 +43,16 @@ registry.category("web_tour.tours").add("BarcodeScanningProductPackagingTour", {
steps: () =>
[
ProductScreen.confirmOpeningPopup(),
// Add the product with its barcode
ProductScreen.scan_barcode("12345601"),
scan_barcode("12345601"),
ProductScreen.selectedOrderlineHas("Packaging Product", 1),
ProductScreen.scan_barcode("12345601"),
scan_barcode("12345601"),
ProductScreen.selectedOrderlineHas("Packaging Product", 2),
// Add the product packaging with its barcode
ProductScreen.scan_barcode("12345610"),
scan_barcode("12345610"),
ProductScreen.selectedOrderlineHas("Packaging Product", 12),
ProductScreen.scan_barcode("12345610"),
scan_barcode("12345610"),
ProductScreen.selectedOrderlineHas("Packaging Product", 22),
Chrome.endTour(),
].flat(),
@@ -66,21 +66,21 @@ registry.category("web_tour.tours").add("GS1BarcodeScanningTour", {
ProductScreen.confirmOpeningPopup(),
// Add the Product 1 with GS1 barcode
ProductScreen.scan_barcode("0108431673020125100000001"),
scan_barcode("0108431673020125100000001"),
ProductScreen.selectedOrderlineHas("Product 1"),
ProductScreen.scan_barcode("0108431673020125100000001"),
scan_barcode("0108431673020125100000001"),
ProductScreen.selectedOrderlineHas("Product 1", 2),
// Add the Product 2 with normal barcode
ProductScreen.scan_barcode("08431673020126"),
scan_barcode("08431673020126"),
ProductScreen.selectedOrderlineHas("Product 2"),
ProductScreen.scan_barcode("08431673020126"),
scan_barcode("08431673020126"),
ProductScreen.selectedOrderlineHas("Product 2", 2),
// Add the Product 3 with normal barcode
ProductScreen.scan_barcode("3760171283370"),
scan_barcode("3760171283370"),
ProductScreen.selectedOrderlineHas("Product 3"),
ProductScreen.scan_barcode("3760171283370"),
scan_barcode("3760171283370"),
ProductScreen.selectedOrderlineHas("Product 3", 2),
Chrome.endTour(),
].flat(),
@@ -6,7 +6,7 @@ import * as Chrome from "@point_of_sale/../tests/tours/helpers/ChromeTourMethods
import * as ReceiptScreen from "@point_of_sale/../tests/tours/helpers/ReceiptScreenTourMethods";
import { registry } from "@web/core/registry";
import * as Order from "@point_of_sale/../tests/tours/helpers/generic_components/OrderWidgetMethods";
import { inLeftSide } from "./helpers/utils";
import { inLeftSide, scan_barcode } from "@point_of_sale/../tests/tours/helpers/utils";
registry.category("web_tour.tours").add("ProductScreenTour", {
test: true,
@@ -191,13 +191,13 @@ registry.category("web_tour.tours").add("limitedProductPricelistLoading", {
[
ProductScreen.confirmOpeningPopup(),
ProductScreen.scan_barcode("0100100"),
scan_barcode("0100100"),
ProductScreen.selectedOrderlineHas('Test Product 1', '1.0', '80.0'),
ProductScreen.scan_barcode("0100200"),
scan_barcode("0100200"),
ProductScreen.selectedOrderlineHas('Test Product 2', '1.0', '100.0'),
ProductScreen.scan_barcode("0100300"),
scan_barcode("0100300"),
ProductScreen.selectedOrderlineHas('Test Product 3', '1.0', '50.0'),
Chrome.endTour(),
].flat(),
@@ -205,29 +205,6 @@ export function clickCloseSession() {
},
];
}
export function scan_barcode(barcode) {
return [
{
content: `PoS model scan barcode '${barcode}'`,
trigger: ".pos", // The element here does not really matter as long as it is present
run: () => {
window.posmodel.env.services.barcode_reader.scan(barcode);
},
},
];
}
export function scan_ean13_barcode(barcode) {
return [
{
content: `PoS model scan EAN13 barcode '${barcode}'`,
trigger: ".pos", // The element here does not really matter as long as it is present
run: () => {
const barcode_reader = window.posmodel.env.services.barcode_reader;
barcode_reader.scan(barcode_reader.parser.sanitize_ean(barcode));
},
},
];
}
export function goBackToMainScreen() {
return [
{
@@ -1,5 +1,7 @@
/** @odoo-module */
import { simulateBarCode } from "@barcodes/../tests/helpers"
export function inLeftSide(steps) {
return [
{
@@ -26,3 +28,15 @@ export function negateStep(step) {
trigger: negate(step.trigger),
};
}
export function scan_barcode(barcode) {
return [
{
content: `PoS model scan barcode '${barcode}'`,
trigger: "body", // The element here does not really matter as long as it is present
run: () => {
simulateBarCode([...barcode, "Enter"])
},
},
];
}