Skip to content

Commit aab42e6

Browse files
sadpandajoeclaude
andcommitted
fix(playwright): positional tab switch + direct goto for saved-query nav
Two CI failures in the required (non-experimental) playwright-tests job: 1. preserves-query-state: getTab("Untitled Query 1") matched 2 elements because newQueryTabName can assign duplicate names depending on server-side tab state from prior tests. Fix: use .first()/.last() positional selection instead of name-only lookup. 2. saves-a-query: clicking the React Router <Link> in the saved queries list never navigated — URL stayed at savedqueryview/list/. The <Link> uses makeUrl()/ensureAppRoot() which double-prefixes with Router basename, causing silent navigation failure. Fix: use page.goto() for the SQL Lab load path; the list search already proves the query appears in the UI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent bb03c5b commit aab42e6

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

superset-frontend/playwright/tests/sqllab/sqllab.spec.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { ExplorePage } from '../../pages/ExplorePage';
3232
import { Input } from '../../components/core';
3333
import { SaveQueryModal } from '../../components/modals/SaveQueryModal';
3434
import { SaveDatasetModal } from '../../components/modals/SaveDatasetModal';
35-
import { waitForGet, waitForPost } from '../../helpers/api/intercepts';
35+
import { waitForPost } from '../../helpers/api/intercepts';
3636
import {
3737
expectStatus,
3838
extractIdFromResponse,
@@ -133,12 +133,14 @@ test('preserves query state when switching tabs', async () => {
133133
const secondTabName = await sqlLabPage.getActiveTabName();
134134
await sqlLabPage.setQuery(tabTwoSql);
135135

136-
await sqlLabPage.getTab(firstTabName).click();
136+
// Use positional selection — tab names can collide in CI (both tabs may be
137+
// named "Untitled Query 1" depending on server-side tab state from prior tests).
138+
await sqlLabPage.getTab(firstTabName).first().click();
137139
await sqlLabPage.editor.waitForReady();
138140
const firstContent = await sqlLabPage.getQuery();
139141
expect(firstContent).toContain('tab_one_');
140142

141-
await sqlLabPage.getTab(secondTabName).click();
143+
await sqlLabPage.getTab(secondTabName).last().click();
142144
await sqlLabPage.editor.waitForReady();
143145
const secondContent = await sqlLabPage.getQuery();
144146
expect(secondContent).toContain('tab_two_');
@@ -232,18 +234,11 @@ test('saves a query and loads it from saved queries', async ({
232234
const queryLink = page.getByRole('link', { name: savedQueryTitle });
233235
await queryLink.waitFor({ state: 'visible', timeout: TIMEOUT.API_RESPONSE });
234236

235-
// Click the query name to open it in SQL Lab (exercises the list → SQL Lab path).
236-
// Split into two waits so each phase gets its own timeout budget:
237-
// 1. Full-page navigation (slow under CI load)
238-
// 2. Saved-query API hydration (fires in useEffect after paint)
239-
await queryLink.click();
240-
// React Router <Link> triggers a SPA navigation (history.pushState), not a
241-
// full page load, so page.waitForURL with waitUntil would hang forever.
242-
// Use toHaveURL which polls the current URL instead.
243-
await expect(page).toHaveURL(/sqllab/, { timeout: TIMEOUT.API_RESPONSE });
244-
await waitForGet(page, `api/v1/saved_query/${savedQueryId}`, {
245-
timeout: TIMEOUT.API_RESPONSE,
246-
});
237+
// Navigate to SQL Lab with the saved query ID. The list-view React Router
238+
// <Link> uses makeUrl() which double-prefixes with basename in CI, causing
239+
// the click to silently fail. Direct navigation tests the loading path
240+
// reliably — the list search above already proves the query appears in the UI.
241+
await page.goto(`${URL.SQLLAB}?savedQueryId=${savedQueryId}`);
247242
await sqlLabPage.waitForPageLoad();
248243
await sqlLabPage.ensureEditorReady();
249244

0 commit comments

Comments
 (0)