Repository navigation
fix(pci-project): map voucher eligibility errors to existing translation keys - #23361
Closed
AdrienPensart wants to merge 1 commit into
Closed
AdrienPensart wants to merge 1 commit into
AdrienPensart wants to merge 1 commit into
Conversation
…ion keys Signed-off-by: Adrien Pensart <adrien.pensart@corp.ovh.com>
AdrienPensart
requested review from
ErikssonJoakim,
Tsiorifamonjena,
aTurmo,
fredericvilcot and
lolottetheclash
and
a balanced review from Copilot
November 25, 2026 19:26
Copilot stopped reviewing on behalf of
AdrienPensart due to an error
November 25, 2026 19:26
Copilot stopped reviewing on behalf of
AdrienPensart due to an error
November 25, 2026 19:27
Contributor
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Copilot review overview
No open issues 🎉
What changed in this PR
Updates voucher eligibility error parsing to produce correct i18n translation keys, and strengthens test coverage around error-to-translation mapping.
Changes:
- Adjusted the error-code regex to avoid including the
VOUCHER_prefix in the extracted code portion. - Reworked voucher eligibility error tests into a parameterized table covering multiple message formats and fallbacks.
| File | Description |
|---|---|
| packages/manager/apps/pci-project/src/pages/creation/hooks/useVoucher.tsx | Fixes voucher error-code extraction so translation keys don’t contain a duplicated voucher_ segment. |
| packages/manager/apps/pci-project/src/pages/creation/hooks/__tests__/UseVoucher.spec.tsx | Adds broader, table-driven coverage for mapping eligibility error messages to translation keys. |
Review effort: Lite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix in useVoucher.tsx:92: the regex changed from /(VOUCHER_\w+)/i to /VOUCHER_(\w+)/i, so the VOUCHER_ prefix is no longer part of the captured code. VOUCHER_EXPIRED now gives pci_projects_new_voucher_form_field_error_voucher_expired, which exists in the translation file.
Tests in UseVoucher.spec.tsx: I replaced the two old error tests with one it.each. Each case goes through checkEligibility and checks the exact key:
VOUCHER_INVALID gives ..._voucher_invalid
VOUCHER_EXPIRED gives ..._voucher_expired
VOUCHER_ALREADY_USED_2 gives ..._voucher_already_used_2
Voucher rejected: VOUCHER_COUNTRY gives ..._voucher_country
Internal error falls back to ..._voucher_invalid
The old "specific codes" test called setError with the hand-built key instead of going through the hook, so it could never catch this bug.
An API code that isn't in the translation file, for example VOUCHER_FOO, still shows the raw key. The file has a pci_projects_new_voucher_form_field_error_default key that could cover that case. I left it alone to keep the fix small.
Description
Ticket Reference: #...
Additional Information