| 1 |
import { test, expect, animationFrame } 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, getFilledOrder } from "../utils"; |
| 5 |
import { definePosModels } from "../data/generate_model_definitions"; |
| 6 |
import { queryAll, queryOne } from "@odoo/hoot-dom"; |
| 7 |
|
| 8 |
definePosModels(); |
| 9 |
|
| 10 |
test("getNewLine", async () => { |
| 11 |
const store = await setupPosEnv(); |
| 12 |
const order = await getFilledOrder(store); |
| 13 |
const orderSummary = await mountWithCleanup(OrderSummary, {}); |
| 14 |
order.getSelectedOrderline().uiState.savedQuantity = 5; |
| 15 |
const newLine = orderSummary.getNewLine(); |
| 16 |
expect(newLine.order_id.id).toBe(order.id); |
| 17 |
expect(newLine.qty).toBe(0); |
| 18 |
}); |
| 19 |
|
| 20 |
test("Display tax include/exclude subtotal label", async () => { |
| 21 |
const store = await setupPosEnv(); |
| 22 |
const order = await getFilledOrder(store); |
| 23 |
|
| 24 |
order.config.iface_tax_included = "total"; |
| 25 |
await mountWithCleanup(OrderSummary, {}); |
| 26 |
const total = queryOne(".total"); |
| 27 |
const subtotal = queryAll(".subtotal"); |
| 28 |
expect(subtotal).toHaveLength(0); |
| 29 |
expect(total.innerHTML).toBe("$ 17.85"); |
| 30 |
|
| 31 |
order.config.iface_tax_included = "subtotal"; |
| 32 |
await animationFrame(); |
| 33 |
const total2 = queryOne(".total"); |
| 34 |
const subtotal2 = queryOne(".subtotal"); |
| 35 |
expect(total2.innerHTML).toBe("$ 17.85"); |
| 36 |
expect(subtotal2.innerHTML).toBe("$ 15.00"); |
| 37 |
}); |