Skip to content

setShop saves the shop while the category tree is reloading #1129

Description

@mattgoud

Part of PrestaShop/PrestaShop#43198 (audit of intermittent UI and Behat test failures).

Failing test

Suite File Test Failure
UI tests/UI/campaigns/functional/BO/14_advancedParameters/10_multistore/08_multistoreOptions.ts (PrestaShop) BO - Advanced Parameters - Multistore : Multistore options > PRE-TEST : Create new store and set URL > should create shop page.waitForSelector: Timeout 10000ms exceeded (div.alert.alert-success)

Bug

"BO - Advanced Parameters - Multistore : Multistore options" fails intermittently on "should create shop":

page.waitForSelector: Timeout 10000ms exceeded.
  - waiting for locator('div.alert.alert-success') to be visible

The failure screenshot shows the error "You need to select at least the root category." and the form displayed again: the shop was not created.

Cause

  • setShop (src/versions/develop/pages/BO/advancedParameters/multistore/shop/create.ts:66) selects the root category with selectByVisibleText(page, '#id_category', ...) (:72) even when it is already selected. That fires change.
  • Each change on #id_category reloads the category tree by ajax and replaces it. The new checkboxes are checked afterwards by JavaScript.
  • The save button is clicked right away (:80). When the click lands after the tree was replaced but before its boxes are checked, the form is posted without categoryBox[] and the controller rejects it.

A longer timeout would not help: the shop creation never starts.

Suggested fix

In setShop, change the root category only when it differs from the current one; otherwise, or after changing it, wait for the tree ajax request to finish and for #categories-tree input[name="categoryBox[]"]:checked before saving.

Activity

  1. added theissue type on Oct 9, 2026
  2. mattgoud commented on Oct 19, 2026

    @mattgoud
    ContributorAuthor

    Seen again on a 9.2.x run, same "You need to select at least the root category" signature, on several campaigns that share setShop:

    • 04_filterSortAndPaginationShops.ts > Create 19 shops > should create shop n°6 / n°10 / n°12 / n°18 (different index on each attempt)
    • 03_CRUDShops.ts > Update shop > should edit shop and check result
    • 08_multistoreOptions.ts > PRE-TEST > should create shop (reported above)

    setShop is also used by 07_editUrlOptions.ts, 03_catalog/01_products/20_multistore.ts, 37_psgdpr/02_configuration/07_multistore.ts and 06_patchProductIdShops.ts. The 19-shop loop in 04 makes the race close to certain on a slow runner. The fix stays in setShop, no campaign change needed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions