| 1 |
|
| 2 |
|
| 3 |
import * as ProductScreen from "@point_of_sale/../tests/pos/tours/utils/product_screen_util"; |
| 4 |
import * as ReceiptScreen from "@point_of_sale/../tests/pos/tours/utils/receipt_screen_util"; |
| 5 |
import * as PaymentScreen from "@point_of_sale/../tests/pos/tours/utils/payment_screen_util"; |
| 6 |
import * as Chrome from "@point_of_sale/../tests/pos/tours/utils/chrome_util"; |
| 7 |
import * as NumberPopup from "@point_of_sale/../tests/generic_helpers/number_popup_util"; |
| 8 |
import * as Order from "@point_of_sale/../tests/generic_helpers/order_widget_util"; |
| 9 |
import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util"; |
| 10 |
import * as Numpad from "@point_of_sale/../tests/generic_helpers/numpad_util"; |
| 11 |
import { registry } from "@web/core/registry"; |
| 12 |
import { inLeftSide } from "@point_of_sale/../tests/pos/tours/utils/common"; |
| 13 |
import * as OfflineUtil from "@point_of_sale/../tests/generic_helpers/offline_util"; |
| 14 |
import { run, negateStep } from "@point_of_sale/../tests/generic_helpers/utils"; |
| 15 |
|
| 16 |
registry.category("web_tour.tours").add("ReceiptScreenTour", { |
| 17 |
steps: () => |
| 18 |
[ |
| 19 |
|
| 20 |
Chrome.startPoS(), |
| 21 |
Dialog.confirm("Open Register"), |
| 22 |
OfflineUtil.setOfflineMode(), |
| 23 |
ProductScreen.addOrderline("Letter Tray", "10", "5"), |
| 24 |
ProductScreen.clickPartnerButton(), |
| 25 |
ProductScreen.clickCustomer("Partner Full"), |
| 26 |
ProductScreen.clickPayButton(), |
| 27 |
PaymentScreen.clickPaymentMethod("Bank"), |
| 28 |
PaymentScreen.validateButtonIsHighlighted(true), |
| 29 |
PaymentScreen.clickShipLaterButton(), |
| 30 |
PaymentScreen.shippingLaterHighlighted(), |
| 31 |
PaymentScreen.clickValidate(), |
| 32 |
ReceiptScreen.receiptIsThere(), |
| 33 |
ReceiptScreen.cashierNameExists("A"), |
| 34 |
Dialog.confirm("Continue with limited functionality"), |
| 35 |
|
| 36 |
ReceiptScreen.shippingDateExists(), |
| 37 |
ReceiptScreen.shippingDateIsToday(), |
| 38 |
|
| 39 |
ReceiptScreen.totalAmountContains("55.0"), |
| 40 |
ReceiptScreen.clickNextOrder(), |
| 41 |
|
| 42 |
|
| 43 |
ProductScreen.addOrderline("Desk Pad", "6", "5", "30.0"), |
| 44 |
ProductScreen.addOrderline("Whiteboard Pen", "6", "6", "36.0"), |
| 45 |
ProductScreen.addOrderline("Monitor Stand", "6", "1", "6.0"), |
| 46 |
ProductScreen.clickPayButton(), |
| 47 |
PaymentScreen.clickPaymentMethod("Cash"), |
| 48 |
PaymentScreen.enterPaymentLineAmount("Cash", "70", true, { remaining: "2.0" }), |
| 49 |
PaymentScreen.clickNumpad("0"), |
| 50 |
PaymentScreen.fillPaymentLineAmountMobile("Cash", "700"), |
| 51 |
PaymentScreen.changeIs("628.0"), |
| 52 |
OfflineUtil.setOnlineMode(), |
| 53 |
PaymentScreen.clickValidate(), |
| 54 |
ReceiptScreen.receiptIsThere(), |
| 55 |
ReceiptScreen.totalAmountContains("72.0"), |
| 56 |
ReceiptScreen.setEmail("[email protected]"), |
| 57 |
ReceiptScreen.clickSend(), |
| 58 |
ReceiptScreen.emailIsSuccessful(), |
| 59 |
OfflineUtil.setOfflineMode(), |
| 60 |
ReceiptScreen.clickNextOrder(), |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
ProductScreen.addOrderline("Desk Pad", "6", "5"), |
| 65 |
ProductScreen.clickPayButton(), |
| 66 |
PaymentScreen.clickTipButton(), |
| 67 |
{ |
| 68 |
content: "click numpad button: 1", |
| 69 |
trigger: ".modal div.numpad button:contains(/^1/)", |
| 70 |
run: "click", |
| 71 |
}, |
| 72 |
NumberPopup.isShown("1"), |
| 73 |
Dialog.confirm(), |
| 74 |
PaymentScreen.emptyPaymentlines("31.0"), |
| 75 |
PaymentScreen.clickPaymentMethod("Cash"), |
| 76 |
PaymentScreen.clickValidate(), |
| 77 |
ReceiptScreen.receiptIsThere(), |
| 78 |
ReceiptScreen.totalAmountContains(`$ 30.00 + $ 1.00 tip`), |
| 79 |
ReceiptScreen.clickNextOrder(), |
| 80 |
|
| 81 |
|
| 82 |
ProductScreen.addOrderline("Desk Pad", "1", "5"), |
| 83 |
inLeftSide([ |
| 84 |
{ ...ProductScreen.clickLine("Desk Pad")[0], isActive: ["mobile"] }, |
| 85 |
...ProductScreen.addCustomerNote("Test customer note"), |
| 86 |
]), |
| 87 |
ProductScreen.clickPayButton(), |
| 88 |
PaymentScreen.clickPaymentMethod("Bank"), |
| 89 |
PaymentScreen.clickValidate(), |
| 90 |
Order.hasLine({ customerNote: "Test customer note" }), |
| 91 |
ReceiptScreen.clickNextOrder(), |
| 92 |
|
| 93 |
|
| 94 |
ProductScreen.addOrderline("Desk Pad", "1", "5"), |
| 95 |
inLeftSide([ |
| 96 |
{ ...ProductScreen.clickLine("Desk Pad")[0], isActive: ["mobile"] }, |
| 97 |
...ProductScreen.addInternalNote("Test internal note"), |
| 98 |
...ProductScreen.clickSelectedLine("Desk Pad"), |
| 99 |
...ProductScreen.addInternalNote("Test internal note on order"), |
| 100 |
...Order.hasInternalNote("Test internal note on order"), |
| 101 |
]), |
| 102 |
ProductScreen.clickPayButton(), |
| 103 |
PaymentScreen.clickPaymentMethod("Bank"), |
| 104 |
PaymentScreen.clickValidate(), |
| 105 |
ReceiptScreen.isShown(), |
| 106 |
negateStep(...Order.hasLine({ internalNote: "Test internal note" })), |
| 107 |
negateStep(...Order.hasInternalNote("Test internal note on order")), |
| 108 |
ReceiptScreen.clickNextOrder(), |
| 109 |
|
| 110 |
|
| 111 |
ProductScreen.addOrderline("Desk Pad", "1", "20"), |
| 112 |
inLeftSide([ |
| 113 |
{ ...ProductScreen.clickLine("Desk Pad")[0], isActive: ["mobile"] }, |
| 114 |
Numpad.click("%"), |
| 115 |
...ProductScreen.selectedOrderlineHasDirect("Desk Pad", "1", "20"), |
| 116 |
Numpad.click("5"), |
| 117 |
...ProductScreen.selectedOrderlineHasDirect("Desk Pad", "1", "19.0"), |
| 118 |
Numpad.click("."), |
| 119 |
]), |
| 120 |
ProductScreen.clickPayButton(), |
| 121 |
PaymentScreen.clickPaymentMethod("Bank"), |
| 122 |
PaymentScreen.clickValidate(), |
| 123 |
ReceiptScreen.receiptIsThere(), |
| 124 |
Order.hasLine({ productName: "Desk Pad", priceNoDiscount: "20" }), |
| 125 |
ReceiptScreen.totalAmountContains("19.00"), |
| 126 |
ReceiptScreen.clickNextOrder(), |
| 127 |
OfflineUtil.setOnlineMode(), |
| 128 |
].flat(), |
| 129 |
}); |
| 130 |
|
| 131 |
registry.category("web_tour.tours").add("ReceiptScreenDiscountWithPricelistTour", { |
| 132 |
steps: () => |
| 133 |
[ |
| 134 |
Chrome.startPoS(), |
| 135 |
Dialog.confirm("Open Register"), |
| 136 |
ProductScreen.addOrderline("Test Product", "1"), |
| 137 |
ProductScreen.clickPriceList("special_pricelist"), |
| 138 |
inLeftSide(Order.hasLine({ productName: "Test Product", price: "6.30" })), |
| 139 |
ProductScreen.clickPayButton(), |
| 140 |
PaymentScreen.clickPaymentMethod("Cash"), |
| 141 |
PaymentScreen.clickValidate(), |
| 142 |
Order.hasLine({ price: "6.30" }), |
| 143 |
|
| 144 |
ReceiptScreen.clickNextOrder(), |
| 145 |
ProductScreen.addOrderline("Test Product", "1"), |
| 146 |
inLeftSide([ |
| 147 |
{ ...ProductScreen.clickLine("Test Product")[0], isActive: ["mobile"] }, |
| 148 |
Numpad.click("Price"), |
| 149 |
Numpad.isActive("Price"), |
| 150 |
Numpad.click("9"), |
| 151 |
]), |
| 152 |
ProductScreen.clickPayButton(), |
| 153 |
PaymentScreen.clickPaymentMethod("Cash"), |
| 154 |
PaymentScreen.clickValidate(), |
| 155 |
ReceiptScreen.noDiscountAmount(), |
| 156 |
].flat(), |
| 157 |
}); |
| 158 |
|
| 159 |
registry.category("web_tour.tours").add("OrderPaidInCash", { |
| 160 |
steps: () => |
| 161 |
[ |
| 162 |
Chrome.startPoS(), |
| 163 |
Dialog.confirm("Open Register"), |
| 164 |
ProductScreen.addOrderline("Desk Pad", "5", "5"), |
| 165 |
inLeftSide(ProductScreen.orderLineHas("Desk Pad", "5")), |
| 166 |
ProductScreen.clickPayButton(), |
| 167 |
PaymentScreen.clickPaymentMethod("Cash"), |
| 168 |
PaymentScreen.validateButtonIsHighlighted(true), |
| 169 |
PaymentScreen.clickValidate(), |
| 170 |
ReceiptScreen.receiptIsThere(), |
| 171 |
ReceiptScreen.clickNextOrder(), |
| 172 |
ProductScreen.isShown(), |
| 173 |
|
| 174 |
Chrome.clickMenuOption("Close Register"), |
| 175 |
ProductScreen.closeWithCashAmount("25"), |
| 176 |
ProductScreen.cashDifferenceIs("0.00"), |
| 177 |
{ |
| 178 |
trigger: ".modal .modal-footer .btn:contains(close register)", |
| 179 |
run: "click", |
| 180 |
expectUnloadPage: true, |
| 181 |
}, |
| 182 |
{ |
| 183 |
trigger: "button:contains(backend)", |
| 184 |
run: "click", |
| 185 |
expectUnloadPage: true, |
| 186 |
}, |
| 187 |
{ |
| 188 |
trigger: "body", |
| 189 |
expectUnloadPage: true, |
| 190 |
}, |
| 191 |
].flat(), |
| 192 |
}); |
| 193 |
|
| 194 |
registry.category("web_tour.tours").add("ReceiptTrackingMethodTour", { |
| 195 |
steps: () => |
| 196 |
[ |
| 197 |
Chrome.startPoS(), |
| 198 |
Dialog.confirm("Open Register"), |
| 199 |
ProductScreen.clickDisplayedProduct("Product A"), |
| 200 |
ProductScreen.enterLotNumber("123456789", "lot"), |
| 201 |
ProductScreen.clickPayButton(), |
| 202 |
PaymentScreen.clickPaymentMethod("Cash"), |
| 203 |
PaymentScreen.clickValidate(), |
| 204 |
ReceiptScreen.trackingMethodIsLot("123456789"), |
| 205 |
].flat(), |
| 206 |
}); |
| 207 |
|
| 208 |
registry.category("web_tour.tours").add("point_of_sale.test_printed_receipt_tour", { |
| 209 |
steps: () => |
| 210 |
[ |
| 211 |
Chrome.startPoS(), |
| 212 |
Dialog.confirm("Open Register"), |
| 213 |
ProductScreen.addOrderline("Desk Pad", "1", "5"), |
| 214 |
ProductScreen.clickPayButton(), |
| 215 |
PaymentScreen.clickPaymentMethod("Bank"), |
| 216 |
PaymentScreen.clickValidate(), |
| 217 |
ReceiptScreen.receiptIsThere(), |
| 218 |
|
| 219 |
run(async () => { |
| 220 |
window.print = (e) => { |
| 221 |
const rendered = e.innerHTML; |
| 222 |
if (!rendered.includes("Desk Pad")) { |
| 223 |
throw new Error("Desk Pad is not present on the ticket"); |
| 224 |
} |
| 225 |
|
| 226 |
if (rendered.includes("5.00 / Units")) { |
| 227 |
throw new Error("The price should not be included on a basic receipt"); |
| 228 |
} |
| 229 |
}; |
| 230 |
await posmodel.printReceipt({ basic: true }); |
| 231 |
}, "Basic receipt doesn't have price"), |
| 232 |
].flat(), |
| 233 |
}); |
| 234 |
|
| 235 |
registry.category("web_tour.tours").add("test_auto_validate_force_done", { |
| 236 |
steps: () => |
| 237 |
[ |
| 238 |
Chrome.startPoS(), |
| 239 |
Dialog.confirm("Open Register"), |
| 240 |
ProductScreen.addOrderline("Whiteboard Pen", "1"), |
| 241 |
ProductScreen.clickPayButton(), |
| 242 |
PaymentScreen.clickPaymentMethod("Cash"), |
| 243 |
{ |
| 244 |
trigger: "body", |
| 245 |
run: () => { |
| 246 |
posmodel.getOrder().payment_ids[0].setPaymentStatus("force_done"); |
| 247 |
}, |
| 248 |
}, |
| 249 |
{ |
| 250 |
trigger: ".send_force_done", |
| 251 |
run: "click", |
| 252 |
}, |
| 253 |
ReceiptScreen.receiptIsThere(), |
| 254 |
].flat(), |
| 255 |
}); |