mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-02 17:08:32 +00:00
feat: snapshot issues with global tabs (#7942)
* chore: fix for sidebar state * fix: global and sidebar state sync * fix: re-priroritise how tab uid is synced
This commit is contained in:
59
tests/snapshots/global-tabs.spec.ts
Normal file
59
tests/snapshots/global-tabs.spec.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { test, expect, closeElectronApp } from '../../playwright';
|
||||
import {
|
||||
createCollection,
|
||||
createRequest,
|
||||
openRequest,
|
||||
createEnvironment
|
||||
} from '../utils/page';
|
||||
import { buildCommonLocators } from '../utils/page/locators';
|
||||
|
||||
test.describe('Snapshot: Global Tab Restoration', () => {
|
||||
test('preferences and global environment tabs are restored and reusable after restart', async ({ launchElectronApp, createTmpDir }) => {
|
||||
const userDataPath = await createTmpDir('snap-global-tabs');
|
||||
const colPath = await createTmpDir('col');
|
||||
|
||||
const app = await launchElectronApp({ userDataPath });
|
||||
const page = await app.firstWindow();
|
||||
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);
|
||||
await createRequest(page, 'ReqAlpha', 'TestCol', { url: 'https://echo.usebruno.com', method: 'GET' });
|
||||
await openRequest(page, 'TestCol', 'ReqAlpha', { persist: true });
|
||||
|
||||
await createEnvironment(page, 'GlobalSnapEnv', 'global');
|
||||
await expect(locators.tabs.requestTab('Global Environments')).toHaveCount(1);
|
||||
|
||||
await locators.openPreferences().click();
|
||||
await expect(locators.tabs.requestTab('Preferences')).toHaveCount(1);
|
||||
});
|
||||
|
||||
await test.step('Close and restart app', async () => {
|
||||
await page.waitForTimeout(2000);
|
||||
await closeElectronApp(app);
|
||||
});
|
||||
|
||||
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 locators2 = buildCommonLocators(page2);
|
||||
|
||||
await expect(locators2.tabs.requestTab('Preferences')).toHaveCount(1, { timeout: 15000 });
|
||||
await expect(locators2.tabs.requestTab('Global Environments')).toHaveCount(1, { timeout: 15000 });
|
||||
|
||||
await locators2.tabs.requestTab('Preferences').click();
|
||||
await expect(locators2.tabs.activeRequestTab()).toContainText('Preferences');
|
||||
|
||||
await locators2.tabs.requestTab('Global Environments').click();
|
||||
await expect(locators2.tabs.activeRequestTab()).toContainText('Global Environments');
|
||||
|
||||
await locators2.openPreferences().click();
|
||||
await expect(locators2.tabs.requestTab('Preferences')).toHaveCount(1);
|
||||
|
||||
await closeElectronApp(app2);
|
||||
});
|
||||
});
|
||||
});
|
||||
80
tests/snapshots/sidebar-state.spec.ts
Normal file
80
tests/snapshots/sidebar-state.spec.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
import { test, expect, closeElectronApp, type Page } from '../../playwright';
|
||||
import {
|
||||
createCollection,
|
||||
createRequest,
|
||||
openRequest
|
||||
} from '../utils/page';
|
||||
import { buildCommonLocators } from '../utils/page/locators';
|
||||
|
||||
test.describe('Snapshot: Sidebar-Tab Restoration', () => {
|
||||
test('open tabs are restored after app restart and tied to the sidebar items', async ({ launchElectronApp, createTmpDir }) => {
|
||||
const userDataPath = await createTmpDir('snap-sidebar-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 });
|
||||
|
||||
await test.step('Create collection with a request open it', async () => {
|
||||
await createCollection(page, 'TestCol', colPath);
|
||||
await createRequest(page, 'ReqAlpha', 'TestCol', { url: 'https://echo.usebruno.com', method: 'GET' });
|
||||
await openRequest(page, 'TestCol', 'ReqAlpha', { persist: true });
|
||||
});
|
||||
|
||||
await test.step('Close and restart app', async () => {
|
||||
// Wait for debounced snapshot save to flush
|
||||
await page.waitForTimeout(2000);
|
||||
await closeElectronApp(app);
|
||||
});
|
||||
|
||||
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 locators = buildCommonLocators(page2);
|
||||
await openRequest(page2, 'TestCol', 'ReqAlpha', { persist: true });
|
||||
|
||||
await expect(locators.tabs.requestTab('ReqAlpha')).toHaveCount(1);
|
||||
|
||||
await closeElectronApp(app2);
|
||||
});
|
||||
});
|
||||
|
||||
test('restored request tab is reused on subsequent sidebar clicks', async ({ launchElectronApp, createTmpDir }) => {
|
||||
const userDataPath = await createTmpDir('snap-sidebar-reuse');
|
||||
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 });
|
||||
|
||||
await test.step('Create collection and keep one request tab open', async () => {
|
||||
await createCollection(page, 'TestCol', colPath);
|
||||
await createRequest(page, 'ReqAlpha', 'TestCol', { url: 'https://echo.usebruno.com', method: 'GET' });
|
||||
await openRequest(page, 'TestCol', 'ReqAlpha', { persist: true });
|
||||
});
|
||||
|
||||
await test.step('Close and restart app', async () => {
|
||||
await page.waitForTimeout(2000);
|
||||
await closeElectronApp(app);
|
||||
});
|
||||
|
||||
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 locators = buildCommonLocators(page2);
|
||||
await expect(locators.tabs.requestTab('ReqAlpha')).toHaveCount(1, { timeout: 15000 });
|
||||
|
||||
await openRequest(page2, 'TestCol', 'ReqAlpha');
|
||||
await expect(locators.tabs.requestTab('ReqAlpha')).toHaveCount(1);
|
||||
|
||||
await openRequest(page2, 'TestCol', 'ReqAlpha', { persist: true });
|
||||
await expect(locators.tabs.requestTab('ReqAlpha')).toHaveCount(1);
|
||||
|
||||
await closeElectronApp(app2);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -5,6 +5,7 @@ export const buildCommonLocators = (page: Page) => ({
|
||||
saveButton: () => page
|
||||
.locator('.infotip')
|
||||
.filter({ hasText: /^Save/ }),
|
||||
openPreferences: () => page.getByRole('button', { name: 'Open Preferences' }),
|
||||
sidebar: {
|
||||
collectionsContainer: () => page.getByTestId('collections'),
|
||||
collection: (name: string) => page.locator('#sidebar-collection-name').filter({ hasText: name }),
|
||||
|
||||
Reference in New Issue
Block a user