|
| 1 | +/** @odoo-module */ |
| 2 | +/* Copyright 2021 Tecnativa - Jairo Llopis |
| 3 | + Copyright 2025 Tecnativa - Víctor Martínez |
| 4 | + * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ |
| 5 | + |
| 6 | +import {registry} from "@web/core/registry"; |
| 7 | +import * as tourUtils from "@website_sale/js/tours/tour_utils"; |
| 8 | + |
| 9 | +registry.category("web_tour.tours").add("website_sale_resource_booking", { |
| 10 | + url: "/shop", |
| 11 | + steps: () => [ |
| 12 | + ...tourUtils.searchProduct("test not bookable product"), |
| 13 | + { |
| 14 | + content: "select test not bookable product", |
| 15 | + trigger: '.oe_product_cart:first a:contains("test not bookable product")', |
| 16 | + run: "click", |
| 17 | + }, |
| 18 | + { |
| 19 | + content: "click on add to cart", |
| 20 | + trigger: '#product_detail form[action^="/shop/cart/update"] #add_to_cart', |
| 21 | + run: "click", |
| 22 | + }, |
| 23 | + ...tourUtils.searchProduct("test bookable product"), |
| 24 | + { |
| 25 | + trigger: 'form input[name="search"]', |
| 26 | + run: "edit test bookable product", |
| 27 | + }, |
| 28 | + { |
| 29 | + trigger: 'form:has(input[name="search"]) .oe_search_button', |
| 30 | + }, |
| 31 | + { |
| 32 | + content: "select test bookable product", |
| 33 | + trigger: '.oe_product_cart:first a:contains("test bookable product")', |
| 34 | + run: "click", |
| 35 | + }, |
| 36 | + { |
| 37 | + content: "change quantity", |
| 38 | + trigger: |
| 39 | + '#product_detail form[action^="/shop/cart/update"] input[name=add_qty]', |
| 40 | + run: "edit 3", |
| 41 | + }, |
| 42 | + { |
| 43 | + content: "click on add to cart", |
| 44 | + trigger: '#product_detail form[action^="/shop/cart/update"] #add_to_cart', |
| 45 | + run: "click", |
| 46 | + }, |
| 47 | + |
| 48 | + tourUtils.goToCart({quantity: 4}), |
| 49 | + { |
| 50 | + // Go to next step |
| 51 | + trigger: "a[name='website_sale_main_button']:contains('Schedule bookings')", |
| 52 | + run: "click", |
| 53 | + }, |
| 54 | + { |
| 55 | + content: "Calendar is loaded", |
| 56 | + trigger: ".o_booking_calendar", |
| 57 | + }, |
| 58 | + { |
| 59 | + content: "Validate calendar title is shown", |
| 60 | + trigger: "h3:contains('Pre-schedule your booking')", |
| 61 | + }, |
| 62 | + { |
| 63 | + content: "Try next month if no slots", |
| 64 | + trigger: ".alert-danger a:contains('Try next month')", |
| 65 | + run: "click", |
| 66 | + }, |
| 67 | + { |
| 68 | + content: "Open March 1 calendar dropdown", |
| 69 | + trigger: "#dropdown-trigger-2021-03-01", |
| 70 | + run: "click", |
| 71 | + }, |
| 72 | + { |
| 73 | + trigger: |
| 74 | + ".dropdown:has(#dropdown-trigger-2021-03-01) .dropdown-menu button:contains('09:00')", |
| 75 | + run: "click", |
| 76 | + }, |
| 77 | + { |
| 78 | + trigger: |
| 79 | + '.modal.show input[name="partner_name"], .modal input[name="partner_name"]', |
| 80 | + run: "edit Mr. A", |
| 81 | + }, |
| 82 | + { |
| 83 | + trigger: |
| 84 | + '.modal.show input[name="partner_email"], .modal input[name="partner_email"], .modal input[name="email"]', |
| 85 | + run: "edit mr.a@example.com", |
| 86 | + }, |
| 87 | + { |
| 88 | + trigger: ".modal-dialog .btn:contains('Confirm booking')", |
| 89 | + run: "click", |
| 90 | + }, |
| 91 | + // Booking 2 of 3 (almost same as above) |
| 92 | + { |
| 93 | + content: "Try next month if no slots", |
| 94 | + trigger: ".alert-danger a:contains('Try next month')", |
| 95 | + run: "click", |
| 96 | + }, |
| 97 | + { |
| 98 | + content: "Open March 1 calendar dropdown", |
| 99 | + trigger: "#dropdown-trigger-2021-03-01", |
| 100 | + run: "click", |
| 101 | + }, |
| 102 | + |
| 103 | + { |
| 104 | + trigger: |
| 105 | + ".dropdown:has(#dropdown-trigger-2021-03-01) .dropdown-menu button:contains('09:00')", |
| 106 | + run: "click", |
| 107 | + }, |
| 108 | + // Enter Mr. B details, and confirm |
| 109 | + { |
| 110 | + trigger: |
| 111 | + '.modal.show input[name="partner_name"], .modal input[name="partner_name"]', |
| 112 | + run: "edit Mr. B", |
| 113 | + }, |
| 114 | + { |
| 115 | + trigger: |
| 116 | + '.modal.show input[name="partner_email"], .modal input[name="partner_email"], .modal input[name="email"]', |
| 117 | + run: "edit mr.b@example.com", |
| 118 | + }, |
| 119 | + { |
| 120 | + trigger: ".modal-dialog .btn:contains('Confirm booking')", |
| 121 | + run: "click", |
| 122 | + }, |
| 123 | + { |
| 124 | + content: "Try next month if no slots", |
| 125 | + trigger: ".alert-danger a:contains('Try next month')", |
| 126 | + run: "click", |
| 127 | + }, |
| 128 | + { |
| 129 | + content: "Open March 1 calendar dropdown", |
| 130 | + trigger: "#dropdown-trigger-2021-03-01", |
| 131 | + run: "click", |
| 132 | + }, |
| 133 | + |
| 134 | + { |
| 135 | + trigger: |
| 136 | + ".dropdown:has(#dropdown-trigger-2021-03-01) .dropdown-menu button:contains('09:30')", |
| 137 | + run: "click", |
| 138 | + }, |
| 139 | + // Enter Mr. B details, and confirm |
| 140 | + { |
| 141 | + trigger: |
| 142 | + '.modal.show input[name="partner_name"], .modal input[name="partner_name"]', |
| 143 | + run: "edit Mr. C", |
| 144 | + }, |
| 145 | + { |
| 146 | + trigger: |
| 147 | + '.modal.show input[name="partner_email"], .modal input[name="partner_email"], .modal input[name="email"]', |
| 148 | + run: "edit mr.c@example.com", |
| 149 | + }, |
| 150 | + { |
| 151 | + trigger: ".modal-dialog .btn:contains('Confirm booking')", |
| 152 | + run: "click", |
| 153 | + }, |
| 154 | + tourUtils.goToCheckout(), |
| 155 | + { |
| 156 | + trigger: ".oe_website_sale", |
| 157 | + run: function () { |
| 158 | + $('input[name="phone"]').val("+32 485 118.218"); |
| 159 | + $('input[name="street"]').val("Street A"); |
| 160 | + $('input[name="city"]').val("City A"); |
| 161 | + $('input[name="zip"]').val("18503"); |
| 162 | + $("#country_id option:eq(1)").attr("selected", true); |
| 163 | + // Integration with website_sale_vat_required |
| 164 | + $('input[name="vat"]').val("US01234567891"); |
| 165 | + // Integration with website_sale_require_legal |
| 166 | + $(".oe_website_sale input[name=accepted_legal_terms]").prop( |
| 167 | + "checked", |
| 168 | + true |
| 169 | + ); |
| 170 | + }, |
| 171 | + }, |
| 172 | + { |
| 173 | + trigger: ".btn-primary:contains('Save address')", |
| 174 | + }, |
| 175 | + tourUtils.goToCheckout(), |
| 176 | + ], |
| 177 | +}); |
0 commit comments