Debian Codegraph @

addons/sale/static/tests/tours/sale_combo_configurator.js

raw symbols SCIP
1 import { registry } from '@web/core/registry';
2 import { stepUtils } from '@web_tour/tour_utils';
3 import comboConfiguratorTourUtils from '@sale/js/tours/combo_configurator_tour_utils';
4 import productConfiguratorTourUtils from '@sale/js/tours/product_configurator_tour_utils';
5 import tourUtils from '@sale/js/tours/tour_utils';
6
7 registry
8 .category('web_tour.tours')
9 .add('sale_combo_configurator', {
10 url: '/odoo',
11 steps: () => [
12 ...stepUtils.goToAppSteps('sale.sale_menu_root', "Open the sales app"),
13 ...tourUtils.createNewSalesOrder(),
14 ...tourUtils.selectCustomer("Test Partner"),
15 ...tourUtils.addProduct("Combo product"),
16 // Assert that the combo configurator has the correct data.
17 comboConfiguratorTourUtils.assertComboCount(2),
18 comboConfiguratorTourUtils.assertComboItemCount("Combo A", 2),
19 comboConfiguratorTourUtils.assertComboItemCount("Combo B", 2),
20 // Assert that price changes when the quantity is updated.
21 comboConfiguratorTourUtils.assertQuantity(1),
22 comboConfiguratorTourUtils.assertPrice('25.00'),
23 comboConfiguratorTourUtils.increaseQuantity(),
24 comboConfiguratorTourUtils.assertQuantity(2),
25 comboConfiguratorTourUtils.assertPrice('50.00'),
26 comboConfiguratorTourUtils.decreaseQuantity(),
27 comboConfiguratorTourUtils.assertQuantity(1),
28 comboConfiguratorTourUtils.assertPrice('25.00'),
29 comboConfiguratorTourUtils.setQuantity(3),
30 comboConfiguratorTourUtils.assertQuantity(3),
31 comboConfiguratorTourUtils.assertPrice('75.00'),
32 // Assert that the combo configurator can only be saved after selecting an item for each
33 // combo.
34 comboConfiguratorTourUtils.assertConfirmButtonDisabled(),
35 comboConfiguratorTourUtils.selectComboItem("Product A2"),
36 comboConfiguratorTourUtils.selectComboItem("Product B2"),
37 comboConfiguratorTourUtils.assertConfirmButtonEnabled(),
38 // Assert that the product configurator is opened when a product with configurable
39 // `no_variant` PTALs is selected.
40 comboConfiguratorTourUtils.selectComboItem("Product A1"),
41 productConfiguratorTourUtils.selectAttribute("Product A1", "No variant attribute", "A"),
42 ...productConfiguratorTourUtils.saveConfigurator(),
43 // Assert that the extra price of a combo item is applied correctly.
44 comboConfiguratorTourUtils.assertPrice('90.00'),
45 // Assert that the extra price of a `no_variant` PTAV is applied correctly.
46 comboConfiguratorTourUtils.selectComboItem("Product A1"),
47 ...productConfiguratorTourUtils.selectAndSetCustomAttribute(
48 "Product A1", "No variant attribute", "B", "Some custom value"
49 ),
50 ...productConfiguratorTourUtils.saveConfigurator(),
51 comboConfiguratorTourUtils.assertPrice('93.00'),
52 // Assert that the order's content is correct.
53 ...comboConfiguratorTourUtils.saveConfigurator(),
54 tourUtils.checkSOLDescriptionContains("Combo product x 3"),
55 tourUtils.checkSOLDescriptionContains(
56 "Product A1", "No variant attribute: B: Some custom value"
57 ),
58 tourUtils.checkSOLDescriptionContains("Product B2"),
59 {
60 content: "Verify the combo item quantities",
61 trigger: 'td[name="product_uom_qty"]:contains(3.00)',
62 },
63 {
64 content: "Verify the first combo item's unit price",
65 trigger: 'td[name="price_unit"]:contains(18.50)',
66 },
67 {
68 content: "Verify the second combo item's unit price",
69 trigger: 'td[name="price_unit"]:contains(12.50)',
70 },
71 {
72 content: "Verify the order's total price",
73 trigger: 'div.oe_subtotal_footer:contains(93.00)',
74 },
75 // Assert that the combo configurator is opened with the previous selection when the
76 // combo is edited.
77 tourUtils.editLineMatching("Combo product x 3"),
78 tourUtils.editConfiguration(),
79 comboConfiguratorTourUtils.setQuantity(2),
80 comboConfiguratorTourUtils.assertComboItemSelected("Product A1"),
81 comboConfiguratorTourUtils.assertComboItemSelected("Product B2"),
82 comboConfiguratorTourUtils.selectComboItem("Product A2"),
83 // Assert that the order's content has been updated.
84 ...comboConfiguratorTourUtils.saveConfigurator(),
85 tourUtils.checkSOLDescriptionContains("Combo product x 2"),
86 tourUtils.checkSOLDescriptionContains("Product A2"),
87 tourUtils.checkSOLDescriptionContains("Product B2"),
88 {
89 content: "Verify the combo item quantities",
90 trigger: 'td[name="product_uom_qty"]:contains(2.00)',
91 },
92 {
93 content: "Verify the first combo item's unit price",
94 trigger: 'td[name="price_unit"]:contains(12.50)',
95 },
96 {
97 content: "Verify the second combo item's unit price",
98 trigger: 'td[name="price_unit"]:contains(12.50)',
99 },
100 {
101 content: "Verify the order's total price",
102 trigger: 'div.oe_subtotal_footer:contains(50.00)',
103 },
104 // Don't end the tour with a form in edition mode.
105 ...stepUtils.saveForm(),
106 ],
107 });
108
109 registry
110 .category('web_tour.tours')
111 .add('sale_combo_configurator_with_optional_products', {
112 url: '/odoo',
113 steps: () => [
114 ...stepUtils.goToAppSteps('sale.sale_menu_root', "Open the sales app"),
115 ...tourUtils.createNewSalesOrder(),
116 ...tourUtils.selectCustomer("Test Partner"),
117 ...tourUtils.addProduct("Combo product"),
118 comboConfiguratorTourUtils.selectComboItem("Product B2"),
119 ...comboConfiguratorTourUtils.saveConfigurator(),
120 productConfiguratorTourUtils.addOptionalProduct("Optional product"),
121 {
122 content: "verify that we cannot reduce main product quantity",
123 trigger: ':not(button[name="sale_quantity_button_minus"])',
124 },
125 {
126 content: "verify that we cannot increase main product quantity",
127 trigger: ':not(button[name="sale_quantity_button_plus"])',
128 },
129 ...productConfiguratorTourUtils.saveConfigurator(),
130 tourUtils.checkSOLDescriptionContains("Combo product"),
131 tourUtils.checkSOLDescriptionContains("Product B2"),
132 tourUtils.checkSOLDescriptionContains("Optional product"),
133 // Don't end the tour with a form in edition mode.
134 ...stepUtils.saveForm(),
135 ],
136 });