Skip to content

Commit

Permalink
[FIX] website_sale: non deterministic test failures
Browse files Browse the repository at this point in the history
Wild try to avoid failures on runbot builds (not reproducible locally).

* simplify and split tour steps
* correctly specify check steps as isCheck: true
* make sure python setup is deterministic
  * batch template creation to avoid creation of dummy archived variant
  * target values for the variant to archive instead of its number in the
  list of variants

runbot build error 25046

closes #159270

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
  • Loading branch information
Feyensv committed Mar 26, 2024
1 parent 78315ae commit 9906785
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 58 deletions.
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,11 +2,13 @@

import base64

from odoo.addons.base.tests.common import HttpCaseWithUserDemo, HttpCaseWithUserPortal
from odoo.fields import Command
from odoo.modules.module import get_module_resource
from odoo.tests import tagged

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

0 comments on commit 9906785

Please sign in to comment.