[IMP] website_sale: add tour for snippet products
This PR added new templates and features to the dynamic snippet products. The goal of this commit is to test these features by selecting every newly made template, saving, and adding a product to the cart. Another tour was added to test the functionality of the recently viewed product filter. task-2677203 Part-of: odoo/odoo#80128
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import wTourUtils from 'website.tour_utils';
|
||||
import wSaleTourUtils from 'website_sale.tour_utils';
|
||||
|
||||
const optionBlock = 'dynamic_snippet_products';
|
||||
const productsSnippet = {id: 's_dynamic_snippet_products', name: 'Products'};
|
||||
const templates = [
|
||||
"dynamic_filter_template_product_product_add_to_cart",
|
||||
"dynamic_filter_template_product_product_view_detail",
|
||||
"dynamic_filter_template_product_product_mini_image",
|
||||
"dynamic_filter_template_product_product_mini_price",
|
||||
"dynamic_filter_template_product_product_mini_name",
|
||||
"dynamic_filter_template_product_product_centered",
|
||||
"dynamic_filter_template_product_product_borderless_1",
|
||||
"dynamic_filter_template_product_product_borderless_2",
|
||||
"dynamic_filter_template_product_product_banner",
|
||||
"dynamic_filter_template_product_product_horizontal_card",
|
||||
"dynamic_filter_template_product_product_horizontal_card_2",
|
||||
"dynamic_filter_template_product_product_card_group",
|
||||
];
|
||||
|
||||
function changeTemplate(templateKey) {
|
||||
const templateClass = templateKey.replace(/dynamic_filter_template_/, "s_");
|
||||
return [
|
||||
wTourUtils.changeOption(optionBlock, 'we-select[data-name="template_opt"] we-toggler', 'template'),
|
||||
wTourUtils.changeOption(optionBlock, `we-button[data-select-data-attribute="website_sale.${templateKey}"]`),
|
||||
{
|
||||
content: 'Check the template is applied',
|
||||
trigger: `iframe .s_dynamic_snippet_products.${templateClass} .carousel`,
|
||||
run: () => null, // It's a check
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
let templatesSteps = [];
|
||||
for (const templateKey of templates) {
|
||||
templatesSteps = templatesSteps.concat(changeTemplate(templateKey));
|
||||
}
|
||||
wTourUtils.registerWebsitePreviewTour('website_sale.snippet_products', {
|
||||
test: true,
|
||||
url: '/',
|
||||
edition: true,
|
||||
},
|
||||
[
|
||||
wTourUtils.dragNDrop(productsSnippet),
|
||||
wTourUtils.clickOnSnippet(productsSnippet),
|
||||
...templatesSteps,
|
||||
...changeTemplate('dynamic_filter_template_product_product_add_to_cart'),
|
||||
...wTourUtils.clickOnSave(),
|
||||
{
|
||||
trigger: "iframe .s_dynamic_snippet_products .o_carousel_product_card_body .js_add_cart",
|
||||
run: 'click',
|
||||
},
|
||||
wSaleTourUtils.goToCart({backend: true}),
|
||||
]);
|
||||
|
||||
wTourUtils.registerWebsitePreviewTour('website_sale.products_snippet_recently_viewed', {
|
||||
test: true,
|
||||
url: '/',
|
||||
edition: true,
|
||||
},
|
||||
[
|
||||
wTourUtils.dragNDrop(productsSnippet),
|
||||
wTourUtils.clickOnSnippet(productsSnippet),
|
||||
wTourUtils.changeOption(optionBlock, 'we-select[data-name="filter_opt"] we-toggler', 'filter'),
|
||||
wTourUtils.changeOption(optionBlock, 'we-select[data-name="filter_opt"] we-button:contains("Recently Viewed")', 'filter'),
|
||||
...changeTemplate('dynamic_filter_template_product_product_add_to_cart'),
|
||||
...wTourUtils.clickOnSave(),
|
||||
{
|
||||
content: 'make delete icon appear',
|
||||
trigger: 'iframe .s_dynamic_snippet_products .o_carousel_product_card',
|
||||
run: function () {
|
||||
const $iframe = $('.o_iframe').contents();
|
||||
const $productCard = $iframe.find('.o_carousel_product_card:has(a img[alt="Storage Box"])');
|
||||
console.log($productCard);
|
||||
$productCard.find('.js_remove').attr('style', 'display: block;');
|
||||
}
|
||||
},
|
||||
{
|
||||
trigger: 'iframe .s_dynamic_snippet_products .o_carousel_product_card .js_remove',
|
||||
run: 'click',
|
||||
},
|
||||
]);
|
||||
@@ -21,3 +21,4 @@ from . import test_website_sale_product
|
||||
from . import test_website_sale_shop_variant_exclusion
|
||||
from . import test_website_editor
|
||||
from . import test_website_sale_reorder_from_portal
|
||||
from . import test_website_sale_snippets
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo.tests import HttpCase, tagged
|
||||
from odoo.addons.website.tools import MockRequest
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install', 'website_snippets')
|
||||
class TestSnippets(HttpCase):
|
||||
|
||||
def test_01_snippet_products_edition(self):
|
||||
self.start_tour('/', 'website_sale.snippet_products', login='admin')
|
||||
|
||||
def test_02_snippet_products_remove(self):
|
||||
self.user = self.env['res.users'].search([('login', '=', 'admin')])
|
||||
self.website_visitor = self.env['website.visitor'].search([('partner_id', '=', self.user.partner_id.id)])
|
||||
before_tour_product_ids = self.website_visitor.product_ids.ids
|
||||
with MockRequest(self.env, website=self.env['website'].get_current_website()):
|
||||
if not self.website_visitor:
|
||||
self.website_visitor = self.env['website.visitor'].create({'partner_id': self.user.partner_id.id})
|
||||
self.product = self.env['product.product'].create({
|
||||
'name': 'Storage Box',
|
||||
'website_published': True,
|
||||
'image_512': b'/product/static/img/product_product_9-image.jpg',
|
||||
'display_name': 'Bin',
|
||||
'description_sale': 'Pedal-based opening system',
|
||||
})
|
||||
self.website_visitor._add_viewed_product(self.product.id)
|
||||
self.start_tour('/', 'website_sale.products_snippet_recently_viewed', login='admin')
|
||||
after_tour_product_ids = self.website_visitor.product_ids.ids
|
||||
self.assertEqual(before_tour_product_ids, after_tour_product_ids, "There shouldn't be any new product in recently viewed after this tour")
|
||||
Reference in New Issue
Block a user