Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][FIX] website_sale: non deterministic test failures #159387

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,37 @@ registry.category("web_tour.tours").add('tour_shop_archived_variant_multi', {
trigger: 'input[data-attribute_name="Color"][data-value_name="Black"]',
},
{
content: "Check that brand b is not available and select it",
trigger: '.css_not_available input[data-attribute_name="Brand"][data-value_name="Brand B"]',
content: "Check that brand b is not available",
trigger: '.css_not_available',
isCheck: true,
},
{
content: "select brand b even though it's not available",
trigger: 'input[data-attribute_name="Brand"][data-value_name="Brand B"]',
},
{
content: "check combination is not possible",
trigger: '.js_main_product.css_not_available .css_not_available_msg:contains("This combination does not exist.")'
trigger: '.js_main_product.css_not_available .css_not_available_msg:contains("This combination does not exist.")',
isCheck: true,
},
{
content: "check add to cart not possible",
trigger: '#add_to_cart.disabled',
run: function () {},
isCheck: true,
},
{
content: "change second variant to remove warning",
trigger: 'input[data-attribute_name="Color"][data-value_name="White"]',
},
{
content: "Check that brand b is not available",
trigger: '.css_not_available',
isCheck: true,
},
{
content: "Check that second variant is disabled",
trigger: '.css_not_available input[data-attribute_name="Color"][data-value_name="Black"]',
run: function () {},
isCheck: true,
},
]});

Expand Down
106 changes: 53 additions & 53 deletions addons/website_sale/tests/test_customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import base64

from odoo.addons.base.tests.common import HttpCaseWithUserDemo, HttpCaseWithUserPortal
from odoo.fields import Command
from odoo.tests import tagged
from odoo.tools.misc import file_open


from odoo.addons.base.tests.common import HttpCaseWithUserDemo, HttpCaseWithUserPortal


@tagged('post_install', '-at_install')
class TestUi(HttpCaseWithUserDemo, HttpCaseWithUserPortal):

Expand Down Expand Up @@ -333,74 +335,72 @@ def test_08_portal_tour_archived_variant_multiple_attributes(self):
{
'name': 'Size',
'create_variant': 'always',
'value_ids': [
Command.create({
'name': 'Large',
'sequence': 1,
}),
Command.create({
'name': 'Small',
'sequence': 2,
}),
],
},
{
'name': 'Color',
'create_variant': 'always',
'value_ids': [
Command.create({
'name': 'White',
'sequence': 1,
}),
Command.create({
'name': 'Black',
'sequence': 2,
}),
],
},
{
'name': 'Brand',
'create_variant': 'always',
},
])

attribute_values = self.env['product.attribute.value'].create([
{
'name': 'Large',
'attribute_id': attribute_1.id,
'sequence': 1,
},
{
'name': 'Small',
'attribute_id': attribute_1.id,
'sequence': 2,
},
{
'name': 'White',
'attribute_id': attribute_2.id,
'sequence': 1,
},
{
'name': 'Black',
'attribute_id': attribute_2.id,
'sequence': 2,
},
{
'name': 'Brand A',
'attribute_id': attribute_3.id,
'sequence': 1,
},
{
'name': 'Brand B',
'attribute_id': attribute_3.id,
'sequence': 2,
'value_ids': [
Command.create({
'name': 'Brand A',
'sequence': 1,
}),
Command.create({
'name': 'Brand B',
'sequence': 2,
}),
],
},
])

product_template = self.env['product.template'].create({
'name': 'Test Product 2',
'is_published': True,
'attribute_line_ids': [
Command.create({
'attribute_id': attribute_1.id,
'value_ids': [Command.set(attribute_1.value_ids.ids)],
}),
Command.create({
'attribute_id': attribute_2.id,
'value_ids': [Command.set(attribute_2.value_ids.ids)],
}),
Command.create({
'attribute_id': attribute_3.id,
'value_ids': [Command.set(attribute_3.value_ids.ids)],
}),
]
})

self.env['product.template.attribute.line'].create([
{
'attribute_id': attribute_1.id,
'product_tmpl_id': product_template.id,
'value_ids': [(6, 0, attribute_values.filtered(lambda v: v.attribute_id == attribute_1).ids)],
},
{
'attribute_id': attribute_2.id,
'product_tmpl_id': product_template.id,
'value_ids': [(6, 0, attribute_values.filtered(lambda v: v.attribute_id == attribute_2).ids)],
},
{
'attribute_id': attribute_3.id,
'product_tmpl_id': product_template.id,
'value_ids': [(6, 0, attribute_values.filtered(lambda v: v.attribute_id == attribute_3).ids)],
},
])

product_template.product_variant_ids[-1].active = False
# Archive (Small, Black, Brand B) variant
product_template._get_variant_for_combination(
product_template.attribute_line_ids.product_template_value_ids.filtered(
lambda ptav: ptav.product_attribute_value_id.sequence == 2
)
).action_archive()

self.start_tour("/", 'tour_shop_archived_variant_multi', login="portal")

Expand Down