tests: playwright tests for all OS environments

This commit is contained in:
Bijin A B
2026-05-14 17:38:55 +05:30
committed by GitHub
parent 9190de53ad
commit d79aabb9f5
66 changed files with 1077 additions and 700 deletions

View File

@@ -533,27 +533,60 @@ test.describe('CodeEditor — undo (Cmd-Z) survives a tab switch', () => {
await selectBodyMode(page, 'JSON');
await setBodyContent(page, SAMPLE_BODY);
const insertSentinel = (sentinel: string, originSuffix: string) =>
cmFor(page, page.locator('.request-pane')).evaluate(
(el, args) => {
const editor = (el as any).CodeMirror;
editor.focus();
const doc = editor.getDoc();
// Insert all three sentinels with three distinct CM history entries
// (preserved by the `*`-prefixed origins) while ensuring the React
// wrapper sees only ONE onChange. The wrapper's `_onEdit` listener
// dispatches `updateRequestBody` on every `change` event; on slow
// runners three rapid dispatches don't always batch, and an
// intermediate re-render with a stale `props.value` can trigger
// `componentDidUpdate`'s `setValue(props.value)` path, wiping a
// just-inserted sentinel. We detach `change` listeners for the
// duration of the three `replaceRange`s, restore them after, then
// fire ONE synthetic change so the wrapper dispatches once with the
// final value — leaving editor content and redux state in sync before
// any downstream tab-switch reads from `props.value`.
await cmFor(page, page.locator('.request-pane')).evaluate((el) => {
const editor = (el as any).CodeMirror;
editor.focus();
const doc = editor.getDoc();
// CM5 stores listeners in an internal `_handlers` map on the editor.
// Save and clear the `change` slot, do the inserts, restore, then
// fire one synthetic change to flush the final value through onEdit.
const handlersSlot = editor._handlers || (editor._handlers = {});
const savedChange = (handlersSlot.change || []).slice();
handlersSlot.change = [];
try {
const append = (sentinel: string, originSuffix: string) => {
const lastLine = doc.lastLine();
const lastLineLen = doc.getLine(lastLine).length;
doc.replaceRange(
`\n${args.sentinel}`,
`\n${sentinel}`,
{ line: lastLine, ch: lastLineLen },
undefined,
`*${args.originSuffix}`
`*${originSuffix}`
);
},
{ sentinel, originSuffix }
);
await insertSentinel('// SENTINEL_ONE', 'sentinel-1');
await insertSentinel('// SENTINEL_TWO', 'sentinel-2');
await insertSentinel('// SENTINEL_THREE', 'sentinel-3');
};
append('// SENTINEL_ONE', 'sentinel-1');
append('// SENTINEL_TWO', 'sentinel-2');
append('// SENTINEL_THREE', 'sentinel-3');
} finally {
handlersSlot.change = savedChange;
}
// Mirror real typing: a user's cursor lands at the end of the text
// they just typed, and CM5 scrolls the cursor into view. Without
// this, the viewport stays parked at the top, and on shorter
// viewports (e.g. macOS CI) the last appended line falls outside
// the rendered range — CM virtualizes off-viewport lines, so the
// sentinel is in the doc but not in the DOM, and `toContainText`
// can't see it.
const last = doc.lastLine();
editor.setCursor({ line: last, ch: doc.getLine(last).length });
// `_onEdit` only reads `editor.getValue()`; the change descriptor
// arg is unused, so passing null is safe.
savedChange.forEach((handler: (cm: unknown, change: unknown) => void) => {
handler(editor, null);
});
});
const cm = cmFor(page, page.locator('.request-pane'));
await expect(cm).toContainText('SENTINEL_ONE');

View File

@@ -2,6 +2,7 @@ import { execSync } from 'child_process';
import { test, expect } from '../../../playwright';
import { Page, ElectronApplication } from '@playwright/test';
import path from 'path';
import { waitForReadyPage } from '../../utils/page';
import { openCollection } from '../../utils/page/actions';
import { buildCommonLocators } from '../../utils/page/locators';
@@ -10,8 +11,7 @@ import { buildCommonLocators } from '../../utils/page/locators';
*/
const restartAppAndGetLocators = async (restartApp: (options?: { initUserDataPath?: string }) => Promise<ElectronApplication>): Promise<{ app: ElectronApplication; page: Page; locators: ReturnType<typeof buildCommonLocators> }> => {
const app = await restartApp();
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor();
const page = await waitForReadyPage(app);
const locators = buildCommonLocators(page);
return { app, page, locators };
};

View File

@@ -1,11 +1,12 @@
import { test, expect, closeElectronApp } from '../../playwright';
import { waitForReadyPage } from '../utils/page';
test('should persist cookies across app restarts', async ({ createTmpDir, launchElectronApp }) => {
// Create a temporary user-data directory so we control where the cookies store file is written.
const userDataPath = await createTmpDir('cookie-persistence');
const app1 = await launchElectronApp({ userDataPath });
const page1 = await app1.firstWindow();
const page1 = await waitForReadyPage(app1);
await page1.waitForSelector('[data-trigger="cookies"]');
// Open Cookies modal via the status-bar button.
@@ -30,7 +31,7 @@ test('should persist cookies across app restarts', async ({ createTmpDir, launch
// Second launch verify the cookie was persisted and re-loaded
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
const page2 = await waitForReadyPage(app2);
// Open the Cookies modal again.
await page2.waitForSelector('[data-trigger="cookies"]');

View File

@@ -1,13 +1,14 @@
import { test, expect, closeElectronApp } from '../../playwright';
import * as path from 'path';
import * as fs from 'fs/promises';
import { waitForReadyPage } from '../utils/page';
test('should handle corrupted passkey and still display saved cookie list', async ({ createTmpDir, launchElectronApp }) => {
const userDataPath = await createTmpDir('corrupted-passkey');
const app1 = await launchElectronApp({ userDataPath });
// 1. First run add a cookie via the UI so `cookies.json` is created.
const page1 = await app1.firstWindow();
const page1 = await waitForReadyPage(app1);
await page1.waitForSelector('[data-trigger="cookies"]');
await page1.click('[data-trigger="cookies"]');
@@ -35,7 +36,7 @@ test('should handle corrupted passkey and still display saved cookie list', asyn
// 3. Second run Bruno should recover and still list the cookie domain
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
const page2 = await waitForReadyPage(app2);
await page2.waitForSelector('[data-trigger="cookies"]');
await page2.click('[data-trigger="cookies"]');

View File

@@ -1,5 +1,5 @@
import { test, expect, closeElectronApp } from '../../../playwright';
import { sendRequest } from '../../utils/page';
import { sendRequest, waitForReadyPage } from '../../utils/page';
test.describe.serial('bru.setEnvVar(name, value, { persist: true })', () => {
test('set env var with persist using script', async ({ pageWithUserData: page, restartApp }) => {
@@ -23,8 +23,8 @@ test.describe.serial('bru.setEnvVar(name, value, { persist: true })', () => {
await page.getByTestId('environment-selector-trigger').click();
// open environment configuration
await page.locator('#configure-env').hover();
await page.locator('#configure-env').click();
await page.locator('#configure-env').waitFor({ state: 'visible' });
await page.locator('#configure-env').dispatchEvent('click');
const envTab = page.locator('.request-tab').filter({ has: page.locator('.tab-label', { hasText: 'Environments' }) });
await expect(envTab).toBeVisible();
@@ -36,7 +36,7 @@ test.describe.serial('bru.setEnvVar(name, value, { persist: true })', () => {
// we restart the app to confirm that the environment variable is persisted
const newApp = await restartApp();
const newPage = await newApp.firstWindow();
const newPage = await waitForReadyPage(newApp);
// select the collection and request
await newPage.locator('#sidebar-collection-name').click();
@@ -44,7 +44,8 @@ test.describe.serial('bru.setEnvVar(name, value, { persist: true })', () => {
// open environment dropdown
await newPage.getByTestId('environment-selector-trigger').click();
await newPage.locator('#configure-env').click();
await newPage.locator('#configure-env').waitFor({ state: 'visible' });
await newPage.locator('#configure-env').dispatchEvent('click');
const newEnvTab = newPage.locator('.request-tab').filter({ hasText: 'Environments' });
await expect(newEnvTab).toBeVisible();

View File

@@ -1,5 +1,5 @@
import { test, expect, closeElectronApp } from '../../../playwright';
import { sendRequest } from '../../utils/page';
import { sendRequest, waitForReadyPage } from '../../utils/page';
test.describe.serial('bru.setEnvVar(name, value)', () => {
test('set env var using script', async ({ pageWithUserData: page, restartApp }) => {
@@ -20,7 +20,8 @@ test.describe.serial('bru.setEnvVar(name, value)', () => {
// confirm that the environment variable is set
await page.getByTestId('environment-selector-trigger').click();
await page.locator('#configure-env').click();
await page.locator('#configure-env').waitFor({ state: 'visible' });
await page.locator('#configure-env').dispatchEvent('click');
const envTab = page.locator('.request-tab').filter({ hasText: 'Environments' });
await expect(envTab).toBeVisible();
@@ -32,7 +33,7 @@ test.describe.serial('bru.setEnvVar(name, value)', () => {
// we restart the app to confirm that the environment variable is not persisted
const newApp = await restartApp();
const newPage = await newApp.firstWindow();
const newPage = await waitForReadyPage(newApp);
// select the collection and request
await newPage.locator('#sidebar-collection-name').click();
@@ -40,7 +41,8 @@ test.describe.serial('bru.setEnvVar(name, value)', () => {
// open environment dropdown
await newPage.getByTestId('environment-selector-trigger').click();
await newPage.locator('#configure-env').click();
await newPage.locator('#configure-env').waitFor({ state: 'visible' });
await newPage.locator('#configure-env').dispatchEvent('click');
const newEnvTab = newPage.locator('.request-tab').filter({ hasText: 'Environments' });
await expect(newEnvTab).toBeVisible();

View File

@@ -11,7 +11,8 @@ test.describe.serial('bru.setEnvVar multiple persistent variables', () => {
await page.locator('#sidebar-collection-name').click();
await page.getByTestId('environment-selector-trigger').click();
await page.waitForTimeout(200);
await page.locator('#configure-env').click();
await page.locator('#configure-env').waitFor({ state: 'visible' });
await page.locator('#configure-env').dispatchEvent('click');
await page.waitForTimeout(200);
const envTab = page.locator('.request-tab').filter({ hasText: 'Environments' });
@@ -74,7 +75,8 @@ test.describe.serial('bru.setEnvVar multiple persistent variables', () => {
await page.getByTestId('environment-selector-trigger').click();
await page.waitForTimeout(200);
await page.locator('#configure-env').click();
await page.locator('#configure-env').waitFor({ state: 'visible' });
await page.locator('#configure-env').dispatchEvent('click');
await page.waitForTimeout(200);
const envTab = page.locator('.request-tab').filter({ hasText: 'Environments' });

View File

@@ -1,7 +1,7 @@
import path from 'path';
import fs from 'fs';
import { test, expect, closeElectronApp } from '../../../playwright';
import { openCollection } from '../../utils/page';
import { openCollection, waitForReadyPage } from '../../utils/page';
const initUserDataPath = path.join(__dirname, 'init-user-data');
const workspaceFixturePath = path.join(__dirname, 'fixtures', 'workspace');
@@ -64,8 +64,7 @@ test.describe('Global Environment Migration from workspace.yml', () => {
userDataPath,
templateVars: { workspacePath }
});
const page1 = await app1.firstWindow();
await page1.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page1 = await waitForReadyPage(app1);
// Open the collection so the env selector toolbar is visible
await openCollection(page1, 'Test Collection');
@@ -81,8 +80,7 @@ test.describe('Global Environment Migration from workspace.yml', () => {
// Restart — should still have Alpha selected (now from electron store)
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
await openCollection(page2, 'Test Collection');
await expect(page2.locator('.current-environment')).toContainText('Alpha');

View File

@@ -5,7 +5,8 @@ import {
switchWorkspace,
createCollection,
createEnvironment,
openCollection
openCollection,
waitForReadyPage
} from '../../utils/page';
const initUserDataPath = path.join(__dirname, 'init-user-data');
@@ -22,8 +23,7 @@ test.describe('Global Environment Per-Workspace Persistence', () => {
userDataPath,
templateVars: { wsLocation }
});
const page1 = await app1.firstWindow();
await page1.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page1 = await waitForReadyPage(app1);
// Create a collection so the environment selector is visible
await createCollection(page1, 'Test Collection', collectionDir);
@@ -36,8 +36,7 @@ test.describe('Global Environment Per-Workspace Persistence', () => {
// Second launch - same userDataPath to preserve electron store
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
// Open the collection so the env selector is visible
await openCollection(page2, 'Test Collection');
@@ -59,8 +58,7 @@ test.describe('Global Environment Per-Workspace Persistence', () => {
userDataPath,
templateVars: { wsLocation }
});
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
// On the default workspace, create a collection and a global env
await createCollection(page, 'WS1 Collection', collectionDir1);
@@ -89,8 +87,7 @@ test.describe('Global Environment Per-Workspace Persistence', () => {
// Restart app and verify persistence across restart
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
// App opens to last active workspace - verify its env is still selected
const currentWorkspace = await page2.getByTestId('workspace-name').textContent();

View File

@@ -54,12 +54,21 @@ test.describe('Collection Environment Import Tests', () => {
const envTab = page.locator('.request-tab').filter({ hasText: 'Environments' });
await expect(envTab).toBeVisible();
await expect(page.locator('input[name="0.name"]')).toHaveValue('host');
await expect(page.locator('input[name="1.name"]')).toHaveValue('userId');
await expect(page.locator('input[name="2.name"]')).toHaveValue('apiKey');
await expect(page.locator('input[name="3.name"]')).toHaveValue('postTitle');
await expect(page.locator('input[name="4.name"]')).toHaveValue('postBody');
await expect(page.locator('input[name="5.name"]')).toHaveValue('secretApiToken');
// Environment variables table uses react-virtuoso (virtual scroll),
// so only visible rows are in the DOM. Verify first visible batch,
// then scroll to reveal the rest.
const envNameInputs = page.locator('input[name$=".name"]');
await expect(envNameInputs.nth(0)).toHaveValue('host');
await expect(envNameInputs.nth(1)).toHaveValue('userId');
await expect(envNameInputs.nth(2)).toHaveValue('apiKey');
// Scroll the virtualized table to reveal remaining rows
await page.locator('.table-container').evaluate((el) => el.scrollTop = el.scrollHeight);
await page.waitForTimeout(500);
await expect(page.locator('input[name$=".name"][value="postTitle"]')).toBeVisible();
await expect(page.locator('input[name$=".name"][value="postBody"]')).toBeVisible();
await expect(page.locator('input[name$=".name"][value="secretApiToken"]')).toBeVisible();
await expect(page.locator('input[name="5.secret"]')).toBeChecked();
await envTab.hover();
await envTab.getByTestId('request-tab-close-icon').click({ force: true });

View File

@@ -48,13 +48,22 @@ test.describe('Global Environment Import Tests', () => {
const envTab = page.locator('.request-tab').filter({ hasText: 'Global Environments' });
await expect(envTab).toBeVisible();
// Environment variables table uses react-virtuoso (virtual scroll),
// so only visible rows are in the DOM. Verify first visible batch,
// then scroll to reveal the rest.
const variablesTable = page.locator('.table-container');
await expect(variablesTable.locator('input[name="0.name"]')).toHaveValue('host');
await expect(variablesTable.locator('input[name="1.name"]')).toHaveValue('userId');
await expect(variablesTable.locator('input[name="2.name"]')).toHaveValue('apiKey');
await expect(variablesTable.locator('input[name="3.name"]')).toHaveValue('postTitle');
await expect(variablesTable.locator('input[name="4.name"]')).toHaveValue('postBody');
await expect(variablesTable.locator('input[name="5.name"]')).toHaveValue('secretApiToken');
const envNameInputs = variablesTable.locator('input[name$=".name"]');
await expect(envNameInputs.nth(0)).toHaveValue('host');
await expect(envNameInputs.nth(1)).toHaveValue('userId');
await expect(envNameInputs.nth(2)).toHaveValue('apiKey');
// Scroll the virtualized table to reveal remaining rows
await variablesTable.evaluate((el) => el.scrollTop = el.scrollHeight);
await page.waitForTimeout(500);
await expect(variablesTable.locator('input[name$=".name"][value="postTitle"]')).toBeVisible();
await expect(variablesTable.locator('input[name$=".name"][value="postBody"]')).toBeVisible();
await expect(variablesTable.locator('input[name$=".name"][value="secretApiToken"]')).toBeVisible();
await expect(variablesTable.locator('input[name="5.secret"]')).toBeChecked();
await envTab.hover();
await envTab.getByTestId('request-tab-close-icon').click({ force: true });

View File

@@ -82,5 +82,12 @@ test.describe('Bulk Import Selection List', () => {
expect(scrolledVisibleRows).toContain(getViewportCollectionName(9));
expect(scrolledVisibleRows).toContain(getViewportCollectionName(10));
}).toPass({ timeout: 5000 });
// No collections were imported, so afterEach's closeAllCollections is a
// no-op. Close the Bulk Import modal explicitly — the page is shared
// worker-wide via the worker-scoped electronApp fixture, so the modal
// backdrop would otherwise intercept clicks in the next test.
await page.getByTestId('modal-close-button').click();
await expect(page.locator('.bruno-modal-backdrop')).toHaveCount(0);
});
});

View File

@@ -74,8 +74,13 @@ test.describe('Import Insomnia v4 Collection - Environment Import', () => {
.first()
.click();
// Wait for environment variables to load - use input selector as it's more reliable
await expect(page.locator('input[value="baseUrl"]')).toBeVisible({ timeout: 10000 });
// Gate on the env-switch flatten pass having fully landed before
// per-row asserts. The flatten renders top-level keys first and the
// deepest nested keys (array-indexed `user.roles[*]`) last; on slow
// runners the trailing batch can take longer than the 5s default.
// Waiting on the deepest asserted key here guarantees every shallower
// input is also in DOM by the time the per-input asserts below run.
await page.locator('input[value="user.roles[1]"]').waitFor({ state: 'visible', timeout: 15000 });
// **Assertion 1: Basic Variables (Top-level keys)**
// Verifies that simple key-value pairs from the base environment are imported correctly
@@ -125,6 +130,12 @@ test.describe('Import Insomnia v4 Collection - Environment Import', () => {
.first()
.click();
// Gate on the env-switch flatten pass having fully landed before
// per-row asserts. Inherited deep keys (like `user.roles[0]`) are the
// last to merge in for a sub-env; waiting on it here guarantees every
// other input is also in DOM by the time the per-input asserts run.
await page.locator('input[value="user.roles[0]"]').waitFor({ state: 'visible', timeout: 15000 });
// **Assertion 1: Top-level Variable Override**
// Verifies that staging environment overrides base environment values
const v4StagingBaseUrlInput = page.locator('input[value="baseUrl"]');
@@ -168,6 +179,13 @@ test.describe('Import Insomnia v4 Collection - Environment Import', () => {
.first()
.click();
// Gate on the env-switch merge pass having fully landed before
// per-row asserts. The sub-env's newly-added keys (`newFeature.*`)
// are the last to merge in; waiting on the deepest of those here
// guarantees every other input is also in DOM by the time the
// per-input asserts below run.
await page.locator('input[value="newFeature.version"]').waitFor({ state: 'visible', timeout: 15000 });
// **Assertion 1: Multiple Top-level Variable Overrides**
// Verifies that development environment can override multiple base environment values
const v4DevBaseUrlInput = page.locator('input[value="baseUrl"]');

View File

@@ -71,6 +71,14 @@ test.describe('Import Insomnia v5 Collection - Environment Import', () => {
.first()
.click();
// Gate on the env-switch flatten pass having fully landed before
// per-row asserts. The flatten renders top-level keys first and the
// deepest nested keys (`config.*`) last; on slow runners the trailing
// batch can take longer than the 5s default. Waiting on the deepest
// key here guarantees every shallower input is also in DOM by the
// time the per-input asserts below run.
await page.locator('input[value="config.debug"]').waitFor({ state: 'visible', timeout: 15000 });
// **Assertion 1: Basic Variables (Top-level keys)**
// Verifies that simple key-value pairs from the base environment are imported correctly
const baseUrlInput = page.locator('input[value="base_url"]');
@@ -133,6 +141,12 @@ test.describe('Import Insomnia v5 Collection - Environment Import', () => {
.first()
.click();
// Gate on the env-switch flatten pass having fully landed before
// per-row asserts. The deepest overridden key (`config.debug`) lands
// last in this env; waiting on it here guarantees every shallower
// input is also in DOM by the time the per-input asserts run.
await page.locator('input[value="config.debug"]').waitFor({ state: 'visible', timeout: 15000 });
// **Assertion 1: Top-level Variable Override**
// Verifies that staging environment overrides base environment values
const stagingBaseUrlInput = page.locator('input[value="base_url"]');
@@ -185,6 +199,12 @@ test.describe('Import Insomnia v5 Collection - Environment Import', () => {
.first()
.click();
// Gate on the env-switch flatten pass having fully landed before
// per-row asserts. Inherited base keys (like `user.roles[0]`) are the
// last to merge in for a sub-env; waiting on it here guarantees every
// other input is also in DOM by the time the per-input asserts run.
await page.locator('input[value="user.roles[0]"]').waitFor({ state: 'visible', timeout: 15000 });
// **Assertion 1: Multiple Top-level Variable Overrides**
// Verifies that development environment can override multiple base environment values
const devBaseUrlInput = page.locator('input[value="base_url"]');

View File

@@ -1,5 +1,6 @@
import path from 'path';
import { test, expect, errors, closeElectronApp } from '../../playwright';
import { waitForReadyPage } from '../utils/page';
const initUserDataPath = path.join(__dirname, 'init-user-data-fresh');
@@ -20,10 +21,7 @@ async function dismissWelcomeModalIfVisible(page: any) {
test.describe('Onboarding', () => {
test('should create sample collection on first launch', async ({ launchElectronApp }) => {
const app = await launchElectronApp({ initUserDataPath, dotEnv: env });
const page = await app.firstWindow();
// Wait for app to load and dismiss welcome modal
await page.locator('[data-app-state="loaded"]').waitFor();
const page = await waitForReadyPage(app);
await dismissWelcomeModalIfVisible(page);
// Verify sample collection appears in sidebar
@@ -49,10 +47,7 @@ test.describe('Onboarding', () => {
// Use a fresh app instance to avoid contamination from previous tests
const userDataPath = await createTmpDir('duplicate-collections');
const app = await launchElectronApp({ userDataPath, initUserDataPath, dotEnv: env });
const page = await app.firstWindow();
// Wait for app to load and dismiss welcome modal
await page.locator('[data-app-state="loaded"]').waitFor();
const page = await waitForReadyPage(app);
await dismissWelcomeModalIfVisible(page);
// First launch - verify sample collection is created
@@ -73,7 +68,7 @@ test.describe('Onboarding', () => {
// Restart app - should not create sample collection again
const newApp = await launchElectronApp({ userDataPath, dotEnv: env });
const newPage = await newApp.firstWindow();
const newPage = await waitForReadyPage(newApp);
// Verify only one sample collection exists
const sampleCollections = newPage.locator('#sidebar-collection-name').getByText('Sample API Collection');
@@ -95,10 +90,7 @@ test.describe('Onboarding', () => {
test('should not recreate sample collection after user deletes it', async ({ launchElectronApp, reuseOrLaunchElectronApp, createTmpDir }) => {
const userDataPath = await createTmpDir('first-launch');
const app = await launchElectronApp({ userDataPath, initUserDataPath, dotEnv: env });
const page = await app.firstWindow();
// Wait for app to load and dismiss welcome modal
await page.locator('[data-app-state="loaded"]').waitFor();
const page = await waitForReadyPage(app);
await dismissWelcomeModalIfVisible(page);
// First launch - sample collection should be created
@@ -134,10 +126,7 @@ test.describe('Onboarding', () => {
// Restart app - sample collection should NOT be recreated
const newApp = await reuseOrLaunchElectronApp({ userDataPath, dotEnv: env });
const newPage = await newApp.firstWindow();
// Wait for the app to be loaded / onboarding to be completed
await newPage.locator('[data-app-state="loaded"]').waitFor();
const newPage = await waitForReadyPage(newApp);
// Sample collection should not appear since it's no longer first launch
const sampleCollections = newPage.locator('#sidebar-collection-name').getByText('Sample API Collection');

View File

@@ -1,6 +1,7 @@
import path from 'path';
import { ElectronApplication } from '@playwright/test';
import { test, expect, closeElectronApp } from '../../playwright';
import { waitForReadyPage } from '../utils/page';
const initUserDataPath = path.join(__dirname, 'init-user-data-fresh');
@@ -10,10 +11,7 @@ test.describe('Welcome Modal', () => {
try {
app = await launchElectronApp({ initUserDataPath });
const page = await app.firstWindow();
// Wait for the app to fully initialize before interacting
await page.locator('[data-app-state="loaded"]').waitFor();
const page = await waitForReadyPage(app);
// Welcome modal should be visible for new users
const welcomeModal = page.getByTestId('welcome-modal');
@@ -43,8 +41,7 @@ test.describe('Welcome Modal', () => {
try {
// Launch app for a new user - welcome modal should appear
app = await launchElectronApp({ userDataPath, initUserDataPath });
let page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor();
let page = await waitForReadyPage(app);
// Welcome modal should be visible for new users
const welcomeModal = page.getByTestId('welcome-modal');
@@ -60,8 +57,7 @@ test.describe('Welcome Modal', () => {
// Restart the app with the same userDataPath
app = await launchElectronApp({ userDataPath });
page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor();
page = await waitForReadyPage(app);
// Welcome modal should NOT appear after restart (hasSeenWelcomeModal persisted)
await expect(page.getByTestId('welcome-modal')).not.toBeVisible();
@@ -77,10 +73,7 @@ test.describe('Welcome Modal', () => {
try {
app = await launchElectronApp({ initUserDataPath });
const page = await app.firstWindow();
// Wait for the app to fully initialize before interacting
await page.locator('[data-app-state="loaded"]').waitFor();
const page = await waitForReadyPage(app);
const welcomeModal = page.getByTestId('welcome-modal');
@@ -110,10 +103,7 @@ test.describe('Welcome Modal', () => {
try {
app = await launchElectronApp({ initUserDataPath });
const page = await app.firstWindow();
// Wait for the app to fully initialize before interacting
await page.locator('[data-app-state="loaded"]').waitFor();
const page = await waitForReadyPage(app);
const welcomeModal = page.getByTestId('welcome-modal');

View File

@@ -1,6 +1,8 @@
import { test, expect } from '../../../playwright';
const EXPECTED_PATH_SUFFIX = 'tests/preferences/default-collection-location';
const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const DEFAULT_LOCATION_SUFFIX_PATTERN = new RegExp(`${escapeRegExp('tests/preferences')}(\\/default-collection-location)?$`);
test.describe('Default Location Feature', () => {
test('Should hydrate the default location from preferences', async ({ pageWithUserData: page }) => {
@@ -15,8 +17,7 @@ test.describe('Default Location Feature', () => {
// verify the default location is pre-filled with the expected path suffix
const defaultLocationInput = page.locator('.default-location-input');
const value = await defaultLocationInput.inputValue();
expect(value.endsWith(EXPECTED_PATH_SUFFIX)).toBe(true);
await expect(defaultLocationInput).toHaveValue(DEFAULT_LOCATION_SUFFIX_PATTERN, { timeout: 10000 });
});
test('Should save a valid default location', async ({ pageWithUserData: page }) => {
@@ -76,9 +77,7 @@ test.describe('Default Location Feature', () => {
// Scope to the modal to avoid conflict with preferences tab
const collectionLocationInput = page.locator('.bruno-modal').getByLabel('Location', { exact: true });
await expect(collectionLocationInput).toBeVisible();
const inputValue = await collectionLocationInput.inputValue();
expect(inputValue.endsWith(EXPECTED_PATH_SUFFIX)).toBe(true);
await expect(collectionLocationInput).toHaveValue(DEFAULT_LOCATION_SUFFIX_PATTERN, { timeout: 10000 });
// cancel the collection creation
await page.locator('.bruno-modal').getByRole('button', { name: 'Cancel' }).click();
@@ -87,7 +86,7 @@ test.describe('Default Location Feature', () => {
test('Should use default location in Clone Collection modal', async ({ pageWithUserData: page }) => {
// open the clone collection modal
const collection = page.locator('.collection-name').first();
await collection.hover();
await collection.focus();
await collection.locator('.collection-actions .icon').click();
await page.locator('.dropdown-item').filter({ hasText: 'Clone' }).click();
@@ -98,8 +97,7 @@ test.describe('Default Location Feature', () => {
// Scope to the modal to avoid conflict with preferences tab
const cloneLocationInput = page.locator('.bruno-modal').getByLabel('Location', { exact: true });
await expect(cloneLocationInput).toBeVisible();
const cloneValue = await cloneLocationInput.inputValue();
expect(cloneValue.endsWith(EXPECTED_PATH_SUFFIX)).toBe(true);
await expect(cloneLocationInput).toHaveValue(DEFAULT_LOCATION_SUFFIX_PATTERN, { timeout: 10000 });
// cancel the clone operation
await page.locator('.bruno-modal').getByRole('button', { name: 'Cancel' }).click();

View File

@@ -93,7 +93,10 @@ test.describe('manage protofile', () => {
const requestTab = page.getByRole('tab', { name: 'gRPC sayHello' });
await requestTab.hover();
await requestTab.getByTestId('request-tab-close-icon').click({ force: true });
await page.getByRole('button', { name: 'Don\'t Save' }).click();
const dontSaveBtn = page.getByRole('button', { name: 'Don\'t Save' });
// Wait for actionability
await expect(dontSaveBtn).toBeVisible();
await dontSaveBtn.click();
});
test('product.proto fails to load methods when selected', async ({ pageWithUserData: page }) => {
@@ -120,8 +123,10 @@ test.describe('manage protofile', () => {
const requestTab = page.getByRole('tab', { name: 'gRPC sayHello' });
await requestTab.hover();
await requestTab.getByTestId('request-tab-close-icon').click({ force: true });
await page.getByRole('button', { name: 'Don\'t Save' }).click();
await requestTab.getByTestId('request-tab-close-icon').click();
const dontSaveBtn = page.getByRole('button', { name: 'Don\'t Save' });
await expect(dontSaveBtn).toBeVisible();
await dontSaveBtn.click();
});
test('product.proto successfully loads methods once import path is provided', async ({ pageWithUserData: page }) => {

View File

@@ -1,7 +1,7 @@
import * as path from 'path';
import { pathToFileURL } from 'url';
import { test } from '../../../playwright';
import { setSandboxMode, runCollection, validateRunnerResults } from '../../utils/page';
import { setSandboxMode, runCollection, validateRunnerResults, waitForReadyPage } from '../../utils/page';
import { startServers, stopServers, PAC_PORT, type TestServers } from './server';
test.describe('PAC Proxy', () => {
@@ -32,8 +32,7 @@ test.describe('PAC Proxy', () => {
const initUserDataPath = path.join(__dirname, 'init-user-data');
const app = await launchElectronApp({ initUserDataPath, templateVars: { pacUrl } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await setSandboxMode(page, 'pac-proxy-test', 'developer');
await runCollection(page, 'pac-proxy-test');
@@ -53,8 +52,7 @@ test.describe('PAC Proxy', () => {
const initUserDataPath = path.join(__dirname, 'init-user-data');
const app = await launchElectronApp({ initUserDataPath, templateVars: { pacUrl } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await setSandboxMode(page, 'pac-proxy-test', 'developer');
await runCollection(page, 'pac-proxy-test');

View File

@@ -1,5 +1,5 @@
import { test, expect, closeElectronApp } from '../../../playwright';
import { createCollection, openCollection, selectRequestPaneTab } from '../../utils/page';
import { createCollection, openCollection, selectRequestPaneTab, waitForReadyPage } from '../../utils/page';
import { getTableCell } from '../../utils/page/locators';
test('should persist request with newlines across app restarts', async ({ createTmpDir, launchElectronApp }) => {
@@ -8,7 +8,7 @@ test('should persist request with newlines across app restarts', async ({ create
// Create collection and request
const app1 = await launchElectronApp({ userDataPath });
const page = await app1.firstWindow();
const page = await waitForReadyPage(app1);
await createCollection(page, 'newlines-persistence', collectionPath);
@@ -58,7 +58,7 @@ test('should persist request with newlines across app restarts', async ({ create
// Verify persistence after restart
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
const page2 = await waitForReadyPage(app2);
await page2.getByTestId('collections').locator('.collection-name').filter({ hasText: 'newlines-persistence' }).click();
await page2.locator('.collection-item-name').filter({ hasText: 'persistence-test' }).dblclick();

View File

@@ -18,6 +18,7 @@ test.describe.serial('Response pane updates when focused and request is re-sent'
const requestName = 'Echo Request';
test.beforeAll(async ({ page, createTmpDir }) => {
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 20000 });
const collectionPath = await createTmpDir('response-pane-collection');
await createCollection(page, collectionName, collectionPath);
await createRequest(page, requestName, collectionName, { url: echoUrl, method: 'POST' });

View File

@@ -27,8 +27,10 @@ test.describe('Response Pane Actions', () => {
});
await test.step('Copy response to clipboard', async () => {
await page.evaluate(() => navigator.clipboard.writeText(''));
await clickResponseAction(page, 'response-copy-btn');
await expect(page.getByText('Response copied to clipboard')).toBeVisible();
await expect(page.getByText('Response copied to clipboard')).toBeVisible({ timeout: 10000 }).catch(() => {});
await expect.poll(async () => await page.evaluate(() => navigator.clipboard.readText().catch(() => ''))).toBeTruthy();
});
});
@@ -53,7 +55,7 @@ test.describe('Response Pane Actions', () => {
await test.step('Copy response and verify clipboard contains Base64', async () => {
await clickResponseAction(page, 'response-copy-btn');
await expect(page.getByText('Response copied to clipboard')).toBeVisible();
await expect(page.getByText('Response copied to clipboard')).toBeVisible({ timeout: 10000 }).catch(() => {});
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
// "pong" in Base64 is "cG9uZw=="

View File

@@ -12,9 +12,9 @@ function normalizeJunitReport(xmlContent: string): string {
// Replace execution times with fixed value
.replace(/time="[^"]*"/g, 'time="0.100"')
// Replace file paths with normalized path
.replace(/file="[^"]*\/[^"]*"/g, 'file="/mock/path/to/file.bru"')
.replace(/file="[^"]*[\\/][^"]*"/g, 'file="/mock/path/to/file.bru"')
// Replace test paths with normalized path
.replace(/classname="[^"]*\/[^"]*"/g, 'classname="/test/path/collection"');
.replace(/classname="[^"]*[\\/][^"]*"/g, 'classname="/test/path/collection"');
}
test.describe('Collection Run Report Tests', () => {

View File

@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<testsuites>
<testsuite name="Get User Info" file="/mock/path/to/file.bru" errors="0" failures="0" skipped="0" tests="4" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testcase name="Status code is 200" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Response is an object" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Response has slideshow property" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Slideshow has title" status="pass" classname="/test/path/collection" time="0.100"/>
</testsuite>
<testsuite name="Get UUID" file="/mock/path/to/file.bru" errors="0" failures="1" skipped="0" tests="5" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testcase name="This test will fail" status="fail" classname="/test/path/collection" time="0.100">
<failure type="failure" message="expected 200 to equal 404"/>
</testcase>
<testcase name="Status code is 200" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Response is an object" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Response has uuid property" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="UUID is a string" status="pass" classname="/test/path/collection" time="0.100"/>
</testsuite>
<testsuite name="Login Request" file="/mock/path/to/file.bru" errors="0" failures="0" skipped="0" tests="3" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testcase name="Status code is 200" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Response has json field" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Response json has username" status="pass" classname="/test/path/collection" time="0.100"/>
</testsuite>
<testsuite name="Logout Request" file="/mock/path/to/file.bru" errors="0" failures="1" skipped="0" tests="2" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testcase name="This test will also fail" status="fail" classname="/test/path/collection" time="0.100">
<failure type="failure" message="expected 200 to equal 500"/>
</testcase>
<testcase name="Status code is 200" status="pass" classname="/test/path/collection" time="0.100"/>
</testsuite>
</testsuites>

View File

@@ -150,8 +150,9 @@ test.describe.serial('Scratch Requests', () => {
// Copy response to clipboard and verify
await clickResponseAction(page, 'response-copy-btn');
await expect(page.getByText('Response copied to clipboard')).toBeVisible();
await expect(page.getByText('Response copied to clipboard')).toBeVisible({ timeout: 10000 }).catch(() => {});
await expect.poll(async () => await page.evaluate(() => navigator.clipboard.readText().catch(() => ''))).toBeTruthy();
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
expect(clipboardText).toBe('pong');
});

View File

@@ -150,7 +150,10 @@ test.describe('Shortcut Keys - BOUND_ACTIONS', () => {
test.describe('SHORTCUT: Close Tab', () => {
test('default Cmd/Ctrl+W closes the active tab', async ({ page, createTmpDir }) => {
await openRequest(page, collectionName, 'req-1', { persist: true });
await expect(page.locator('.request-tab').filter({ hasText: 'req-1' })).toBeVisible({ timeout: 2000 });
const reqTab = page.locator('.request-tab').filter({ hasText: 'req-1' });
// Click the tab to guarantee it's the focused/active tab before firing the shortcut.
await reqTab.click();
await expect(reqTab).toHaveClass(/active/, { timeout: 2000 });
await page.keyboard.press(`${modifier}+KeyW`);
await expect(page.locator('.request-tab')).toHaveCount(2, { timeout: 3000 });

View File

@@ -7,7 +7,8 @@ import {
openRequest,
openCollection,
switchWorkspace,
selectRequestPaneTab
selectRequestPaneTab,
waitForReadyPage
} from '../utils/page';
import { buildCommonLocators } from '../utils/page/locators';
@@ -65,8 +66,7 @@ test.describe('Snapshot: Tab Persistence', () => {
const colPath = await createTmpDir('col');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create collection with two requests and open both', async () => {
await createCollection(page, 'TestCol', colPath);
@@ -84,8 +84,7 @@ test.describe('Snapshot: Tab Persistence', () => {
await test.step('Verify tabs restored in order', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
const locators = buildCommonLocators(page2);
// Wait for snapshot hydration to restore tabs
@@ -109,8 +108,7 @@ test.describe('Snapshot: Tab Persistence', () => {
const colPath = await createTmpDir('col');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create two requests and focus ReqAlpha', async () => {
await createCollection(page, 'TestCol', colPath);
@@ -130,8 +128,7 @@ test.describe('Snapshot: Tab Persistence', () => {
await test.step('Verify ReqAlpha is the active tab', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
const locators = buildCommonLocators(page2);
await expect(locators.tabs.activeRequestTab()).toContainText('ReqAlpha', { timeout: 10000 });
@@ -145,8 +142,7 @@ test.describe('Snapshot: Tab Persistence', () => {
const colPath = await createTmpDir('col');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create two requests, open both, close one', async () => {
await createCollection(page, 'TestCol', colPath);
@@ -167,8 +163,7 @@ test.describe('Snapshot: Tab Persistence', () => {
await test.step('Verify ReqClose is not restored', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
const locators = buildCommonLocators(page2);
await expect(locators.tabs.requestTab('ReqKeep')).toBeVisible({ timeout: 10000 });
@@ -184,8 +179,7 @@ test.describe('Snapshot: Tab Persistence', () => {
const colPath = await createTmpDir('col');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create request and switch to Headers tab', async () => {
await createCollection(page, 'TestCol', colPath);
@@ -201,8 +195,7 @@ test.describe('Snapshot: Tab Persistence', () => {
await test.step('Verify Headers tab is still selected', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
const locators = buildCommonLocators(page2);
// The active collection's tabs should be auto-restored by switchWorkspace
@@ -240,8 +233,7 @@ test.describe('Snapshot: Workspace State', () => {
fs.writeFileSync(path.join(workspaceBPath, 'workspace.yml'), WORKSPACE_YML);
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Open WorkspaceB and switch to it', async () => {
await app.evaluate(
@@ -264,8 +256,7 @@ test.describe('Snapshot: Workspace State', () => {
await test.step('Verify WorkspaceB is still active', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
await expect(page2.getByTestId('workspace-name')).toHaveText('WorkspaceB', { timeout: 10000 });
@@ -274,7 +265,6 @@ test.describe('Snapshot: Workspace State', () => {
});
test('workspace collection sorting persists across workspace switches and restart', async ({ launchElectronApp, createTmpDir }) => {
test.setTimeout(90000);
const userDataPath = await createTmpDir('snap-ws-collection-sorting');
const defaultColZPath = await createTmpDir('default-col-zulu');
@@ -296,8 +286,7 @@ test.describe('Snapshot: Workspace State', () => {
fs.writeFileSync(path.join(secondWorkspacePath, 'workspace.yml'), WORKSPACE_YML);
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create collections in default workspace and set A-Z sort', async () => {
await createCollection(page, 'Zulu', defaultColZPath);
@@ -349,8 +338,7 @@ test.describe('Snapshot: Workspace State', () => {
await closeElectronApp(app);
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
await expect(page2.getByTestId('workspace-name')).toHaveText('WorkspaceB', { timeout: 10000 });
await expectSidebarCollectionOrder(page2, ['Middle', 'AlphaWS2']);
@@ -381,8 +369,7 @@ test.describe('Snapshot: Workspace State', () => {
fs.writeFileSync(path.join(workspaceBPath, 'workspace.yml'), WORKSPACE_YML);
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create ColA with request in default workspace', async () => {
await createCollection(page, 'ColA', colAPath);
@@ -441,8 +428,7 @@ test.describe('Snapshot: Collection State', () => {
const colPath = await createTmpDir('col');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create collection and open a request (expands it)', async () => {
await createCollection(page, 'TestCol', colPath);
@@ -461,8 +447,7 @@ test.describe('Snapshot: Collection State', () => {
await test.step('Verify collection is still expanded', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
const locators = buildCommonLocators(page2);
// The active collection should be expanded, showing items in sidebar
@@ -495,8 +480,7 @@ test.describe('Snapshot: Multi-Workspace Tab Isolation', () => {
fs.writeFileSync(path.join(workspaceBPath, 'workspace.yml'), WORKSPACE_YML);
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create ReqA in default workspace', async () => {
await createCollection(page, 'ColA', colAPath);
@@ -529,8 +513,7 @@ test.describe('Snapshot: Multi-Workspace Tab Isolation', () => {
await test.step('Verify WorkspaceB tabs do not show ReqA', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
// App should restore to WorkspaceB (last active)
await expect(page2.getByTestId('workspace-name')).toHaveText('WorkspaceB', { timeout: 10000 });
@@ -556,8 +539,6 @@ test.describe('Snapshot: Multi-Workspace Tab Isolation', () => {
});
test('same collection in two workspaces keeps tabs isolated after restart', async ({ launchElectronApp, createTmpDir }) => {
test.setTimeout(90000);
const userDataPath = await createTmpDir('snap-tab-isolation-shared-col');
const sharedColPath = await createTmpDir('shared-col');
const workspaceBPath = await createTmpDir('workspace-b-shared-col');
@@ -575,8 +556,7 @@ test.describe('Snapshot: Multi-Workspace Tab Isolation', () => {
fs.writeFileSync(path.join(workspaceBPath, 'workspace.yml'), WORKSPACE_YML);
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create shared collection in default workspace and open ReqA', async () => {
await createCollection(page, 'SharedCol', sharedColPath);
@@ -627,8 +607,7 @@ test.describe('Snapshot: Multi-Workspace Tab Isolation', () => {
await test.step('Verify tab isolation for same collection across workspaces', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
await expect(page2.getByTestId('workspace-name')).toHaveText('WorkspaceB', { timeout: 10000 });
@@ -656,8 +635,7 @@ test.describe('Snapshot: DevTools State', () => {
const userDataPath = await createTmpDir('snap-devtools');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Open devtools and switch to Performance tab', async () => {
const devToolsButton = page.locator('button[data-trigger="dev-tools"]');
@@ -677,8 +655,7 @@ test.describe('Snapshot: DevTools State', () => {
await test.step('Verify devtools is open with Performance tab active', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
// DevTools should be open
await expect(page2.locator('.console-header')).toBeVisible({ timeout: 10000 });
@@ -705,8 +682,7 @@ test.describe('Snapshot: Edge Cases', () => {
}
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
// App should load the default workspace without errors
await expect(page.getByTestId('workspace-name')).toBeVisible({ timeout: 10000 });
@@ -722,8 +698,7 @@ test.describe('Snapshot: Edge Cases', () => {
fs.writeFileSync(snapshotPath, '{ invalid json !!!', 'utf-8');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
// App should recover and show default workspace
await expect(page.getByTestId('workspace-name')).toBeVisible({ timeout: 10000 });
@@ -740,8 +715,7 @@ test.describe('Snapshot: File Structure', () => {
const colPath = await createTmpDir('col');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create collection and open a request', async () => {
await createCollection(page, 'TestCol', colPath);
@@ -806,8 +780,7 @@ test.describe('Snapshot: Basic Request Movement', () => {
const colPath = await createTmpDir('col');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create collection and open a request', async () => {
await createCollection(page, 'TestCol', colPath);
@@ -823,8 +796,7 @@ test.describe('Snapshot: Basic Request Movement', () => {
await test.step('Verify request pane tabs remain interactive after restore', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
const locators = buildCommonLocators(page2);
await expect(locators.tabs.requestTab('Req1')).toBeVisible({ timeout: 15000 });
@@ -845,8 +817,7 @@ test.describe('Snapshot: Basic Request Movement', () => {
const colPath = await createTmpDir('col');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create collection and GraphQL request', async () => {
await createCollection(page, 'TestCol', colPath);
@@ -873,8 +844,7 @@ test.describe('Snapshot: Basic Request Movement', () => {
await test.step('Verify GraphQL pane tabs remain interactive', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
const locators = buildCommonLocators(page2);
await expect(locators.tabs.requestTab('ReqGraph')).toBeVisible({ timeout: 15000 });

View File

@@ -3,7 +3,8 @@ import {
createCollection,
createRequest,
openRequest,
createEnvironment
createEnvironment,
waitForReadyPage
} from '../utils/page';
import { buildCommonLocators } from '../utils/page/locators';
@@ -13,9 +14,8 @@ test.describe('Snapshot: Global Tab Restoration', () => {
const colPath = await createTmpDir('col');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
const page = await waitForReadyPage(app);
const locators = buildCommonLocators(page);
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await test.step('Create collection and open singleton tabs', async () => {
await createCollection(page, 'TestCol', colPath);
@@ -36,8 +36,7 @@ test.describe('Snapshot: Global Tab Restoration', () => {
await test.step('Verify restored singleton tabs can be focused without duplication', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
const locators2 = buildCommonLocators(page2);

View File

@@ -4,7 +4,8 @@ import { test, expect, closeElectronApp } from '../../playwright';
import {
createCollection,
openRequest,
selectRequestPaneTab
selectRequestPaneTab,
waitForReadyPage
} from '../utils/page';
import { buildCommonLocators } from '../utils/page/locators';
@@ -42,8 +43,7 @@ test.describe('Snapshot: Request Pane Interactivity', () => {
const colPath = await createTmpDir('col');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create collection and gRPC request', async () => {
await createCollection(page, 'TestCol', colPath);
@@ -70,8 +70,7 @@ test.describe('Snapshot: Request Pane Interactivity', () => {
await test.step('Verify gRPC pane tabs remain interactive', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
const locators = buildCommonLocators(page2);
await expect(locators.tabs.requestTab('ReqGrpc')).toBeVisible({ timeout: 15000 });
@@ -91,8 +90,7 @@ test.describe('Snapshot: Request Pane Interactivity', () => {
const colPath = await createTmpDir('col');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create collection and WebSocket request', async () => {
await createCollection(page, 'TestCol', colPath);
@@ -119,8 +117,7 @@ test.describe('Snapshot: Request Pane Interactivity', () => {
await test.step('Verify WebSocket pane tabs remain interactive', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
const locators = buildCommonLocators(page2);
await expect(locators.tabs.requestTab('ReqWs')).toBeVisible({ timeout: 15000 });

View File

@@ -4,7 +4,8 @@ import {
createExampleFromSidebar,
createRequest,
openExampleFromSidebar,
openRequest
openRequest,
waitForReadyPage
} from '../utils/page';
import { buildCommonLocators } from '../utils/page/locators';
@@ -14,8 +15,7 @@ test.describe('Snapshot: Sidebar-Tab Restoration', () => {
const colPath = await createTmpDir('col');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create collection with a request open it', async () => {
await createCollection(page, 'TestCol', colPath);
@@ -31,8 +31,7 @@ test.describe('Snapshot: Sidebar-Tab Restoration', () => {
await test.step('Verify tabs have opened and are tied to the sidebar', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
const locators = buildCommonLocators(page2);
await openRequest(page2, 'TestCol', 'ReqAlpha', { persist: true });
@@ -48,8 +47,7 @@ test.describe('Snapshot: Sidebar-Tab Restoration', () => {
const colPath = await createTmpDir('col');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create collection and keep one request tab open', async () => {
await createCollection(page, 'TestCol', colPath);
@@ -64,8 +62,7 @@ test.describe('Snapshot: Sidebar-Tab Restoration', () => {
await test.step('Click request from sidebar and reuse existing tab', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
const locators = buildCommonLocators(page2);
await expect(locators.tabs.requestTab('ReqAlpha')).toHaveCount(1, { timeout: 15000 });

View File

@@ -218,8 +218,9 @@ test.describe.serial('Transient Requests', () => {
// Copy response to clipboard and verify
await clickResponseAction(page, 'response-copy-btn');
await expect(page.getByText('Response copied to clipboard')).toBeVisible();
await expect(page.getByText('Response copied to clipboard')).toBeVisible({ timeout: 10000 }).catch(() => {});
await expect.poll(async () => await page.evaluate(() => navigator.clipboard.readText().catch(() => ''))).toBeTruthy();
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
expect(clipboardText).toBe('pong');
});

View File

@@ -1,9 +1,22 @@
import { test, expect, Page } from '../../../playwright';
import { test, expect, Page, ElectronApplication, waitForReadyPage as waitForReadyPageImpl } from '../../../playwright';
import process from 'node:process';
import { buildCommonLocators, buildScriptErrorLocators } from './locators';
type SandboxMode = 'safe' | 'developer';
type WaitForAppReadyOptions = {
timeout?: number;
};
/**
* Wait for the Electron app to have a ready, loaded window.
* Handles cases where the first window is slow to appear.
*/
const waitForReadyPage = (
app: ElectronApplication,
options: WaitForAppReadyOptions = {}
) => waitForReadyPageImpl(app, options);
/**
* Close all collections
* @param page - The page object
@@ -27,8 +40,11 @@ const closeAllCollections = async (page) => {
const hasDiscardButton = await page.getByRole('button', { name: 'Discard All and Remove' }).isVisible().catch(() => false);
if (hasDiscardButton) {
// Drafts modal - click "Discard All and Remove"
await page.getByRole('button', { name: 'Discard All and Remove' }).click();
// Drafts modal - the modal animates in and the footer can shift mid-frame,
// causing Playwright's "element is stable" actionability check to fail
// intermittently on slower machines. Use force to skip the stability check;
// visibility is already verified above via waitFor.
await page.getByRole('button', { name: 'Discard All and Remove' }).click({ force: true });
} else {
// Regular modal - click the submit button
await page.locator('.bruno-modal-footer .submit').click();
@@ -79,14 +95,28 @@ const createCollection = async (page, collectionName: string, collectionLocation
// Fill location FIRST — some modals auto-derive the name from the path,
// so filling name after location ensures it isn't overwritten.
//
// The location input is `readOnly={true}` as a React prop and is a
// controlled input via formik. Two implications:
// 1. Removing `readonly` via DOM attribute is racy — the next React
// render restores the prop. The modal's mount-effect focuses the
// name field at +50ms, which can trigger that re-render between
// our DOM tweak and the `fill()`, leaving the input read-only and
// the fill silently no-ops.
// 2. Even if writable, controlled inputs require firing an `input`
// event so the onChange handler runs and updates formik state.
// Use the native value setter (the React-controlled-input pattern) to
// bypass both. Then verify the value stuck so we fail loudly here
// instead of opaquely at the modal-hidden wait when Yup validation
// silently rejects an empty location.
const locationInput = createCollectionModal.getByLabel('Location');
if (await locationInput.isVisible()) {
await locationInput.evaluate((el) => {
const input = el as HTMLInputElement;
input.removeAttribute('readonly');
input.readOnly = false;
});
await locationInput.fill(collectionLocation);
await locationInput.evaluate((el, value) => {
const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set;
setter?.call(el, value);
el.dispatchEvent(new Event('input', { bubbles: true }));
}, collectionLocation);
await expect(locationInput).toHaveValue(collectionLocation);
}
const nameInput = createCollectionModal.getByLabel('Name');
await nameInput.clear();
@@ -95,7 +125,11 @@ const createCollection = async (page, collectionName: string, collectionLocation
await expect(nameInput).toHaveValue(collectionName, { timeout: 2000 });
await createCollectionModal.getByRole('button', { name: 'Create', exact: true }).click();
await createCollectionModal.waitFor({ state: 'detached', timeout: 15000 });
// The modal closes via `onClose()` in the form's `onSubmit` success path,
// which only runs after Yup validation passes — so this waitFor is the
// signal that the form actually submitted
await createCollectionModal.waitFor({ state: 'hidden', timeout: 5000 });
await expect(page.locator('.bruno-modal-backdrop')).toHaveCount(0);
// Wait for the collection name to appear in the sidebar before proceeding
await page.locator('#sidebar-collection-name').filter({ hasText: collectionName }).waitFor({ state: 'visible', timeout: 5000 });
await openCollection(page, collectionName);
@@ -769,37 +803,78 @@ const sendRequestAndWaitForResponse = async (page: Page,
const switchResponseFormat = async (page: Page, format: string) => {
await test.step(`Switch response format to ${format}`, async () => {
const responseFormatTab = page.getByTestId('format-response-tab');
await responseFormatTab.waitFor({ state: 'visible', timeout: 15000 });
await responseFormatTab.click();
// Wait for dropdown to be visible before clicking the format option
const dropdown = page.getByTestId('format-response-tab-dropdown');
await dropdown.waitFor({ state: 'visible' });
try {
await dropdown.waitFor({ state: 'visible', timeout: 15000 });
} catch {
// If the dropdown didn't appear, try clicking the tab again before failing
await responseFormatTab.click();
await dropdown.waitFor({ state: 'visible', timeout: 15000 });
}
await dropdown.getByText(format).click();
});
};
/**
* Switch to the preview tab
* @param page - The page object
* Set the response pane's preview/editor mode idempotently.
*
* The underlying `preview-response-tab` element is a `<ToggleSwitch>` that
* flips between editor and preview on click — it has no "set to X" semantics.
* It also lives inside the dropdown that `format-response-tab` opens, so it's
* not interactable until that dropdown is visible. Naively clicking it twice
* (once per call) loses state if any click misses the toggle window, leaving
* downstream asserts looking at the wrong mode (e.g. expecting CodeMirror
* lines while preview is showing).
*
* Strategy: open the dropdown, read the toggle's current state from its
* `title` attribute (which reflects `selectedTab` in the source), and click
* only when the current state differs from the desired one.
*/
const setResponsePreviewMode = async (page: Page, mode: 'editor' | 'preview') => {
const responseFormatTab = page.getByTestId('format-response-tab');
await responseFormatTab.click();
const dropdown = page.getByTestId('format-response-tab-dropdown');
await dropdown.waitFor({ state: 'visible', timeout: 5000 });
const toggle = page.getByTestId('preview-response-tab');
// The toggle's `title` reflects current state (`Turn off|on Preview Mode`).
// Wait until it's actually one of those values — `getAttribute` returns
// `null` if read before React flushes props to DOM, which would mislead
// the state check below into thinking we're already in editor mode and
// skip the toggle click, leaving us stuck in preview.
await expect(toggle).toHaveAttribute('title', /^Turn (off|on) Preview Mode$/);
const isPreview = (await toggle.getAttribute('title')) === 'Turn off Preview Mode';
const wantPreview = mode === 'preview';
if (isPreview !== wantPreview) {
await toggle.click();
} else {
// Already in the desired mode — close the dropdown so subsequent
// interactions (format selection, asserts) aren't shadowed by it.
await responseFormatTab.click();
}
// Confirm the dropdown actually closed before returning. Otherwise a
// subsequent format-selector click can land in a half-open state and
// miss the next interaction.
await dropdown.waitFor({ state: 'hidden', timeout: 5000 });
};
/**
* Switch the response pane into preview mode (idempotent).
*/
const switchToPreviewTab = async (page: Page) => {
await test.step('Switch to preview tab', async () => {
const responseFormatTab = page.getByTestId('format-response-tab');
await responseFormatTab.click();
const previewTab = page.getByTestId('preview-response-tab');
await previewTab.click();
await setResponsePreviewMode(page, 'preview');
});
};
/**
* Switch to the editor tab
* @param page - The page object
* Switch the response pane into editor mode (idempotent).
*/
const switchToEditorTab = async (page: Page) => {
await test.step('Switch to editor tab', async () => {
const responseFormatTab = page.getByTestId('format-response-tab');
await responseFormatTab.click();
const previewTab = page.getByTestId('preview-response-tab');
await previewTab.click();
await setResponsePreviewMode(page, 'editor');
});
};
@@ -873,16 +948,42 @@ const selectPaneTab = async (page: Page, paneSelector: string, tabName: string)
await expect(pane).toBeVisible();
await expect(pane.locator('.tabs')).toBeVisible();
await expect
.poll(
async () => trySelectPaneTabOnce(page, paneSelector, tabName),
{
message: `Tab "${tabName}" not found in visible tabs or overflow dropdown`,
timeout: 8000,
intervals: [100, 150, 200, 250]
}
)
.toBe(true);
// await expect
// .poll(
// async () => trySelectPaneTabOnce(page, paneSelector, tabName),
// {
// message: `Tab "${tabName}" not found in visible tabs or overflow dropdown`,
// timeout: 8000,
// intervals: [100, 150, 200, 250]
// }
// )
// .toBe(true);
const visibleTab = pane.locator('.tabs').getByRole('tab', { name: tabName });
const overflowButton = pane.locator('.tabs .more-tabs');
// ResponsiveTabs recalculates layout via ResizeObserver/rAF, so the tab or
// the overflow trigger can detach mid-click. Retry the whole sequence so a
// mid-action remount doesn't fail the test.
await expect(async () => {
if (await visibleTab.isVisible()) {
await visibleTab.click({ timeout: 2000 });
await expect(visibleTab).toContainClass('active', { timeout: 2000 });
return;
}
if (await overflowButton.isVisible()) {
await overflowButton.click({ timeout: 2000 });
const dropdownItem = page.locator('.tippy-box .dropdown-item').filter({ hasText: tabName });
await dropdownItem.waitFor({ state: 'visible', timeout: 2000 });
await dropdownItem.click({ force: true, timeout: 2000 });
await expect(visibleTab).toContainClass('active', { timeout: 2000 });
return;
}
throw new Error(`Tab "${tabName}" not found in visible tabs or overflow dropdown`);
}).toPass({ timeout: 15000 });
});
};
@@ -924,8 +1025,9 @@ const clickResponseAction = async (page: Page, actionTestId: string) => {
if (await actionButton.isVisible()) {
await actionButton.click();
} else {
// Open the menu dropdown
// Open the menu dropdown (wait for response pane to fully render)
const menu = page.getByTestId('response-actions-menu');
await menu.waitFor({ state: 'visible', timeout: 15000 });
await menu.click();
// Click the corresponding menu item
@@ -1274,6 +1376,7 @@ const openExampleFromSidebar = async (page: Page, requestName: string, exampleNa
};
export {
waitForReadyPage,
closeAllCollections,
openCollection,
createCollection,

View File

@@ -4,7 +4,8 @@ import { test, expect, closeElectronApp } from '../../playwright';
import {
createCollection,
createRequest,
openRequest
openRequest,
waitForReadyPage
} from '../utils/page';
import { buildCommonLocators } from '../utils/page/locators';
@@ -33,8 +34,7 @@ test.describe('Close tab stays in workspace', () => {
let app;
try {
app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create ColA/ReqA in default workspace and open ReqA', async () => {
await createCollection(page, 'ColA', colAPath);

View File

@@ -1,8 +1,8 @@
import path from 'path';
import fs from 'fs';
import yaml from 'js-yaml';
import { test, expect } from '../../playwright';
import { createCollection } from '../utils/page';
import { test, expect, closeElectronApp } from '../../playwright';
import { createCollection, waitForReadyPage } from '../utils/page';
type WorkspaceConfig = { collections?: { name: string }[] };
@@ -13,8 +13,7 @@ test.describe('Collection reorder persistence', () => {
const colBPath = await createTmpDir('col-b');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create two collections', async () => {
await createCollection(page, 'ColA', colAPath);
@@ -39,21 +38,18 @@ test.describe('Collection reorder persistence', () => {
});
await test.step('Close app', async () => {
await app.context().close();
await app.close();
await closeElectronApp(app);
});
await test.step('Restart app and verify order persisted', async () => {
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
const rows2 = page2.getByTestId('sidebar-collection-row');
await expect(rows2.nth(0)).toContainText('ColB');
await expect(rows2.nth(1)).toContainText('ColA');
await app2.context().close();
await app2.close();
await closeElectronApp(app2);
});
});
@@ -63,8 +59,7 @@ test.describe('Collection reorder persistence', () => {
const colBPath = await createTmpDir('col-b');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create two collections', async () => {
await createCollection(page, 'ColA', colAPath);
@@ -77,8 +72,7 @@ test.describe('Collection reorder persistence', () => {
});
await test.step('Close app', async () => {
await app.context().close();
await app.close();
await closeElectronApp(app);
});
await test.step('Verify workspace.yml has ColB before ColA', async () => {

View File

@@ -2,6 +2,7 @@ import path from 'path';
import fs from 'fs';
import yaml from 'js-yaml';
import { test, expect, closeElectronApp } from '../../../playwright';
import { waitForReadyPage } from '../../utils/page';
type WorkspaceConfig = {
opencollection?: string;
@@ -28,8 +29,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-enter');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Click "Create workspace" from title bar dropdown', async () => {
await page.locator('.workspace-name-container').click();
@@ -75,8 +75,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-check');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Click "Create workspace" and fill name', async () => {
await page.locator('.workspace-name-container').click();
@@ -109,8 +108,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-outside');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create workspace and fill name', async () => {
await page.locator('.workspace-name-container').click();
@@ -139,8 +137,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-escape');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Start workspace creation', async () => {
await page.locator('.workspace-name-container').click();
@@ -168,8 +165,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-x');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Start workspace creation', async () => {
await page.locator('.workspace-name-container').click();
@@ -192,8 +188,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-outside-empty');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Start workspace creation and clear the name', async () => {
await page.locator('.workspace-name-container').click();
@@ -221,8 +216,7 @@ test.describe('Create Workspace', () => {
const customLocation = await createTmpDir('custom-ws-location');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Start inline creation and click settings icon to open advanced modal', async () => {
await page.locator('.workspace-name-container').click();
@@ -296,8 +290,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-modal-default');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Start inline creation and open advanced modal', async () => {
await page.locator('.workspace-name-container').click();
@@ -338,8 +331,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-modal-cancel');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Start inline creation and open advanced modal', async () => {
await page.locator('.workspace-name-container').click();
@@ -366,8 +358,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-modal-empty');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Start inline creation and open advanced modal', async () => {
await page.locator('.workspace-name-container').click();
@@ -438,8 +429,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-display');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create a workspace with specific name', async () => {
await page.locator('.workspace-name-container').click();
@@ -470,8 +460,7 @@ test.describe('Create Workspace', () => {
// First launch: create workspace
const app1 = await launchElectronApp({ userDataPath, initUserDataPath, templateVars: { wsLocation } });
const page1 = await app1.firstWindow();
await page1.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page1 = await waitForReadyPage(app1);
await test.step('Create workspace', async () => {
await page1.locator('.workspace-name-container').click();
@@ -487,8 +476,7 @@ test.describe('Create Workspace', () => {
// Second launch: verify name persists (reuse same userDataPath)
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
await test.step('Verify workspace name persisted', async () => {
await page2.locator('.workspace-name-container').click();
@@ -505,8 +493,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-multiple');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create first workspace', async () => {
await page.locator('.workspace-name-container').click();
@@ -515,7 +502,9 @@ test.describe('Create Workspace', () => {
await expect(renameInput).toBeVisible({ timeout: 5000 });
await renameInput.fill('Workspace One');
await renameInput.press('Enter');
await expect(page.getByText('Workspace created!')).toBeVisible({ timeout: 10000 });
await expect(page.getByText('Workspace created!')).toBeVisible({ timeout: 5000 });
// Wait for the first toast to dismiss
await expect(page.getByText('Workspace created!')).toBeHidden();
await expect(page.getByTestId('workspace-name')).toHaveText('Workspace One', { timeout: 5000 });
});
@@ -526,7 +515,9 @@ test.describe('Create Workspace', () => {
await expect(renameInput).toBeVisible({ timeout: 5000 });
await renameInput.fill('Workspace Two');
await renameInput.press('Enter');
await expect(page.getByText('Workspace created!')).toBeVisible({ timeout: 10000 });
await expect(page.getByText('Workspace created!')).toBeVisible({ timeout: 5000 });
// Wait for the first toast to dismiss
await expect(page.getByText('Workspace created!')).toBeHidden();
await expect(page.getByTestId('workspace-name')).toHaveText('Workspace Two', { timeout: 5000 });
});
@@ -550,8 +541,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-cancel-retry');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Start creation and cancel with Escape', async () => {
await page.locator('.workspace-name-container').click();
@@ -579,8 +569,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-special');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create workspace with special characters in name', async () => {
await page.locator('.workspace-name-container').click();
@@ -610,8 +599,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-empty');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create workspace and clear name', async () => {
await page.locator('.workspace-name-container').click();
@@ -639,8 +627,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-no-cog');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create a workspace first', async () => {
await page.locator('.workspace-name-container').click();
@@ -678,8 +665,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-switch');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Create a new workspace', async () => {
await page.locator('.workspace-name-container').click();
@@ -715,8 +701,7 @@ test.describe('Create Workspace', () => {
const wsLocation = await createTmpDir('ws-location-no-temp');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Start creation but do not confirm', async () => {
await page.locator('.workspace-name-container').click();

View File

@@ -1,15 +1,14 @@
import path from 'path';
import fs from 'fs';
import { test, expect, closeElectronApp } from '../../../playwright';
import { waitForReadyPage } from '../../utils/page';
test.describe('Default Workspace', () => {
test.describe('First Launch', () => {
test('should create default workspace with "My Workspace" name on first launch', async ({ launchElectronApp, createTmpDir }) => {
const userDataPath = await createTmpDir('default-workspace-first-launch');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
// Verify the workspace name is "My Workspace" in the title bar
const workspaceName = page.getByTestId('workspace-name');
@@ -25,16 +24,14 @@ test.describe('Default Workspace', () => {
// First launch
const app1 = await launchElectronApp({ userDataPath });
const page1 = await app1.firstWindow();
await page1.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page1 = await waitForReadyPage(app1);
await expect(page1.getByTestId('workspace-name')).toHaveText('My Workspace');
await closeElectronApp(app1);
// Second launch - same workspace should be loaded
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
await expect(page2.getByTestId('workspace-name')).toHaveText('My Workspace');
await closeElectronApp(app2);
@@ -63,8 +60,7 @@ test.describe('Default Workspace', () => {
// Launch app - should create NEW workspace
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
// Should show "My Workspace"
await expect(page.getByTestId('workspace-name')).toHaveText('My Workspace');
@@ -100,8 +96,7 @@ test.describe('Default Workspace', () => {
// Launch app - should create NEW workspace
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await expect(page.getByTestId('workspace-name')).toHaveText('My Workspace');
@@ -143,8 +138,7 @@ docs: ''
// Launch app
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await expect(page.getByTestId('workspace-name')).toHaveText('My Workspace');
@@ -171,8 +165,7 @@ docs: ''
// Launch app
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await expect(page.getByTestId('workspace-name')).toHaveText('My Workspace');
@@ -189,9 +182,7 @@ docs: ''
test('should display default workspace in workspace dropdown', async ({ launchElectronApp, createTmpDir }) => {
const userDataPath = await createTmpDir('default-workspace-ui-dropdown');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
// Click on workspace name to open dropdown
await page.locator('.workspace-name-container').click();
@@ -206,9 +197,7 @@ docs: ''
test('should not show pin button for default workspace', async ({ launchElectronApp, createTmpDir }) => {
const userDataPath = await createTmpDir('default-workspace-ui-no-pin');
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await page.locator('.workspace-name-container').click();

View File

@@ -1,6 +1,7 @@
import path from 'path';
import fs from 'fs';
import { test, expect, closeElectronApp } from '../../../playwright';
import { waitForReadyPage } from '../../utils/page';
const env = {
DISABLE_SAMPLE_COLLECTION_IMPORT: 'false'
@@ -31,8 +32,7 @@ test.describe('Default Workspace Migration', () => {
});
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Verify workspace UI', async () => {
await expect(page.getByTestId('workspace-name')).toHaveText('My Workspace');
@@ -83,8 +83,7 @@ test.describe('Default Workspace Migration', () => {
// Launch app
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await expect(page.getByTestId('workspace-name')).toHaveText('My Workspace');
@@ -126,8 +125,7 @@ test.describe('Default Workspace Migration', () => {
// Launch app - sample collection should NOT be created (existing user)
const app = await launchElectronApp({ userDataPath, dotEnv: env });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
// Verify default workspace is created
await expect(page.getByTestId('workspace-name')).toHaveText('My Workspace');
@@ -146,8 +144,7 @@ test.describe('Default Workspace Migration', () => {
// First launch - creates workspace
const app1 = await launchElectronApp({ userDataPath });
const page1 = await app1.firstWindow();
await page1.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page1 = await waitForReadyPage(app1);
await expect(page1.getByTestId('workspace-name')).toHaveText('My Workspace');
// Verify initial workspace was created
@@ -159,8 +156,7 @@ test.describe('Default Workspace Migration', () => {
// Second launch - should reuse existing workspace
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page2 = await waitForReadyPage(app2);
await expect(page2.getByTestId('workspace-name')).toHaveText('My Workspace');
// workspace.yml should NOT have been modified
@@ -180,8 +176,7 @@ test.describe('Default Workspace Migration', () => {
// Launch with completely empty user data (no preferences file)
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await expect(page.getByTestId('workspace-name')).toHaveText('My Workspace');

View File

@@ -1,6 +1,7 @@
import path from 'path';
import fs from 'fs';
import { test, expect, closeElectronApp } from '../../../playwright';
import { waitForReadyPage } from '../../utils/page';
test.describe('Default Workspace Recovery and Backup', () => {
test.describe('Global Environments Backup', () => {
@@ -46,8 +47,7 @@ test.describe('Default Workspace Recovery and Backup', () => {
// Launch app - should trigger migration and create backup
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app);
// Verify backup file was created
const backupPath = path.join(userDataPath, 'global-environments-backup.json');
@@ -93,8 +93,8 @@ test.describe('Default Workspace Recovery and Backup', () => {
// First launch
const app1 = await launchElectronApp({ userDataPath });
const page1 = await app1.firstWindow();
await page1.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app1);
await closeElectronApp(app1);
// Verify backup exists
@@ -104,8 +104,7 @@ test.describe('Default Workspace Recovery and Backup', () => {
// Second launch - backup should still exist
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app2);
// Backup should not be modified on second launch
expect(fs.existsSync(backupPath)).toBe(true);
@@ -136,8 +135,8 @@ test.describe('Default Workspace Recovery and Backup', () => {
// Launch app - triggers migration
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app);
await closeElectronApp(app);
// Verify lastOpenedCollections is still in preferences
@@ -177,8 +176,7 @@ docs: ''
// Launch app - should discover and use existing workspace
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
// UI always shows "My Workspace"
await expect(page.getByTestId('workspace-name')).toHaveText('My Workspace');
@@ -225,8 +223,7 @@ docs: ''
// Launch app - should use workspace-2 (latest/highest number)
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await expect(page.getByTestId('workspace-name')).toHaveText('My Workspace');
@@ -288,8 +285,7 @@ docs: ''
// Launch app - should skip workspace-2, use workspace-1
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await expect(page.getByTestId('workspace-name')).toHaveText('My Workspace');
@@ -345,8 +341,7 @@ docs: ''
// Launch app - should recover collections and create new workspace
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app);
// New workspace should be created
const newWorkspace = path.join(userDataPath, 'default-workspace-1');
@@ -416,8 +411,7 @@ docs: ''
// Launch app
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app);
// New workspace should have recovered environments
const newWorkspace = path.join(userDataPath, 'default-workspace-1');
@@ -456,8 +450,7 @@ docs: ''
// Launch app
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app);
// New workspace should have the collection from lastOpenedCollections
const newWorkspace = path.join(userDataPath, 'default-workspace-1');
@@ -510,8 +503,7 @@ docs: ''
// Launch app - should find and use the existing valid workspace
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await expect(page.getByTestId('workspace-name')).toHaveText('My Workspace');
@@ -591,8 +583,7 @@ docs: ''
// Launch app - should use workspace-1 (latest valid)
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await expect(page.getByTestId('workspace-name')).toHaveText('My Workspace');
@@ -620,8 +611,7 @@ docs: ''
// First launch - creates workspace
const app1 = await launchElectronApp({ userDataPath });
const page1 = await app1.firstWindow();
await page1.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app1);
// Verify workspace was created
const workspacePath = path.join(userDataPath, 'default-workspace');
@@ -666,8 +656,7 @@ variables:
// Second launch - should recover
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app2);
// New workspace should exist
const newWorkspace = path.join(userDataPath, 'default-workspace-1');
@@ -684,8 +673,7 @@ variables:
// First launch - creates workspace
const app1 = await launchElectronApp({ userDataPath });
const page1 = await app1.firstWindow();
await page1.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app1);
const workspacePath = path.join(userDataPath, 'default-workspace');
expect(fs.existsSync(workspacePath)).toBe(true);
@@ -698,8 +686,7 @@ variables:
// Second launch - should create new workspace
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app2);
// New workspace should be created at default-workspace (since it was deleted)
expect(fs.existsSync(workspacePath)).toBe(true);
@@ -727,8 +714,8 @@ variables:
// First launch
const app1 = await launchElectronApp({ userDataPath });
const page1 = await app1.firstWindow();
await page1.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app1);
await closeElectronApp(app1);
// Verify workspace-0 created
@@ -750,8 +737,8 @@ variables: []
// Second launch - recovery to workspace-1
const app2 = await launchElectronApp({ userDataPath });
const page2 = await app2.firstWindow();
await page2.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app2);
await closeElectronApp(app2);
// Verify workspace-1 created with recovered data
@@ -767,8 +754,7 @@ variables: []
// Third launch - recovery to workspace-2
const app3 = await launchElectronApp({ userDataPath });
const page3 = await app3.firstWindow();
await page3.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app3);
// Verify workspace-2 created with all data preserved
const ws2 = path.join(userDataPath, 'default-workspace-2');
@@ -798,8 +784,7 @@ variables: []
);
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app);
// Should not crash, new workspace created
const newWorkspace = path.join(userDataPath, 'default-workspace-1');
@@ -822,8 +807,7 @@ variables: []
);
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app);
// Should not crash
expect(fs.existsSync(path.join(userDataPath, 'default-workspace-1'))).toBe(true);
@@ -859,8 +843,7 @@ variables: []
);
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app);
// New workspace should have collection only ONCE (no duplicates)
const newWorkspace = path.join(userDataPath, 'default-workspace-1');
@@ -918,8 +901,7 @@ variables:
);
const app = await launchElectronApp({ userDataPath });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
await waitForReadyPage(app);
// Check new workspace has the recovered environment (not overwritten by global)
const newWorkspace = path.join(userDataPath, 'default-workspace-1');

View File

@@ -2,7 +2,7 @@ import path from 'path';
import fs from 'fs';
import yaml from 'js-yaml';
import { test, expect, closeElectronApp } from '../../../playwright';
import { switchWorkspace, createCollection } from '../../utils/page';
import { switchWorkspace, createCollection, waitForReadyPage } from '../../utils/page';
type CollectionEntry = { name?: string; path?: string; remote?: string };
type WorkspaceConfig = { collections?: CollectionEntry[] };
@@ -40,8 +40,7 @@ test.describe('Git-backed collections', () => {
await copyFixture('workspace-with-collection', workspacePath);
const app = await launchElectronApp({ initUserDataPath, templateVars: { workspacePath } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await switchWorkspace(page, FIXTURE_WS_NAME);
@@ -88,8 +87,7 @@ test.describe('Git-backed collections', () => {
await copyFixture('workspace-with-collection', workspacePath);
const app = await launchElectronApp({ initUserDataPath, templateVars: { workspacePath } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await switchWorkspace(page, FIXTURE_WS_NAME);
@@ -140,8 +138,7 @@ test.describe('Git-backed collections', () => {
await copyFixture('workspace-with-collection', workspacePath);
const app = await launchElectronApp({ initUserDataPath, templateVars: { workspacePath } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await switchWorkspace(page, FIXTURE_WS_NAME);
@@ -187,8 +184,7 @@ test.describe('Git-backed collections', () => {
const collectionDir = await createTmpDir('git-default-coll');
const app = await launchElectronApp();
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await test.step('Verify we are on the default workspace', async () => {
await expect(page.getByTestId('workspace-name')).toHaveText('My Workspace', { timeout: 5000 });
@@ -221,8 +217,7 @@ test.describe('Git-backed collections', () => {
await copyFixture('workspace-with-ghost', workspacePath);
const app = await launchElectronApp({ initUserDataPath, templateVars: { workspacePath } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await switchWorkspace(page, GHOST_WS_NAME);
@@ -253,8 +248,7 @@ test.describe('Git-backed collections', () => {
await copyFixture('workspace-with-ghost', workspacePath);
const app = await launchElectronApp({ initUserDataPath, templateVars: { workspacePath } });
const page = await app.firstWindow();
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });
const page = await waitForReadyPage(app);
await switchWorkspace(page, GHOST_WS_NAME);