| 1 |
import { test, expect } from "@odoo/hoot"; |
| 2 |
import { mountWithCleanup } from "@web/../tests/web_test_helpers"; |
| 3 |
import { OrderSummary } from "@point_of_sale/app/screens/product_screen/order_summary/order_summary"; |
| 4 |
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils"; |
| 5 |
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions"; |
| 6 |
import { addProductLineToOrder } from "@pos_loyalty/../tests/unit/utils"; |
| 7 |
|
| 8 |
definePosModels(); |
| 9 |
|
| 10 |
test("_updateGiftCardOrderline", async () => { |
| 11 |
const store = await setupPosEnv(); |
| 12 |
const models = store.models; |
| 13 |
const order = store.addNewOrder(); |
| 14 |
|
| 15 |
const product = models["product.product"].get(1); |
| 16 |
// Program #3 - loyalty program for gift cards |
| 17 |
const program = models["loyalty.program"].get(3); |
| 18 |
// Card #3 - gift card which program type is gift_card |
| 19 |
const card = models["loyalty.card"].get(3); |
| 20 |
|
| 21 |
await addProductLineToOrder(store, order); |
| 22 |
|
| 23 |
const points = product.lst_price; |
| 24 |
|
| 25 |
order.uiState.couponPointChanges[card.id] = { |
| 26 |
coupon_id: card.id, |
| 27 |
program_id: program.id, |
| 28 |
product_id: product.id, |
| 29 |
points: points, |
| 30 |
manual: false, |
| 31 |
}; |
| 32 |
|
| 33 |
const component = await mountWithCleanup(OrderSummary, {}); |
| 34 |
|
| 35 |
await component._updateGiftCardOrderline("ABC123", points); |
| 36 |
|
| 37 |
const updatedLine = order.getSelectedOrderline(); |
| 38 |
|
| 39 |
expect(updatedLine.gift_code).toBe("ABC123"); |
| 40 |
expect(updatedLine.product_id.id).toBe(product.id); |
| 41 |
expect(updatedLine.getQuantity()).toBe(1); |
| 42 |
expect(order.uiState.couponPointChanges[card.id]).toBe(undefined); |
| 43 |
}); |