| 1 |
/* global posmodel */ |
| 2 |
|
| 3 |
import { registry } from "@web/core/registry"; |
| 4 |
import * as PaymentScreen from "@point_of_sale/../tests/pos/tours/utils/payment_screen_util"; |
| 5 |
import * as ReceiptScreen from "@point_of_sale/../tests/pos/tours/utils/receipt_screen_util"; |
| 6 |
import * as FloorScreen from "@pos_restaurant/../tests/tours/utils/floor_screen_util"; |
| 7 |
import * as ChromePos from "@point_of_sale/../tests/pos/tours/utils/chrome_util"; |
| 8 |
import * as ChromeRestaurant from "@pos_restaurant/../tests/tours/utils/chrome"; |
| 9 |
import * as ProductScreenPos from "@point_of_sale/../tests/pos/tours/utils/product_screen_util"; |
| 10 |
import * as ProductScreenResto from "@pos_restaurant/../tests/tours/utils/product_screen_util"; |
| 11 |
|
| 12 |
const Chrome = { ...ChromePos, ...ChromeRestaurant }; |
| 13 |
const ProductScreen = { ...ProductScreenPos, ...ProductScreenResto }; |
| 14 |
|
| 15 |
const getRandomTable = () => { |
| 16 |
const tables = posmodel.currentFloor.table_ids; |
| 17 |
return tables[Math.floor(Math.random() * tables.length)].table_number; |
| 18 |
}; |
| 19 |
|
| 20 |
const getRandomTableWithOrder = () => { |
| 21 |
const tables = posmodel.currentFloor.table_ids.filter( |
| 22 |
(table) => table.backLink("<-pos.order.table_id").length > 0 |
| 23 |
); |
| 24 |
return tables[Math.floor(Math.random() * tables.length)].table_number; |
| 25 |
}; |
| 26 |
|
| 27 |
const getRandomProduct = () => { |
| 28 |
const products = posmodel.models["product.product"].filter( |
| 29 |
(p) => |
| 30 |
!p.isConfigurable() && |
| 31 |
!p.isCombo() && |
| 32 |
!p.isTracked() && |
| 33 |
p.id !== posmodel.config.tip_product_id?.id && |
| 34 |
!posmodel.config._pos_special_products_ids?.includes(p.id) |
| 35 |
); |
| 36 |
return products[Math.floor(Math.random() * products.length)].name; |
| 37 |
}; |
| 38 |
|
| 39 |
registry.category("web_tour.tours").add("PoSFakeTourRestaurant", { |
| 40 |
steps: () => |
| 41 |
[ |
| 42 |
FloorScreen.clickTable(getRandomTable()), |
| 43 |
ProductScreen.clickDisplayedProduct(getRandomProduct()), |
| 44 |
ProductScreen.clickDisplayedProduct(getRandomProduct()), |
| 45 |
ProductScreen.clickDisplayedProduct(getRandomProduct()), |
| 46 |
Chrome.clickPlanButton(), |
| 47 |
FloorScreen.clickTable(getRandomTable()), |
| 48 |
ProductScreen.clickDisplayedProduct(getRandomProduct()), |
| 49 |
ProductScreen.clickDisplayedProduct(getRandomProduct()), |
| 50 |
ProductScreen.clickDisplayedProduct(getRandomProduct()), |
| 51 |
ProductScreen.clickPayButton(), |
| 52 |
PaymentScreen.clickPaymentMethod("Cash"), |
| 53 |
PaymentScreen.clickValidate(), |
| 54 |
ReceiptScreen.clickNextOrder(), |
| 55 |
].flat(), |
| 56 |
}); |
| 57 |
|
| 58 |
registry.category("web_tour.tours").add("PoSFakeTourTransferOrder", { |
| 59 |
steps: () => |
| 60 |
[ |
| 61 |
FloorScreen.clickTable(getRandomTableWithOrder()), |
| 62 |
ProductScreen.clickControlButton("Transfer"), |
| 63 |
FloorScreen.clickTable(getRandomTable()), |
| 64 |
ProductScreen.clickDisplayedProduct(getRandomProduct()), |
| 65 |
Chrome.clickPlanButton(), |
| 66 |
].flat(), |
| 67 |
}); |