diff --git a/packages/insomnia-smoke-test/playwright/pages/components/navigation-sidebar.ts b/packages/insomnia-smoke-test/playwright/pages/components/navigation-sidebar.ts index 5e3cd993f7c..406eac17355 100644 --- a/packages/insomnia-smoke-test/playwright/pages/components/navigation-sidebar.ts +++ b/packages/insomnia-smoke-test/playwright/pages/components/navigation-sidebar.ts @@ -309,9 +309,10 @@ export class NavigationSidebar { return this.unsyncedWorkspaceRow(workspaceName).getByRole('button', { name: 'Fetch unsynced workspace' }); } - async fetchUnsyncedWorkspace(name: string): Promise { + async fetchUnsyncedWorkspace(name: string, verifyVisible?: Locator): Promise { const unsyncedWorkspaceButton = this.unsyncedWorkspaceButton(name); await unsyncedWorkspaceButton.click(); + await this.page.mouse.move(0, 0); await expect.soft(this.unsyncedWorkspaceRow(name)).toBeHidden({ timeout: 5000 }); await expect.soft(this.workspaceRow(name)).toBeVisible(); // The sidebar list is still settling right after the unsynced row disappears @@ -329,6 +330,20 @@ export class NavigationSidebar { } } } + if (!verifyVisible) { + return; + } + for (let attempt = 0; attempt <= 10; attempt++) { + try { + await verifyVisible.waitFor({ state: 'visible', timeout: 1000 }); + return; + } catch { + if (attempt === 10) { + throw new Error(`Workspace "${name}" was selected but its content did not render after 10 attempts`); + } + await this.workspaceRow(name).click(); + } + } } // =========================================================================== diff --git a/packages/insomnia-smoke-test/tests/smoke/cloud-sync.test.ts b/packages/insomnia-smoke-test/tests/smoke/cloud-sync.test.ts index 4cfd3ea298b..0fed8cabd74 100644 --- a/packages/insomnia-smoke-test/tests/smoke/cloud-sync.test.ts +++ b/packages/insomnia-smoke-test/tests/smoke/cloud-sync.test.ts @@ -1,4 +1,4 @@ -import { expect } from '@playwright/test'; +import { expect, type Page } from '@playwright/test'; import playwrightConfig from '../../playwright.config'; import { test } from '../../playwright/test'; @@ -6,6 +6,22 @@ import { test } from '../../playwright/test'; // @ts-expect-error playwrightConfig.webServer.url must exists const devServerUrl = playwrightConfig?.webServer?.url || 'http://127.0.0.1:4010'; +async function clickGitSyncMenuItem(page: Page, menuItemText: string): Promise { + const gitSyncButton = page.getByLabel('Git Sync'); + const menuItem = page.getByText(menuItemText); + for (let attempt = 1; attempt <= 10; attempt++) { + await gitSyncButton.click(); + try { + await menuItem.click({ timeout: 1000 }); + return; + } catch { + if (attempt === 10) { + throw new Error(`Could not click "${menuItemText}" in the Git Sync dropdown after 10 attempts`); + } + } + } +} + test.describe('Cloud Sync', () => { test.beforeAll(async () => { await fetch(`${devServerUrl}/__test-config/cloud-sync`, { @@ -24,8 +40,8 @@ test.describe('Cloud Sync', () => { }); test('Discard, branch and commit actions', async ({ page, insomnia }) => { - // Sync My Collection R1 - await insomnia.navigationSidebar.fetchUnsyncedWorkspace('My Collection R1'); + test.slow(); + await insomnia.navigationSidebar.fetchUnsyncedWorkspace('My Collection R1', insomnia.navigationSidebar.requestRow('New Request')); await insomnia.navigationSidebar.clickRequestOrFolder('New Request'); // Send request and check body await page.getByRole('button', { name: 'Send' }).click(); @@ -77,8 +93,7 @@ test.describe('Cloud Sync', () => { // focused, so back out first. await insomnia.navigationSidebar.backToAllProjects(); await insomnia.navigationSidebar.fetchUnsyncedWorkspace('My MCP Client'); - await page.getByLabel('Git Sync').click(); - await page.getByText('Branches').click(); + await clickGitSyncMenuItem(page, 'Branches'); const branchModal = page.getByRole('dialog'); const localBranchDiv = branchModal.getByLabel('Branches list', { exact: true });