Skip to content

Comments

[FIX] website_sale_require_legal: fix race condition in UI tour test#1170

Open
Kimkhoi3010 wants to merge 1 commit intoOCA:16.0from
Kimkhoi3010:16.0-fix-website_sale_require_legal
Open

[FIX] website_sale_require_legal: fix race condition in UI tour test#1170
Kimkhoi3010 wants to merge 1 commit intoOCA:16.0from
Kimkhoi3010:16.0-fix-website_sale_require_legal

Conversation

@Kimkhoi3010
Copy link

@Kimkhoi3010 Kimkhoi3010 commented Feb 25, 2026

Context

  • Fix a race condition in the UI tour test that caused intermittent failures when sale_loyalty is installed alongside website_sale_require_legal.
  • The Odoo payment widget (web.assets_frontend_lazy) initializes asynchronously. The submit button starts as disabled="true" in the HTML template and is only enabled by the widget's _enableButton() after async initialization completes.
  • The Tour Manager can become ready before the payment widget finishes initializing. When the tour clicked button[name="o_payment_submit_button"] while it was still disabled, no event handler fired, no AJAX was sent to /shop/payment/transaction, and the browser never navigated — causing the final form.oe_product_cart step to time out.
  • The presence of sale_loyalty adds enough overhead during page load to make this timing window consistently reproducible.

Changes

  • static/tests/tours/tour.js:
    • Add a final tour step waiting for form.oe_product_cart on the shop page, ensuring the AJAX call has completed before the tour ends.
  • tests/test_ui.py:
    • Change the dummy provider's redirect form to action="/shop/payment/validate" so the browser navigates to /shop only after the AJAX response is received.

Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't use self.env["loyalty.program"] in a module that don't depend on the module adding that model, so you have to find another solution.

@pedrobaeza pedrobaeza added this to the 16.0 milestone Feb 25, 2026
@Kimkhoi3010 Kimkhoi3010 marked this pull request as draft February 25, 2026 07:31
@Kimkhoi3010 Kimkhoi3010 force-pushed the 16.0-fix-website_sale_require_legal branch from 3c86591 to 876ab5a Compare February 25, 2026 08:43
@Kimkhoi3010 Kimkhoi3010 marked this pull request as ready for review February 25, 2026 08:50
@Kimkhoi3010
Copy link
Author

You can't use self.env["loyalty.program"] in a module that don't depend on the module adding that model, so you have to find another solution.

Hi @pedrobaeza, I have updated the PR. Thanks for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants