Skip to content

fix(cypress): fix cypress tests for SearchableSelect and add missing useRef import#272

Merged
prajjwalkumar17 merged 2 commits intomainfrom
fix/searchable-select-tests-useRef
Apr 29, 2026
Merged

fix(cypress): fix cypress tests for SearchableSelect and add missing useRef import#272
prajjwalkumar17 merged 2 commits intomainfrom
fix/searchable-select-tests-useRef

Conversation

@jagan-jaya
Copy link
Copy Markdown
Collaborator

@jagan-jaya jagan-jaya commented Apr 29, 2026

This PR fixes Cypress test failures caused by the new SearchableSelect component:

Changes

  • Update all Cypress tests to use click-based selection instead of cy.select()
  • Add selectSearchableOption helper function in cypress/support/euclid-helpers.js
  • Fix missing useRef import in EuclidRulesPage component (fixes ReferenceError)
  • Update SearchableSelect component styling

Testing

  • All EuclidRulesPage tests should now pass with the SearchableSelect component
  • No functional changes to the UI, only test and import fixes
`just cypress-parallel`

[worker-3]   (Run Finished)
[worker-3] 
[worker-3] 
[worker-3]        Spec                                              Tests  Passing  Failing  Pending  Skipped  
[worker-3]   ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
[worker-3]   │ ✔  ui/euclid-rules-nested-branches.cy.      00:11       11       11        -        -        - │
[worker-3]   │    js                                                                                          │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  ui/euclid-rules-volume-split-priori      00:14        9        9        -        -        - │
[worker-3]   │    ty.cy.js                                                                                    │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  ui/euclid-rules-volume-split.cy.js       00:14        8        8        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  ui/analytics-page.cy.js                  00:03        1        1        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  ui/auth-page.cy.js                       00:06        3        3        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  ui/dashboard-overview.cy.js              00:06        1        1        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  ui/debit-routing-page.cy.js              00:02        1        1        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  ui/decision-explorer.cy.js               00:08        5        5        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  ui/payment-audit.cy.js                   00:08        1        1        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  ui/volume-split-page.cy.js               00:03        1        1        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  api/analytics-api.cy.js                  00:04        1        1        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  api/dynamic-routing.cy.js                00:05        1        1        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  api/merchant-crud.cy.js                  356ms        2        2        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  api/routing-mutation.cy.js               196ms        1        1        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  api/rule-configs.cy.js                   261ms        2        2        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  api/rule-routing-advanced.cy.js          243ms        2        2        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  api/rule-routing-priority.cy.js          166ms        1        1        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  api/rule-routing-single.cy.js            176ms        1        1        -        -        - │
[worker-3]   ├────────────────────────────────────────────────────────────────────────────────────────────────┤
[worker-3]   │ ✔  api/volume-split.cy.js                   00:01        1        1        -        -        - │
[worker-3]   └────────────────────────────────────────────────────────────────────────────────────────────────┘
[worker-3]     ✔  All specs passed!                        01:30       53       53        -        -        -  
[worker-3] 

- Update all Cypress tests to use click-based selection instead of cy.select()
- Add selectSearchableOption helper function to support custom dropdowns
- Fix missing useRef import in EuclidRulesPage component
- Update SearchableSelect component button selectors
Copilot AI review requested due to automatic review settings April 29, 2026 12:33
@jagan-jaya jagan-jaya changed the title Fix Cypress tests for SearchableSelect and add missing useRef import fix(cypress): fix cypress tests for SearchableSelect and add missing useRef import Apr 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Euclid Rules Cypress tests to work with the new SearchableSelect (button + searchable dropdown) instead of native <select>, and fixes a missing React hook import that caused a runtime error.

Changes:

  • Added data-cy/data-value hooks to SearchableSelect usage to support reliable Cypress selection/assertions.
  • Introduced Cypress helper functions for interacting with SearchableSelect, and migrated affected Euclid rules specs away from cy.select().
  • Updated a few UI-copy assertions in other Cypress specs to match current UI messages; added an aria-label for the condition remove button.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
