From 9ccc7ed1ef849c3c4515c6a0ae86acf25b23bc48 Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Mon, 4 Nov 2019 16:56:38 +0100 Subject: [PATCH] [IMP] website_sale_wishlist: Adapt tests to work with/without demo data --- .../tests/tours/website_sale_wishlist.js | 12 ++--- .../tests/test_wishlist_process.py | 54 +++++++++++++++++++ 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/addons/website_sale_wishlist/static/tests/tours/website_sale_wishlist.js b/addons/website_sale_wishlist/static/tests/tours/website_sale_wishlist.js index 935efb39ef2..ab9193608b1 100644 --- a/addons/website_sale_wishlist/static/tests/tours/website_sale_wishlist.js +++ b/addons/website_sale_wishlist/static/tests/tours/website_sale_wishlist.js @@ -6,7 +6,7 @@ var tour = require("web_tour.tour"); tour.register('shop_wishlist', { test: true, - url: '/shop', + url: '/shop?search=Customizable Desk', }, [ { @@ -41,7 +41,7 @@ tour.register('shop_wishlist', { run: function (){ $('.oe_login_form input[name="login"]').val("admin"); $('.oe_login_form input[name="password"]').val("admin"); - $('.oe_login_form input[name="redirect"]').val("/shop"); + $('.oe_login_form input[name="redirect"]').val("/shop?search=Customizable Desk"); $('.oe_login_form').submit(); }, }, @@ -51,8 +51,8 @@ tour.register('shop_wishlist', { run: function () {}, }, { - content: "click on Customizable Desk", - trigger: '.oe_product_cart a:contains("Customizable Desk")', + content: "click on Customizable Desk (TEST)", + trigger: '.oe_product_cart a:contains("Customizable Desk (TEST)")', }, { content: "check the first variant is already in wishlist", @@ -75,8 +75,8 @@ tour.register('shop_wishlist', { trigger: 'a[href="/shop/wishlist"]', }, { - content: "remove Customizable Desk", - trigger: 'tr:contains("Customizable Desk") .o_wish_rm:first', + content: "remove Customizable Desk (TEST)", + trigger: 'tr:contains("Customizable Desk (TEST)") .o_wish_rm:first', }, { content: "check that wishlist contains 1 item", diff --git a/addons/website_sale_wishlist/tests/test_wishlist_process.py b/addons/website_sale_wishlist/tests/test_wishlist_process.py index c9d487af8cf..dc995eda45e 100644 --- a/addons/website_sale_wishlist/tests/test_wishlist_process.py +++ b/addons/website_sale_wishlist/tests/test_wishlist_process.py @@ -6,4 +6,58 @@ import odoo.tests @odoo.tests.tagged('-at_install', 'post_install') class TestUi(odoo.tests.HttpCase): def test_01_wishlist_tour(self): + + self.env['product.template'].search([]).write({'website_published': False}) + # Setup attributes and attributes values + self.product_attribute_1 = self.env['product.attribute'].create({ + 'name': 'Legs', + 'sequence': 10, + }) + product_attribute_value_1 = self.env['product.attribute.value'].create({ + 'name': 'Steel', + 'attribute_id': self.product_attribute_1.id, + 'sequence': 1, + }) + product_attribute_value_2 = self.env['product.attribute.value'].create({ + 'name': 'Aluminium', + 'attribute_id': self.product_attribute_1.id, + 'sequence': 2, + }) + product_attribute_2 = self.env['product.attribute'].create({ + 'name': 'Color', + 'sequence': 20, + }) + product_attribute_value_3 = self.env['product.attribute.value'].create({ + 'name': 'White', + 'attribute_id': product_attribute_2.id, + 'sequence': 1, + }) + product_attribute_value_4 = self.env['product.attribute.value'].create({ + 'name': 'Black', + 'attribute_id': product_attribute_2.id, + 'sequence': 2, + }) + + # Create product template + self.product_product_4_product_template = self.env['product.template'].create({ + 'name': 'Customizable Desk (TEST)', + 'standard_price': 500.0, + 'list_price': 750.0, + 'website_published': True, + }) + + # Generate variants + self.env['product.template.attribute.line'].create([{ + 'product_tmpl_id': self.product_product_4_product_template.id, + 'attribute_id': self.product_attribute_1.id, + 'value_ids': [(4, product_attribute_value_1.id), (4, product_attribute_value_2.id)], + }, { + 'product_tmpl_id': self.product_product_4_product_template.id, + 'attribute_id': product_attribute_2.id, + 'value_ids': [(4, product_attribute_value_3.id), (4, product_attribute_value_4.id)], + + }]) + + self.env.ref('base.user_admin').name = 'Mitchell Admin' + self.start_tour("/", 'shop_wishlist')