Skip to content

Fix: Correct free gift selectors for develop version#981

Closed
mattgoud wants to merge 1 commit into
PrestaShop:mainfrom
mattgoud:fix/discount-free-gift-selectors-develop
Closed

Fix: Correct free gift selectors for develop version#981
mattgoud wants to merge 1 commit into
PrestaShop:mainfrom
mattgoud:fix/discount-free-gift-selectors-develop

Conversation

@mattgoud
Copy link
Copy Markdown
Contributor

@mattgoud mattgoud commented May 26, 2026

Problem

The selectors for the free gift product search in the develop version page object were wrong since PR #972.

The _product_ segment was added to the IDs but it does not exist in the rendered HTML. The Symfony form field is named free_gift directly under the root discount form:

// DiscountType.php
->add('free_gift', ProductSearchType::class, [...])

Which generates these IDs:

  • Container: #discount_free_gift
  • Search input: #discount_free_gift_search_input
  • List: #discount_free_gift_list

Root cause

The _product_ suffix was a confusion with the specific_products pattern which IS genuinely nested under discount_conditions_product_ (a different sub-form). The free_gift field has no such nesting.

The bug was masked until commit 96815717be6 in PrestaShop fixed the test data from discountType: 'Free gift' to discountType: 'free_gift' — this activated the code path that calls setValue() on the broken selector.

Fix

Revert the 3 selectors introduced in PR #972 to their correct values (matching the 9.1 version).

After merge

tests/UI/package.json in the PrestaShop repository already points to #main:

"@prestashop-core/ui-testing": "https://github.com/PrestaShop/ui-testing-library#main"

There is no version bump to do. Once this PR is merged, a npm install run in tests/UI/ is enough to regenerate package-lock.json with the new commit SHA, and a dedicated PR must be opened in the PrestaShop repository to commit the updated package-lock.json.

The selectors introduced in PR PrestaShop#972 were wrong: the _product_ segment
does not exist in the generated HTML ids. The Symfony form field is
named 'free_gift' directly under the root 'discount' form, so the
rendered ids are:
  - #discount_free_gift_search_input (not _product_search_input)
  - #discount_free_gift_list         (not _product_list)
  - #discount_free_gift_{row}        (not _product_{row})

The _product_ suffix was a confusion with the specific_products pattern
which is genuinely nested under discount_conditions_product_.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-project-automation github-project-automation Bot moved this to Ready for review in PR Dashboard May 26, 2026
@Progi1984 Progi1984 closed this May 26, 2026
@github-project-automation github-project-automation Bot moved this from Ready for review to Closed in PR Dashboard May 26, 2026
@Progi1984
Copy link
Copy Markdown
Member

No need : we wait the PR of @nicosomb to be Merged.

@mattgoud
Copy link
Copy Markdown
Contributor Author

No need : we wait the PR of @nicosomb to be Merged.

ah ok ! thanks for the info @Progi1984

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

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

3 participants