| 1 |
import { rpc } from "@web/core/network/rpc"; |
| 2 |
import { registry } from "@web/core/registry"; |
| 3 |
import { delay } from "@web/core/utils/concurrency"; |
| 4 |
|
| 5 |
registry.category("web_tour.tours").add('shop_wishlist', { |
| 6 |
url: '/shop?search=Customizable Desk', |
| 7 |
steps: () => [ |
| 8 |
{ |
| 9 |
content: "hover card && click on add to wishlist", |
| 10 |
trigger: ".o_wsale_product_grid_wrapper:contains(desk)", |
| 11 |
run: "hover && click .o_add_wishlist", |
| 12 |
}, |
| 13 |
{ |
| 14 |
trigger: 'a[href="/shop/wishlist"] .badge:contains(1)', |
| 15 |
}, |
| 16 |
{ |
| 17 |
content: "go to wishlist", |
| 18 |
trigger: 'a[href="/shop/wishlist"]', |
| 19 |
run: "click", |
| 20 |
expectUnloadPage: true, |
| 21 |
}, |
| 22 |
{ |
| 23 |
content: "remove first item in whishlist", |
| 24 |
trigger: '.o_wish_rm:first', |
| 25 |
run: "click", |
| 26 |
}, |
| 27 |
{ |
| 28 |
content: "go back to the store", |
| 29 |
trigger: "#empty-wishlist-message a[href='/shop']", |
| 30 |
run: "click", |
| 31 |
expectUnloadPage: true, |
| 32 |
}, |
| 33 |
{ |
| 34 |
content: "hover card && click on add to wishlist", |
| 35 |
trigger: ".o_wsale_product_grid_wrapper:contains(desk)", |
| 36 |
run: "hover && click .o_add_wishlist", |
| 37 |
}, |
| 38 |
{ |
| 39 |
trigger: ".my_wish_quantity:contains(1)", |
| 40 |
}, |
| 41 |
{ |
| 42 |
content: "check value of wishlist and go to login", |
| 43 |
trigger: 'a[href="/web/login"]', |
| 44 |
run: "click", |
| 45 |
expectUnloadPage: true, |
| 46 |
}, |
| 47 |
{ |
| 48 |
content: "submit login", |
| 49 |
trigger: ".oe_login_form", |
| 50 |
run: function (){ |
| 51 |
document.querySelector('.oe_login_form input[name="login"]').value = "admin"; |
| 52 |
document.querySelector('.oe_login_form input[name="password"]').value = "admin"; |
| 53 |
document.querySelector('.oe_login_form input[name="redirect"]').value = "/shop?search=Customizable Desk"; |
| 54 |
document.querySelector(".oe_login_form").submit(); |
| 55 |
}, |
| 56 |
expectUnloadPage: true, |
| 57 |
}, |
| 58 |
{ |
| 59 |
content: "check that logged in", |
| 60 |
trigger: "li span:contains('Mitchell Admin')", |
| 61 |
}, |
| 62 |
{ |
| 63 |
content: "click on Customizable Desk (TEST)", |
| 64 |
trigger: '.oe_product_cart a:contains("Customizable Desk")', |
| 65 |
run: "click", |
| 66 |
expectUnloadPage: true, |
| 67 |
}, |
| 68 |
{ |
| 69 |
content: "check the first variant is already in wishlist", |
| 70 |
trigger: '#product_detail .o_add_wishlist_dyn.disabled', |
| 71 |
}, |
| 72 |
{ |
| 73 |
trigger: "#product_detail label:contains(Aluminium) input", |
| 74 |
}, |
| 75 |
{ |
| 76 |
content: "change variant", |
| 77 |
trigger: 'label:contains(Aluminium) input', |
| 78 |
run: "click", |
| 79 |
}, |
| 80 |
{ |
| 81 |
trigger: "#product_detail .o_add_wishlist_dyn:not(.disabled)", |
| 82 |
}, |
| 83 |
{ |
| 84 |
content: "wait button enable and click on add to wishlist", |
| 85 |
trigger: '#product_detail .o_add_wishlist_dyn', |
| 86 |
run: "click", |
| 87 |
}, |
| 88 |
{ |
| 89 |
trigger: 'a[href="/shop/wishlist"] .badge:contains(2)', |
| 90 |
}, |
| 91 |
{ |
| 92 |
content: "check that wishlist contains 2 items and go to wishlist", |
| 93 |
trigger: 'a[href="/shop/wishlist"]', |
| 94 |
run: "click", |
| 95 |
expectUnloadPage: true, |
| 96 |
}, |
| 97 |
{ |
| 98 |
content: "remove Customizable Desk (TEST)", |
| 99 |
trigger: '.o_wish_rm:first', |
| 100 |
run: "click", |
| 101 |
}, |
| 102 |
{ |
| 103 |
content: "check that wishlist contains 1 item", |
| 104 |
trigger: ".my_wish_quantity:contains(1)", |
| 105 |
}, |
| 106 |
{ |
| 107 |
content: "add last item to cart", |
| 108 |
trigger: '.o_wish_add:eq(1)', |
| 109 |
run: "click", |
| 110 |
}, |
| 111 |
{ |
| 112 |
content: "Clicking on the Add to cart button", |
| 113 |
trigger: "button[name='website_sale_product_configurator_continue_button']", |
| 114 |
run: "click", |
| 115 |
expectUnloadPage: true, |
| 116 |
}, |
| 117 |
{ |
| 118 |
content: "check that user is redirect - wishlist is empty", |
| 119 |
trigger: "#wrap #cart_products", |
| 120 |
}, |
| 121 |
{ |
| 122 |
content: "check that cart contains 1 item", |
| 123 |
trigger: ".my_cart_quantity:contains(1)", |
| 124 |
}, |
| 125 |
{ |
| 126 |
content: "check that wishlist is empty and no more visible", |
| 127 |
trigger: ":not(:has(.my_wish_quantity:visible))", |
| 128 |
}, |
| 129 |
|
| 130 |
{ |
| 131 |
content: "Create a product with dynamic attribute and its values.", |
| 132 |
trigger: 'body', |
| 133 |
run: function () { |
| 134 |
rpc("/web/dataset/call_kw/product.attribute/create", { |
| 135 |
model: 'product.attribute', |
| 136 |
method: 'create', |
| 137 |
args: [{ |
| 138 |
'name': "color", |
| 139 |
'display_type': 'color', |
| 140 |
'create_variant': 'dynamic' |
| 141 |
}], |
| 142 |
kwargs: {}, |
| 143 |
}).then(function (attributeId) { |
| 144 |
return rpc("/web/dataset/call_kw/product.template/create", { |
| 145 |
model: 'product.template', |
| 146 |
method: 'create', |
| 147 |
args: [{ |
| 148 |
'name': "Bottle", |
| 149 |
'is_published': true, |
| 150 |
'attribute_line_ids': [[0, 0, { |
| 151 |
'attribute_id': attributeId, |
| 152 |
'value_ids': [ |
| 153 |
[0, 0, { |
| 154 |
'name': "red", |
| 155 |
'attribute_id': attributeId, |
| 156 |
}], |
| 157 |
[0, 0, { |
| 158 |
'name': "blue", |
| 159 |
'attribute_id': attributeId, |
| 160 |
}], |
| 161 |
[0, 0, { |
| 162 |
'name': "black", |
| 163 |
'attribute_id': attributeId, |
| 164 |
}], |
| 165 |
] |
| 166 |
}]], |
| 167 |
}], |
| 168 |
kwargs: {}, |
| 169 |
}); |
| 170 |
}).then(function () { |
| 171 |
window.location.href = '/web/session/logout?redirect=/shop?search=Bottle'; |
| 172 |
}); |
| 173 |
}, |
| 174 |
expectUnloadPage: true, |
| 175 |
}, |
| 176 |
{ |
| 177 |
trigger: '.oe_product_cart:contains("Bottle")', |
| 178 |
}, |
| 179 |
{ |
| 180 |
content: "Add Bottle to wishlist from /shop", |
| 181 |
trigger: ".oe_product_cart:contains(Bottle)", |
| 182 |
run: "hover && click .oe_product_cart:contains(Bottle) .o_add_wishlist", |
| 183 |
}, |
| 184 |
{ |
| 185 |
content: "Check that wishlist contains 1 item", |
| 186 |
trigger: '.my_wish_quantity:contains(1)', |
| 187 |
}, |
| 188 |
{ |
| 189 |
trigger: '.o_wsale_product_grid_wrapper:contains("Bottle") .o_add_wishlist.disabled', |
| 190 |
}, |
| 191 |
{ |
| 192 |
content: "Click on product", |
| 193 |
trigger: '.oe_product_cart a:contains("Bottle")', |
| 194 |
run: "click", |
| 195 |
expectUnloadPage: true, |
| 196 |
}, |
| 197 |
{ |
| 198 |
content: "Select Bottle with second variant from /product", |
| 199 |
trigger: "input.js_variant_change[data-value-name=blue]:not(:visible)", |
| 200 |
run: async (actions) => { |
| 201 |
await delay(1500); |
| 202 |
await actions.click(); |
| 203 |
}, |
| 204 |
}, |
| 205 |
{ |
| 206 |
trigger: "#product_detail .o_add_wishlist_dyn:not(.disabled)", |
| 207 |
}, |
| 208 |
{ |
| 209 |
content: "Add product in wishlist", |
| 210 |
trigger: '#product_detail .o_add_wishlist_dyn', |
| 211 |
run: "click", |
| 212 |
}, |
| 213 |
{ |
| 214 |
content: "Select Bottle with third variant from /product", |
| 215 |
trigger: "input.js_variant_change[data-value-name=black]:not(:visible)", |
| 216 |
run: async (actions) => { |
| 217 |
await delay(1500); |
| 218 |
await actions.click(); |
| 219 |
}, |
| 220 |
}, |
| 221 |
{ |
| 222 |
trigger: "#product_detail .o_add_wishlist_dyn:not(.disabled)", |
| 223 |
}, |
| 224 |
{ |
| 225 |
content: "Add product in wishlist", |
| 226 |
trigger: '#product_detail .o_add_wishlist_dyn', |
| 227 |
run: "click", |
| 228 |
}, |
| 229 |
{ |
| 230 |
content: "Check that wishlist contains 3 items and go to wishlist", |
| 231 |
trigger: '.my_wish_quantity:contains(3)', |
| 232 |
run: function () { |
| 233 |
window.location.href = '/shop/wishlist'; |
| 234 |
}, |
| 235 |
expectUnloadPage: true, |
| 236 |
}, |
| 237 |
{ |
| 238 |
content: "Check wishlist contains first variant", |
| 239 |
trigger: '#o_comparelist_table .oe_product_cart a:contains("red")', |
| 240 |
}, |
| 241 |
{ |
| 242 |
content: "Check wishlist contains second variant", |
| 243 |
trigger: '#o_comparelist_table .oe_product_cart a:contains("blue")', |
| 244 |
}, |
| 245 |
{ |
| 246 |
content: "Check wishlist contains third variant, then go to login", |
| 247 |
trigger: '#o_comparelist_table .oe_product_cart a:contains("black")', |
| 248 |
run: function () { |
| 249 |
window.location.href = "/web/login"; |
| 250 |
}, |
| 251 |
expectUnloadPage: true, |
| 252 |
}, |
| 253 |
{ |
| 254 |
content: "Submit login as admin", |
| 255 |
trigger: '.oe_login_form', |
| 256 |
run: function () { |
| 257 |
document.querySelector('.oe_login_form input[name="login"]').value = "admin"; |
| 258 |
document.querySelector('.oe_login_form input[name="password"]').value = "admin"; |
| 259 |
document.querySelector('.oe_login_form input[name="redirect"]').value = "/"; |
| 260 |
document.querySelector(".oe_login_form").submit(); |
| 261 |
}, |
| 262 |
expectUnloadPage: true, |
| 263 |
}, |
| 264 |
|
| 265 |
{ |
| 266 |
content: "Archive the first variant", |
| 267 |
trigger: 'header#top:contains("Mitchell Admin")', |
| 268 |
run: function () { |
| 269 |
rpc("/web/dataset/call_kw/product.product/search", { |
| 270 |
model: 'product.product', |
| 271 |
method: 'search', |
| 272 |
args: [[['name', '=', "Bottle"]]], |
| 273 |
kwargs: {}, |
| 274 |
}) |
| 275 |
.then(function (productIds) { |
| 276 |
return rpc("/web/dataset/call_kw/product.product/write", { |
| 277 |
model: 'product.product', |
| 278 |
method: 'write', |
| 279 |
args: [productIds[0], {active: false}], |
| 280 |
kwargs: {}, |
| 281 |
}); |
| 282 |
}) |
| 283 |
.then(function () { |
| 284 |
window.location.href = '/web/session/logout?redirect=/shop?search=Bottle'; |
| 285 |
}); |
| 286 |
}, |
| 287 |
expectUnloadPage: true, |
| 288 |
}, |
| 289 |
{ |
| 290 |
trigger: ".js_sale", |
| 291 |
}, |
| 292 |
{ |
| 293 |
content: "Check there is wishlist button on product from /shop", |
| 294 |
trigger: ".o_wsale_product_grid_wrapper:contains(Bottle) .o_add_wishlist", |
| 295 |
}, |
| 296 |
{ |
| 297 |
content: "Click on product", |
| 298 |
trigger: '.oe_product_cart a:contains("Bottle")', |
| 299 |
run: "click", |
| 300 |
expectUnloadPage: true, |
| 301 |
}, |
| 302 |
{ |
| 303 |
content: "Select Bottle with first variant (red) from /product", |
| 304 |
trigger: "input.js_variant_change[data-value-name=red]:not(:visible)", |
| 305 |
run: "click", |
| 306 |
}, |
| 307 |
{ |
| 308 |
content: "Check there is no wishlist button when selecting impossible variant", |
| 309 |
trigger: '#product_detail:not(:has(.o_add_wishlist))', |
| 310 |
}, |
| 311 |
{ |
| 312 |
content: "Select Bottle with second variant (blue) from /product", |
| 313 |
trigger: "input.js_variant_change[data-value-name=blue]:not(:visible)", |
| 314 |
run: "click", |
| 315 |
}, |
| 316 |
{ |
| 317 |
content: "Click on wishlist when selecting a possible variant from /product", |
| 318 |
trigger: '#product_detail .o_add_wishlist_dyn:not(.disabled)', |
| 319 |
run: "click", |
| 320 |
}, |
| 321 |
{ |
| 322 |
content: "Check product added to wishlist and go to login", |
| 323 |
trigger: '.my_wish_quantity:contains(1)', |
| 324 |
run: function () { |
| 325 |
window.location.href = "/web/login"; |
| 326 |
}, |
| 327 |
expectUnloadPage: true, |
| 328 |
}, |
| 329 |
{ |
| 330 |
content: "Submit login", |
| 331 |
trigger: '.oe_login_form', |
| 332 |
run: function () { |
| 333 |
document.querySelector('.oe_login_form input[name="login"]').value = "admin"; |
| 334 |
document.querySelector('.oe_login_form input[name="password"]').value = "admin"; |
| 335 |
document.querySelector('.oe_login_form input[name="redirect"]').value = "/"; |
| 336 |
document.querySelector(".oe_login_form").submit(); |
| 337 |
}, |
| 338 |
expectUnloadPage: true, |
| 339 |
}, |
| 340 |
|
| 341 |
{ |
| 342 |
content: "Archive all variants", |
| 343 |
trigger: 'header#top:contains("Mitchell Admin")', |
| 344 |
run: function () { |
| 345 |
rpc("/web/dataset/call_kw/product.product/search", { |
| 346 |
model: 'product.product', |
| 347 |
method: 'search', |
| 348 |
args: [[['name', '=', "Bottle"]]], |
| 349 |
kwargs: {}, |
| 350 |
}) |
| 351 |
.then(function (productIds) { |
| 352 |
return rpc("/web/dataset/call_kw/product.product/write", { |
| 353 |
model: 'product.product', |
| 354 |
method: 'write', |
| 355 |
args: [productIds, {active: false}], |
| 356 |
kwargs: {}, |
| 357 |
}); |
| 358 |
}) |
| 359 |
.then(function () { |
| 360 |
window.location.href = '/web/session/logout?redirect=/shop?search=Bottle'; |
| 361 |
}); |
| 362 |
}, |
| 363 |
expectUnloadPage: true, |
| 364 |
}, |
| 365 |
{ |
| 366 |
trigger: ".js_sale", |
| 367 |
}, |
| 368 |
{ |
| 369 |
content: "Check that there is no wishlist button from /shop", |
| 370 |
trigger: '.oe_product_cart:contains("Bottle"):not(:has(.o_add_wishlist))', |
| 371 |
}, |
| 372 |
{ |
| 373 |
content: "Click on product", |
| 374 |
trigger: '.oe_product_cart a:contains("Bottle")', |
| 375 |
run: "click", |
| 376 |
expectUnloadPage: true, |
| 377 |
}, |
| 378 |
{ |
| 379 |
content: "Check that there is no wishlist button from /product", |
| 380 |
trigger: '#product_detail:not(:has(.o_add_wishlist_dyn))', |
| 381 |
}, |
| 382 |
|
| 383 |
{ |
| 384 |
content: "Go to '/shop?search=Customizable Desk'", |
| 385 |
trigger: 'body', |
| 386 |
run: function () { |
| 387 |
window.location.href = '/shop?search=Customizable Desk ' |
| 388 |
}, |
| 389 |
expectUnloadPage: true, |
| 390 |
}, |
| 391 |
{ |
| 392 |
content: "Click on the product", |
| 393 |
trigger: '.oe_product_image_link img', |
| 394 |
run: "click", |
| 395 |
expectUnloadPage: true, |
| 396 |
}, |
| 397 |
{ |
| 398 |
content: "Add the product in the wishlist", |
| 399 |
trigger: '#product_option_block .o_add_wishlist_dyn', |
| 400 |
run: "click", |
| 401 |
}, |
| 402 |
{ |
| 403 |
content: "Added into the wishlist", |
| 404 |
trigger: '.my_wish_quantity.bg-primary:contains(1)', |
| 405 |
}, |
| 406 |
{ |
| 407 |
content: "Go to '/shop", |
| 408 |
trigger: 'header#top a[href="/shop"]', |
| 409 |
run: "click", |
| 410 |
expectUnloadPage: true, |
| 411 |
}, |
| 412 |
{ |
| 413 |
content: "Search the product Customizable Desk'", |
| 414 |
trigger: 'form.o_wsale_products_searchbar_form input', |
| 415 |
run: function () { |
| 416 |
document.querySelector( |
| 417 |
'form.o_wsale_products_searchbar_form input[name="search"]' |
| 418 |
).value = "Customizable Desk"; |
| 419 |
document.querySelector("form.o_wsale_products_searchbar_form button").click(); |
| 420 |
}, |
| 421 |
expectUnloadPage: true, |
| 422 |
}, |
| 423 |
{ |
| 424 |
content: "The product is in the wishlist", |
| 425 |
trigger: '.oe_product_cart .o_wsale_product_btn:has(.o_add_wishlist[disabled])', |
| 426 |
}, |
| 427 |
{ |
| 428 |
content: "Go to the wishlist", |
| 429 |
trigger: 'a[href="/shop/wishlist"]', |
| 430 |
run: "click", |
| 431 |
expectUnloadPage: true, |
| 432 |
}, |
| 433 |
{ |
| 434 |
content: "Remove the product from the wishlist", |
| 435 |
trigger: '.o_wish_rm', |
| 436 |
run: "click", |
| 437 |
}, |
| 438 |
{ |
| 439 |
content: "go back to the store", |
| 440 |
trigger: "#empty-wishlist-message a[href='/shop']", |
| 441 |
run: "click", |
| 442 |
expectUnloadPage: true, |
| 443 |
}, |
| 444 |
{ |
| 445 |
content: "Search the product Customizable Desk'", |
| 446 |
trigger: 'form.o_wsale_products_searchbar_form input', |
| 447 |
run: function () { |
| 448 |
document.querySelector( |
| 449 |
'form.o_wsale_products_searchbar_form input[name="search"]' |
| 450 |
).value = "Customizable Desk"; |
| 451 |
document.querySelector("form.o_wsale_products_searchbar_form button").click(); |
| 452 |
}, |
| 453 |
expectUnloadPage: true, |
| 454 |
}, |
| 455 |
{ |
| 456 |
content: "The product is not in the wishlist", |
| 457 |
trigger: '.oe_product_cart .o_wsale_product_btn:not(:has(.o_add_wishlist[disabled]))', |
| 458 |
}, |
| 459 |
] |
| 460 |
}); |