Debian Codegraph @

addons/hr_holidays/static/tests/tours/time_off_allocation_warning_tour.js

raw
1 import { registry } from '@web/core/registry';
2 import { stepUtils } from "@web_tour/tour_utils";
3
4 const today = luxon.DateTime.now();
5 const pastDateFrom = today.minus({ days: 3 }).toFormat("MM/dd/yyyy");
6 const pastDateTo = today.minus({ days: 2 }).toFormat("MM/dd/yyyy");
7 const futureDateTo = today.plus({ days: 2 }).toFormat("MM/dd/yyyy");
8 const warningText = "The allocated days cannot be used, because the allocation is set to finish in the past.";
9
10 registry.category("web_tour.tours").add("time_off_allocation_warning_tour", {
11 url: "/odoo",
12 steps: () => [
13 stepUtils.showAppsMenuItem(),
14 {
15 content: "Click Time Off",
16 trigger: ".o_app[data-menu-xmlid='hr_holidays.menu_hr_holidays_root']",
17 run: "click",
18 },
19 {
20 content: "Open Management menu",
21 trigger: ".o-dropdown[data-menu-xmlid='hr_holidays.menu_hr_holidays_management']",
22 run: "click",
23 },
24 {
25 content: "Go to Allocations",
26 trigger: ".o-dropdown-item[data-menu-xmlid='hr_holidays.hr_holidays_menu_manager_approve_allocations']",
27 run: "click",
28 },
29 {
30 content: "Create a new allocation",
31 trigger: ".o-kanban-button-new",
32 run: "click",
33 },
34 {
35 content: "Click to select a leave type",
36 trigger: ".o_field_widget[name='holiday_status_id'] input",
37 run: "click",
38 },
39 {
40 trigger: ".o-autocomplete--dropdown-menu > li > a[id=holiday_status_id_0_0_0]",
41 run: "click",
42 },
43 {
44 content: "Open the start date picker",
45 trigger: ".o_field_widget[name='date_from'] button",
46 // Past date to trigger the warning
47 run: "click",
48 },
49 {
50 content: "Edit the start date picker",
51 trigger: ".o_field_widget[name='date_from'] input",
52 // Past date to trigger the warning
53 run: `click && edit ${pastDateFrom}`,
54 },
55 {
56 content: "Edit the end date picker",
57 trigger: ".o_field_widget[name='date_to'] input",
58 // Past date to trigger the warning
59 run: `click && edit ${pastDateTo} && click body`,
60 },
61 {
62 content: "Error regarding allocation to be visible",
63 trigger: `.o_cell:has(.o_row[name='validity']) + div span:contains(${warningText})`,
64 },
65 {
66 content: "Open the end date picker",
67 trigger: ".o_field_widget[name='date_to'] button",
68 run: "click",
69 },
70 {
71 content: "Edit the end date picker",
72 trigger: ".o_field_widget[name='date_to'] input",
73 run: `click && edit ${futureDateTo} && click body`,
74 },
75 {
76 content: "Error regarding allocation to be visible",
77 trigger: `.o_cell:has(.o_row[name='validity']) + div:not(:has(span:not(:contains(${warningText}))))`,
78 },
79 ...stepUtils.saveForm(),
80 ],
81 });