| 1 |
import { test, expect } from "@odoo/hoot"; |
| 2 |
import { mountWithCleanup } from "@web/../tests/web_test_helpers"; |
| 3 |
import { setupPosEnv } from "../utils"; |
| 4 |
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; |
| 5 |
import { definePosModels } from "../data/generate_model_definitions"; |
| 6 |
|
| 7 |
definePosModels(); |
| 8 |
|
| 9 |
test("_getProductByBarcode", async () => { |
| 10 |
const store = await setupPosEnv(); |
| 11 |
store.addNewOrder(); |
| 12 |
const order = store.getOrder(); |
| 13 |
const comp = await mountWithCleanup(ProductScreen, { props: { orderUuid: order.uuid } }); |
| 14 |
await comp.addProductToOrder(store.models["product.template"].get(5)); |
| 15 |
|
| 16 |
expect(order.displayPrice).toBe(3.45); |
| 17 |
expect(comp.total).toBe("$\u00a03.45"); |
| 18 |
expect(comp.items).toBe("1"); |
| 19 |
|
| 20 |
const productByBarcode = await comp._getProductByBarcode({ base_code: "test_test" }); |
| 21 |
expect(productByBarcode.id).toEqual(5); |
| 22 |
}); |
| 23 |
|
| 24 |
test("fastValidate", async () => { |
| 25 |
const store = await setupPosEnv(); |
| 26 |
store.addNewOrder(); |
| 27 |
const order = store.getOrder(); |
| 28 |
const fastPaymentMethod = order.config.fast_payment_method_ids[0]; |
| 29 |
const productScreen = await mountWithCleanup(ProductScreen, { |
| 30 |
props: { orderUuid: order.uuid }, |
| 31 |
}); |
| 32 |
await productScreen.addProductToOrder(store.models["product.template"].get(5)); |
| 33 |
|
| 34 |
expect(order.displayPrice).toBe(3.45); |
| 35 |
expect(productScreen.total).toBe("$\u00a03.45"); |
| 36 |
expect(productScreen.items).toBe("1"); |
| 37 |
|
| 38 |
await productScreen.fastValidate(fastPaymentMethod); |
| 39 |
|
| 40 |
expect(order.payment_ids[0].payment_method_id).toEqual(fastPaymentMethod); |
| 41 |
expect(order.state).toBe("paid"); |
| 42 |
expect(order.amount_paid).toBe(3.45); |
| 43 |
}); |