website/src/components/ui/SearchableSelect.tsx Adds dataCy support and exposes selected value via data-value for test assertions.
website/src/components/pages/EuclidRulesPage.tsx Fixes missing useRef import; adds dataCy props to condition LHS/value selects; adds accessible label for remove button.
cypress/support/euclid-helpers.js Adds new Cypress helpers for selecting LHS/value via SearchableSelect.
cypress/e2e/ui/euclid-rules-nested-branches.cy.js Migrates LHS selection/assertions to the new helpers and data-value attribute.
cypress/e2e/ui/euclid-rules-lifecycle.cy.js Migrates LHS/value selection to helpers while keeping operator selection via native <select>.
cypress/e2e/ui/euclid-rules-enum-operators.cy.js Adjusts operator/value assertions for SearchableSelect and checkbox-based multi-select mode.
cypress/e2e/ui/euclid-rules-e2e.cy.js Updates end-to-end rule creation flows to use new selection helpers.
cypress/e2e/ui/euclid-rules-builder.cy.js Updates UI interaction assertions and remove-condition action for the new DOM structure.
cypress/e2e/ui/decision-explorer.cy.js Updates assertions for debit-routing enabled/disabled copy.
cypress/e2e/ui/debit-routing-page.cy.js Updates success-message assertions for debit-routing enable/disable copy.
cypress/e2e/ui/auth-page.cy.js Updates assertion for updated Auth page hero heading text.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +98 to +103
function selectCondLhs(index, value) {
cy.get('[data-cy="cond-lhs"]').eq(index).within(() => {
cy.get('button.cond-select').click()
cy.get('input[placeholder="Search…"]').clear().type(value)
cy.get('button:not(.cond-select)').first().click()
})
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

selectCondLhs (and selectCondVal) always clicks the first result button after typing. If the search term matches multiple options (common with prefix keys), this can select the wrong value and make tests flaky. Prefer selecting the option deterministically (e.g., by exact match) or add a stable attribute (like data-value) on option buttons and click by that.

Copilot uses AI. Check for mistakes.
Comment on lines +98 to +118
function selectCondLhs(index, value) {
cy.get('[data-cy="cond-lhs"]').eq(index).within(() => {
cy.get('button.cond-select').click()
cy.get('input[placeholder="Search…"]').clear().type(value)
cy.get('button:not(.cond-select)').first().click()
})
}

/**
* Select an enum value from the SearchableSelect value dropdown.
* Works inside or outside a cy.within() scope.
* @param {number} index - 0-based index of cond-val within current scope
* @param {string} value - enum value to search and select (e.g. 'card')
*/
function selectCondVal(index, value) {
cy.get('[data-cy="cond-val"]').eq(index).within(() => {
cy.get('button.cond-select').click()
cy.get('input[placeholder="Search…"]').clear().type(value)
cy.get('button:not(.cond-select)').first().click()
})
}
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

selectCondLhs and selectCondVal are effectively identical apart from the [data-cy=...] selector. Consider extracting a single generic helper (e.g., taking the data-cy value) and reusing it for both to reduce duplication and keep future updates consistent.

Copilot uses AI. Check for mistakes.
Comment on lines +92 to +104
/**
* Select a routing-key (LHS) from the SearchableSelect dropdown.
* Works inside or outside a cy.within() scope.
* @param {number} index - 0-based index of cond-lhs within current scope
* @param {string} value - routing key value to search and select (e.g. 'payment_method')
*/
function selectCondLhs(index, value) {
cy.get('[data-cy="cond-lhs"]').eq(index).within(() => {
cy.get('button.cond-select').click()
cy.get('input[placeholder="Search…"]').clear().type(value)
cy.get('button:not(.cond-select)').first().click()
})
}
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

The PR description says it adds a selectSearchableOption Cypress helper, but the code adds selectCondLhs / selectCondVal instead. Either update the PR description or rename/extract to match the described helper so future readers can find it easily.

Copilot uses AI. Check for mistakes.
@jagan-jaya jagan-jaya self-assigned this Apr 29, 2026
@prajjwalkumar17 prajjwalkumar17 merged commit c431542 into main Apr 29, 2026
17 checks passed
@prajjwalkumar17 prajjwalkumar17 deleted the fix/searchable-select-tests-useRef branch April 29, 2026 13:02
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.

3 participants