19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:32:12 +01:00
parent 79f83631d5
commit 73afc09215
6267 changed files with 1534193 additions and 1130106 deletions

View file

@ -0,0 +1,74 @@
import { registry } from "@web/core/registry";
import * as tourUtils from '@website_sale/js/tours/tour_utils';
registry.category("web_tour.tours").add('apply_discount_code_program_multi_rewards', {
url: '/shop?search=Super%20Chair',
steps: () => [
{
trigger: ".oe_search_found:not(:visible)",
},
{
content: 'select Super Chair',
trigger: '.oe_product_cart a:contains("Super Chair")',
run: "click",
expectUnloadPage: true,
},
{
content: 'Add Super Chair into cart',
trigger: 'a:contains(Add to cart)',
run: "click",
},
tourUtils.goToCart(),
{
trigger: "h4:contains(order summary)",
},
{
trigger: 'form[name="coupon_code"]',
},
{
content: 'insert discount code',
trigger: 'form[name="coupon_code"] input[name="promo"]',
run: "edit 12345",
},
{
content: 'validate the promo code',
trigger: 'form[name="coupon_code"] button[type="submit"]',
run: "click",
expectUnloadPage: true,
},
{
content: 'check reward',
trigger: '.alert:contains("10% on Super Chair")',
},
{
content: 'claim reward',
trigger: '.alert:contains("10% on Super Chair") .btn:contains("Claim")',
run: "click",
expectUnloadPage: true,
},
{
content: "check claimed reward",
trigger:
"#cart_products.js_cart_lines .o_cart_product h6:contains(10% on Super Chair)",
},
// Try to reapply the same promo code
{
trigger: 'form[name="coupon_code"]',
},
{
content: 'insert discount code',
trigger: 'form[name="coupon_code"] input[name="promo"]',
run: "edit 12345",
},
{
content: 'validate the promo code',
trigger: 'form[name="coupon_code"] button[type="submit"]',
run: "click",
expectUnloadPage: true,
},
{
content: 'check refused message',
trigger: '.alert-danger:contains("This promo code is already applied")',
},
],
});

View file

@ -0,0 +1,49 @@
import { registry } from "@web/core/registry";
import * as wsTourUtils from "@website_sale/js/tours/tour_utils";
registry.category("web_tour.tours").add("shop_sale_ewallet", {
url: "/shop",
steps: () => [
// Add a $50 gift card to the order
...wsTourUtils.addToCart({ productName: "TEST - Gift Card", expectUnloadPage: true }),
wsTourUtils.goToCart(),
{
trigger: 'button[name="o_loyalty_claim"]:contains("Use")',
async run(helpers) {
const rewards = document.querySelectorAll('form[name="claim_reward"]');
if (rewards.length === 1) {
await helpers.click();
} else {
console.error(`Expected 1 claimable reward, got: ${rewards.length}`);
}
},
expectUnloadPage: true,
},
{
content: "Checkout",
trigger: 'a[name="website_sale_main_button"]',
run: "click",
expectUnloadPage: true,
},
{
content: "Confirm Order",
trigger: 'button[name="o_payment_submit_button"]',
run: "click",
expectUnloadPage: true,
},
{
trigger: 'div h3:contains("Thank you for your order.")'
},
{
trigger: 'a[href="/shop/cart"]',
run: function () {
const cartQuantity = document.querySelector(".my_cart_quantity");
if (cartQuantity.textContent !== "0") {
console.error(
"cart should be empty and reset after an order is paid using ewallet"
);
}
},
},
],
});

View file

