Debian Codegraph @

addons/pos_sale/static/tests/unit/components/orderline.test.js

raw symbols SCIP
1 import { test, expect } from "@odoo/hoot";
2 import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
3 import { mountWithCleanup } from "@web/../tests/web_test_helpers";
4 import { Orderline } from "@point_of_sale/app/components/orderline/orderline";
5 import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
6
7 definePosModels();
8
9 test("Displays the table with details of the down payment", async () => {
10 const store = await setupPosEnv();
11 const order = store.addNewOrder();
12
13 const productDownPayment = store.models["product.template"].get(105);
14 const sol1 = store.models["sale.order.line"].get(1);
15 const sol2 = store.models["sale.order.line"].get(2);
16 const line = await store.addLineToOrder(
17 {
18 product_tmpl_id: productDownPayment,
19 sale_order_origin_id: 1,
20 down_payment_details: [
21 {
22 product_name: sol1.display_name,
23 product_uom_qty: sol1.product_uom_qty,
24 price_unit: sol1.price_unit,
25 total: sol1.price_total,
26 },
27 {
28 product_name: sol2.display_name,
29 product_uom_qty: sol2.product_uom_qty,
30 price_unit: sol2.price_unit,
31 total: sol2.price_total,
32 },
33 ],
34 qty: 1,
35 },
36 order
37 );
38
39 const comp = await mountWithCleanup(Orderline, { props: { line } });
40
41 const saleOrderInfo = ".orderline .info-list .sale-order-info";
42 const cell = (tr, td) => `${saleOrderInfo} tr:nth-child(${tr}) td:nth-child(${td})`;
43
44 expect(comp.line).toEqual(line);
45 expect(saleOrderInfo).toBeVisible();
46 expect(`${saleOrderInfo} tr`).toHaveCount(2);
47
48 expect(cell(1, 1)).toHaveText("5x");
49 expect(cell(1, 2)).toHaveText("Product 1");
50 expect(cell(1, 4)).toHaveText(`$ 500.00 (tax incl.)`);
51
52 expect(cell(2, 1)).toHaveText("3x");
53 expect(cell(2, 2)).toHaveText("Product 2");
54 expect(cell(2, 4)).toHaveText(`$ 150.00 (tax incl.)`);
55 });