fix(e2e): address Copilot review comments from PR #7768#7775
fix(e2e): address Copilot review comments from PR #7768#7775clubanderson merged 1 commit intomainfrom
Conversation
Four issues flagged in post-merge review: 1. find-and-search.spec.ts: remove unused collectConsoleErrors import (causes TypeScript/ESLint no-unused-vars) 2. find-and-search.spec.ts: keyboard shortcut test now validates the search results dropdown (global-search-results) instead of the navbar input (global-search-input), which is always visible and gave a false pass regardless of Ctrl/Meta+K behavior 3. keyboard-navigation.spec.ts: same fix — Escape-closes-search test now checks that global-search-results becomes hidden after Escape instead of the always-visible search input 4. ux-assertions.ts: narrow the /Access-Control-Allow-Origin/i allowlist pattern to only match known demo/local origins (localhost, 127.0.0.1, kubestellar.io) to avoid masking unrelated CORS issues Fixes #7772 Signed-off-by: Andy Anderson <[email protected]>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
✅ Deploy Preview for kubestellarconsole ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
There was a problem hiding this comment.
Pull request overview
Follow-up to PR #7768 to address Copilot review feedback by cleaning up E2E tests around global search keyboard interactions and tightening console-error allowlist regexes used in Playwright UX assertions.
Changes:
- Remove an unused
collectConsoleErrorsimport infind-and-search.spec.ts. - Update global search keyboard/Escape E2E checks to use
global-search-resultsinstead of the always-visible navbar input. - Narrow the console-error allowlist regex for
Access-Control-Allow-Origininux-assertions.tsto known demo/local origins.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| web/e2e/user-flows/keyboard-navigation.spec.ts | Changes how the “Escape closes search” test detects open/closed state. |
| web/e2e/user-flows/find-and-search.spec.ts | Removes unused import; changes keyboard shortcut validation for global search. |
| web/e2e/helpers/ux-assertions.ts | Narrows the Access-Control allowlist patterns to reduce over-filtering. |
| // global-search-input is always visible in the navbar; we validate the | ||
| // shortcut by checking that the search dropdown (results panel) becomes | ||
| // visible after the keypress. | ||
| const searchResults = page.getByTestId('global-search-results') | ||
| // Try Ctrl+K (Linux/Windows CI) | ||
| await page.keyboard.press('Control+k') | ||
| const searchInput = page.getByTestId('global-search-input') | ||
| const opened = await searchInput.isVisible({ timeout: 2_000 }).catch(() => false) | ||
| if (!opened) { | ||
| const openedCtrl = await searchResults.isVisible({ timeout: 2_000 }).catch(() => false) | ||
| if (!openedCtrl) { | ||
| // Fallback: try Meta+K (Mac) | ||
| await page.keyboard.press('Meta+k') | ||
| } | ||
| await expect(searchInput).toBeVisible({ timeout: ELEMENT_VISIBLE_TIMEOUT_MS }) | ||
| await expect(searchResults).toBeVisible({ timeout: ELEMENT_VISIBLE_TIMEOUT_MS }) |
There was a problem hiding this comment.
global-search-results isn’t a reliable indicator that Ctrl/Meta+K opened global search. In SearchDropdown, the results panel only mounts when isSearchOpen && !!searchQuery.trim() (non-empty query), and the data-testid="global-search-results" node only exists when there are results (flatResults.length > 0). With an empty query after Ctrl/Meta+K, this expectation will fail even if the shortcut worked. Prefer asserting the input becomes focused (or type a known query like "cluster" after the shortcut and then assert results visible).
| // global-search-input is always visible in the navbar; track the dropdown | ||
| // results panel (global-search-results) to determine open/closed state. | ||
| const searchResults = page.getByTestId('global-search-results') | ||
|
|
||
| // Try both Ctrl+K and Meta+K to open search (platform-dependent) | ||
| await page.keyboard.press('Control+k') | ||
| const searchInput = page.getByTestId('global-search-input') | ||
| let opened = await searchInput.isVisible({ timeout: 2_000 }).catch(() => false) | ||
| let opened = await searchResults.isVisible({ timeout: 2_000 }).catch(() => false) | ||
| if (!opened) { | ||
| await page.keyboard.press('Meta+k') | ||
| opened = await searchInput.isVisible({ timeout: 2_000 }).catch(() => false) | ||
| opened = await searchResults.isVisible({ timeout: 2_000 }).catch(() => false) | ||
| } | ||
| if (!opened) { | ||
| // Fallback: click the search area directly | ||
| const searchArea = page.getByTestId('global-search') | ||
| const hasSearch = await searchArea.isVisible({ timeout: 2_000 }).catch(() => false) | ||
| if (hasSearch) { | ||
| await searchArea.click() | ||
| opened = await searchInput.isVisible({ timeout: 2_000 }).catch(() => false) | ||
| opened = await searchResults.isVisible({ timeout: 2_000 }).catch(() => false) | ||
| } | ||
| } | ||
| if (!opened) { test.skip(true, 'Could not open search via keyboard or click'); return } | ||
| if (!opened) { test.skip(true, 'Could not open search dropdown via keyboard or click'); return } | ||
|
|
||
| await page.keyboard.press('Escape') | ||
| await expect(searchInput).not.toBeVisible({ timeout: MODAL_TIMEOUT_MS }) | ||
| await expect(searchResults).not.toBeVisible({ timeout: MODAL_TIMEOUT_MS }) |
There was a problem hiding this comment.
Using global-search-results to detect whether search opened/closed is incorrect here: the results panel is only mounted when the query is non-empty, and the global-search-results test id only renders when there are actual results. As written, opened will remain false on an empty query and the test will skip (or the final assertion will be meaningless). Instead, validate open/close via focus state on global-search-input (focused after Ctrl/Meta+K/click, blurred after Escape) or type a known query before checking results visibility.
| // to avoid masking unrelated issues that mention this header. | ||
| /Access-Control-Allow-Origin.*localhost/i, | ||
| /Access-Control-Allow-Origin.*127\.0\.0\.1/i, | ||
| /Access-Control-Allow-Origin.*kubestellar\.io/i, |
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
|
Post-merge build verification passed ✅ Both Go and frontend builds compiled successfully against merge commit |
❌ Post-Merge Verification: failedCommit: |
Summary
Follow-up to PR #7768 to address 4 Copilot review comments that were flagged after merge.
Changes
1. Remove unused import (
find-and-search.spec.ts)collectConsoleErrorswas imported but not used after PR #7768 changes. Removed to fix TypeScript/ESLintno-unused-vars.2. Fix keyboard shortcut test (
find-and-search.spec.ts)The keyboard shortcut test was checking
global-search-input.isVisible()to determine if Ctrl/Meta+K worked, but that input is always visible in the navbar. Updated to checkglobal-search-results(the dropdown panel) instead — this correctly reflects whether the shortcut activated search.3. Fix Escape-closes-search test (
keyboard-navigation.spec.ts)Same root cause — the test checked
expect(searchInput).not.toBeVisible()after Escape, which always passes since the input is always visible. Updated to checkglobal-search-resultsfor both open/close detection.4. Narrow CORS allowlist regex (
ux-assertions.ts)The
/Access-Control-Allow-Origin/ipattern was too broad and would mask unrelated issues mentioning that header. Replaced with three specific patterns matching only known demo/local origins:localhost,127.0.0.1, andkubestellar.io.Test plan
npm run build)Fixes #7772