@ -1,90 +1,49 @@
/** @odoo-module **/
import { registry } from "@web/core/registry";
import * as tourUtils from "@website_sale/js/tours/tour_utils";
import tour from 'web_tour.tour';
import tourUtils from 'website_sale.tour_utils';
tour.register('shop_sale_gift_card', {
test: true,
url: '/shop?search=Small%20Drawer'
},
[
registry.category("web_tour.tours").add('shop_sale_gift_card', {
url: '/shop',
steps: () => [
// Add a small drawer to the order (50$)
{
content: 'select Small Drawer',
extra_trigger: '.oe_search_found',
trigger: '.oe_product_cart a:contains("TEST - Small Drawer")',
},
{
content: 'Add Small Drawer into cart',
trigger: 'a:contains(ADD TO CART)',
},
...tourUtils.addToCart({ productName: "TEST - Small Drawer", expectUnloadPage: true }),
tourUtils.goToCart(),
{
content: 'Click on "I have a promo code"',
extra_trigger: '#cart_products',
trigger: '.show_coupon',
},
{
content: 'insert gift card code',
trigger: 'form[name="coupon_code"] input[name="promo"]',
run: 'text GIFT_CARD'
run: "edit GIFT_CARD",
},
{
content: 'validate the gift card',
trigger: 'form[name="coupon_code"] .a-submit',
trigger: 'form[name="coupon_code"] button[type="submit"]',
run: "click",
expectUnloadPage: true,
},
{
content: 'check gift card line',
trigger: '.td-product_name:contains("PAY WITH GIFT CARD")',
trigger: "#cart_products div>h6:contains(PAY WITH GIFT CARD)",
},
{
content: 'Click on "I have a promo code"',
trigger: '.show_coupon',
},
{
content: 'insert gift card code',
extra_trigger: 'form[name="coupon_code"]',
content: "Insert promo",
trigger: 'form[name="coupon_code"] input[name="promo"]',
run: 'text 10PERCENT'
run: "edit 10PERCENT",
},
{
content: 'validate the gift card',
trigger: 'form[name="coupon_code"] .a-submit',
content: "Validate the promo",
trigger: 'form[name="coupon_code"] button[type="submit"]',
run: "click",
expectUnloadPage: true,
},
{
content: 'check gift card amount',
trigger: '.oe_currency_value:contains("-45.00")',
trigger: '.oe_website_sale .oe_cart',
run: function () {}, // it's a check
content: "Check promo",
trigger: "#cart_products div>h6:contains(10% on your order)",
},
{
content: 'go to shop',
trigger: 'a:contains("Shop")',
},
{
content: "type Gift Card in search",
trigger: 'form input[name="search"]',
run: "text Gift Card",
},
{
content: "start search",
trigger: 'form:has(input[name="search"]) .oe_search_button',
},
{
content: "select Gift Card",
extra_trigger: '.oe_search_found', // Wait to be on search results or it sometimes throws concurent error (sent search form + click on product on /shop)
trigger: '.oe_product_cart a:containsExact("TEST - Gift Card")',
},
{
content: "click on 'Add to Cart' button",
trigger: "a:contains(ADD TO CART)",
},
tourUtils.goToCart({quantity: 2}),
{
content: 'check gift card amount',
trigger: '.oe_currency_value:contains("-45.00")',
trigger: '.oe_website_sale .oe_cart',
run: function () {}, // it's a check
content: "Click on Continue Shopping",
trigger: "div.card-body a:contains(Continue shopping)",
run: "click",
expectUnloadPage: true,
},
...tourUtils.addToCart({ productName: "TEST - Gift Card", expectUnloadPage: true }),
tourUtils.goToCart({quantity: 2}),
],
);
});

View file

@ -1,70 +1,68 @@
/** @odoo-module **/
import { rpc } from "@web/core/network/rpc";
import { registry } from "@web/core/registry";
import * as tourUtils from '@website_sale/js/tours/tour_utils';
import tour from 'web_tour.tour';
import ajax from 'web.ajax';
import tourUtils from 'website_sale.tour_utils';
tour.register('shop_sale_loyalty', {
test: true,
registry.category("web_tour.tours").add('shop_sale_loyalty', {
url: '/shop?search=Small%20Cabinet',
},
[
steps: () => [
/* 1. Buy 1 Small Cabinet, enable coupon code & insert 10% code */
{
trigger: ".oe_search_found:not(:visible)",
},
{
content: "select Small Cabinet",
extra_trigger: '.oe_search_found',
trigger: '.oe_product_cart a:contains("Small Cabinet")',
run: "click",
expectUnloadPage: true,
},
{
content: "add 2 Small Cabinet into cart",
trigger: '#product_details input[name="add_qty"]',
run: "text 2",
run: "edit 2",
},
{
content: "click on 'Add to Cart' button",
trigger: "a:contains(ADD TO CART)",
trigger: "a:contains(Add to cart)",
run: "click",
},
tourUtils.goToCart({quantity: 2}),
{
content: "click on 'I have a promo code'",
extra_trigger: '.show_coupon',
trigger: '.show_coupon',
trigger: 'form[name="coupon_code"]',
},
{
content: "insert promo code 'testcode'",
extra_trigger: 'form[name="coupon_code"]',
trigger: 'form[name="coupon_code"] input[name="promo"]',
run: "text testcode",
run: "edit testcode",
},
{
content: "validate the coupon",
trigger: 'form[name="coupon_code"] .a-submit',
trigger: 'form[name="coupon_code"] button[type="submit"]',
run: "click",
expectUnloadPage: true,
},
{
content: "check reward product",
trigger: '.td-product_name:contains("10.0% discount on total amount")',
run: function () {}, // it's a check
trigger: 'div>h6:contains("10.0% discount on total amount")',
},
{
content: "check loyalty points",
trigger: '.oe_website_sale_gift_card span:contains("372.03 Points")',
run: function () {}, // it's a check
trigger: '.oe_website_sale_gift_card strong[name="o_loyalty_points"]:contains("372.03")',
},
/* 2. Add some cabinet to get a free one, play with quantity */
{
content: "go to shop",
trigger: '.td-product_name:contains("10.0% discount on total amount")',
trigger: 'div>h6:contains("10.0% discount on total amount")',
run: function () {
ajax.jsonRpc('/web/dataset/call_kw', 'call', {
rpc('/web/dataset/call_kw/account.tax/create', {
model: 'account.tax',
method: 'create',
args: [{
'name':'15% tax incl ' + _.now(),
'name':'15% tax incl ' + new Date().getTime(),
'amount': 15,
}],
kwargs: {},
}).then(function (tax_id) {
ajax.jsonRpc('/web/dataset/call_kw', 'call', {
rpc('/web/dataset/call_kw/product.template/create', {
model: 'product.template',
method: 'create',
args: [{
@ -79,73 +77,54 @@ tour.register('shop_sale_loyalty', {
});
});
},
expectUnloadPage: true,
},
{
content: "type Taxed Product in search",
trigger: 'form input[name="search"]',
run: "text Taxed Product",
},
{
content: "start search",
trigger: 'form:has(input[name="search"]) .oe_search_button',
},
{
content: "select Taxed Product",
extra_trigger: '.oe_search_found', // Wait to be on search results or it sometimes throws concurent error (sent search form + click on product on /shop)
trigger: '.oe_product_cart a:containsExact("Taxed Product")',
},
{
content: "click on 'Add to Cart' button",
trigger: "a:contains(ADD TO CART)",
},
...tourUtils.addToCart({ productName: "Taxed Product", expectUnloadPage: true }),
tourUtils.goToCart({quantity: 3}),
{
trigger: ".oe_currency_value:contains(/74.00/):not(div[name='o_cart_total'])",
},
{
content: "check reduction amount got recomputed and merged both discount lines into one only",
extra_trigger: '.oe_currency_value:contains("-74.00"):not(#cart_total .oe_currency_value:contains("-74.00"))',
trigger: '.oe_website_sale .oe_cart',
run: function () {}, // it's a check
},
/* 3. Add some cabinet to get a free one, play with quantity */
{
content: "add one Small Cabinet",
trigger: '#cart_products input.js_quantity',
run: "text 3",
run: "edit 3 && click body",
},
{
content: "check reduction amount got recomputed when changing qty",
trigger: '.oe_currency_value:contains("-106.00")',
run: function () {}, // it's a check
trigger: '.oe_currency_value:contains("- 106.00")',
},
{
content: "add more Small Cabinet into cart",
trigger: '#cart_products input.js_quantity',
run: "text 4",
run: "edit 4 && click body",
},
{
content: "check free product is added",
trigger: '#wrap:has(.td-product_name:contains("Free Product - Small Cabinet"))',
run: function () {}, // it's a check
trigger: '#wrap:has(div h6:contains("Free Product - Small Cabinet"))',
},
{
content: "remove one cabinet from cart",
trigger: '#cart_products input.js_quantity[value="4"]',
run: "text 3",
run: "edit 3 && click body",
},
{
content: "check free product is removed",
trigger: '#wrap:not(:has(.td-product_name:contains("Free Product - Small Cabinet")))',
run: function () {}, // it's a check
trigger: '#wrap:not(:has(div h6:contains("Free Product - Small Cabinet")))',
},
/* 4. Check /shop/payment does not break the `merged discount lines split per tax` (eg: with _compute_tax_id) */
/* 4. Check /shop/payment does not break the `merged discount lines split per tax` (eg: with _compute_tax_ids) */
{
content: "go to checkout",
trigger: 'a[href="/shop/checkout?express=1"]',
},
{
content: "check total is unchanged once we land on payment page",
extra_trigger: '#payment_method h3:contains("Pay with")',
trigger: 'tr#order_total .oe_currency_value:contains("967.50")',
run: function () {}, // it's a check
trigger: 'a[href="/shop/checkout?try_skip_step=true"]',
run: "click",
expectUnloadPage: true,
},
...tourUtils.assertCartAmounts({
total: '967.50',
}),
]
);
});

View file

@ -0,0 +1,131 @@
import { registry } from "@web/core/registry";
import {
addToCart,
assertCartAmounts,
confirmOrder,
goToCart,
goToCheckout,
pay,
waitForInteractionToLoad,
} from "@website_sale/js/tours/tour_utils";
function assertRewardAmounts(rewards) {
const steps = [];
const currencyValue = `.oe_currency_value:visible`;
for (const [reward, amount] of Object.entries(rewards)) {
steps.push({
content: `check if ${reward} reward is correct`,
trigger: `[data-reward-type=${reward}] ${currencyValue}:text(${amount})`,
});
}
return steps;
}
function selectDelivery(provider) {
return {
content: `select ${provider} shipping`,
trigger: `li[name=o_delivery_method]:contains(${provider}) input`,
run: "click",
};
}
const webTours = registry.category("web_tour.tours");
webTours.add("check_shipping_discount", {
url: "/shop?search=Plumbus",
steps: () => [
{
content: "select Plumbus",
trigger: '.oe_product a:contains("Plumbus")',
run: "click",
expectUnloadPage: true,
},
{
content: "add 3 Plumbus into cart",
trigger: '#product_details input[name="add_qty"]',
run: "edit 3",
},
{
content: "click on 'Add to Cart' button",
trigger: '#product_detail form #add_to_cart',
run: "click",
},
goToCart({ quantity: 3 }),
goToCheckout(),
waitForInteractionToLoad(),
selectDelivery("delivery2"),
...assertCartAmounts({
delivery: "10.00", // delivery2 is $10, ignoring shipping discount
total: "304.00", // $100 per Plumbus, plus discounted delivery
}),
...assertRewardAmounts({ shipping: "- 6.00" }),
{
content: "pay with eWallet",
trigger: "form[name=claim_reward] button[name='o_loyalty_claim']:contains('Use')",
run: "click",
expectUnloadPage: true,
},
...assertRewardAmounts({ discount: "- 304.00" }),
waitForInteractionToLoad(),
selectDelivery("delivery1"),
...assertCartAmounts({ delivery: "5.00" }),
...assertRewardAmounts({ discount: "- 300.00", shipping: "- 5.00" }),
{
content: "confirm shipping method",
trigger: ".o_total_card a[name=website_sale_main_button]",
run: "click",
expectUnloadPage: true,
},
...pay({ expectUnloadPage: true }),
],
});
webTours.add("update_shipping_after_discount", {
url: "/shop",
steps: () => [
...addToCart({ productName: "Plumbus", expectUnloadPage: true }),
goToCart(),
{
content: "use eWallet to check it doesn't impact `free_over` shipping",
trigger: "button[name='o_loyalty_claim']:contains('Use')",
run: "click",
expectUnloadPage: true,
},
{
content: "Check pay with eWallet is applied",
trigger: ".o_cart_product [name=website_sale_cart_line_price]:contains(- 100.00)",
},
goToCheckout(),
selectDelivery("delivery1"),
...assertCartAmounts({
total: "0.00", // $100 total is covered by eWallet
delivery: "0.00", // $100 is over $75 `free_over` amount, so free shipping
}),
...assertRewardAmounts({ discount: "- 100.00" }),
confirmOrder(),
{
content: "enter discount code",
trigger: "form[name=coupon_code] input[name=promo]",
run: "edit test-50pc",
},
{
content: "apply discount code",
trigger: 'form[name="coupon_code"] button[type="submit"]',
run: "click",
expectUnloadPage: true,
},
...assertCartAmounts({
total: "0.00", // $50 total is covered by eWallet
delivery: "5.00", // $50 is below $75 `free_over` amount, so no free shipping
}),
{
content: "check discount code discount doesn't apply to shipping",
trigger: '[data-reward-type=discount] .oe_currency_value:text(- 50.00)',
},
{
content: "check eWallet discount applies to shipping ($50 for Plumbus + $5 for delivery)",
trigger: '[data-reward-type=discount] .oe_currency_value:text(- 55.00)',
},
],
});

View file

@ -0,0 +1,32 @@
import { registry } from "@web/core/registry";
import * as wsTourUtils from "@website_sale/js/tours/tour_utils";
registry.category("web_tour.tours").add('shop_sale_loyalty_delivery', {
url: '/shop',
steps: () => [
...wsTourUtils.addToCart({ productName: "Plumbus", expectUnloadPage: true }),
wsTourUtils.goToCart(1),
wsTourUtils.goToCheckout(),
{
content: "select delivery method 1",
trigger: "li label:contains(delivery1)",
run: "click",
},
{
content: "Enter gift card code",
trigger: "form[name='coupon_code'] input[name='promo']",
run: "edit 123456",
},
{
content: "click on 'Apply'",
trigger: 'form[name="coupon_code"] button[type="submit"]',
run: "click",
expectUnloadPage: true,
},
wsTourUtils.confirmOrder(),
...wsTourUtils.assertCartAmounts({
total: '0.00',
delivery: '5.00'
}),
]
});