Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion e2e/pages/app-shell/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ export const buildRequestTabsLocators = (page: Page) => ({
collectionSettingsTab: () =>
page.locator('.request-tab').filter({ has: page.locator('.tab-label', { hasText: 'Collection' }) }),
activeRequestTab: () => page.locator('.request-tab.active'),
workspaceTab: (type: 'workspaceOverview' | 'workspaceEnvironments') => page.getByTestId(`request-tab-${type}`),
leftChevron: () => page.getByLabel('Left Chevron'),
scrollContainer: () => page.locator('.tabs-scroll-container'),
activeRequestTabLabel: () => page.locator('.request-tab.active').getByTestId('request-tab-label'),
// The request tab's right-click menu; `key` is the menu item id (e.g. 'clone-request').
requestTabMenuItem: (key: string) => page.getByTestId(`menu-dropdown-${key}`),
activeRequestTabMethod: () => page.locator('.request-tab.active .tab-method'),
closeTab: (requestName: string) => page.locator('.request-tab').filter({ hasText: requestName }).getByTestId('request-tab-close-icon'),
closableTabs: () => page.locator('.request-tab').filter({ has: page.getByTestId('request-tab-close-icon') }),
// Workspace tabs (Overview, Environments) are closable but not part of a collection's tabs
closableTabs: () => page.locator('.request-tab')
.filter({ has: page.getByTestId('request-tab-close-icon') })
.filter({ hasNot: page.getByTestId('request-tab-workspaceOverview').or(page.getByTestId('request-tab-workspaceEnvironments')) }),
closeTabIcon: (tab: Locator) => tab.getByTestId('request-tab-close-icon'),
draftIndicator: () => page.locator('.request-tab.active .has-changes-icon'),
activeTabDirty: () => page.locator('.request-tab.active .close-gradient.has-changes'),
Expand Down
1 change: 1 addition & 0 deletions e2e/pages/app-shell/title-bar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Page, test } from '../../playwright';

export const buildTitleBarLocators = (page: Page) => ({
homeButton: () => page.getByTestId('app-titlebar').getByTestId('home-button'),
workspaceMenuTrigger: () => page.getByTestId('workspace-menu'),
activeWorkspaceName: () => page.getByTestId('workspace-menu').getByTestId('workspace-name'),
createWorkspaceOption: () => page.getByTestId('workspace-menu-create-workspace'),
Expand Down
5 changes: 5 additions & 0 deletions e2e/pages/collection/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ export const buildCollectionHeaderLocators = (page: Page) => {
overflowMenu: () => collectionHeader.getByTestId('more-actions'),
overflowMenuItem: (itemId: string) => page.getByTestId(`more-actions-${itemId}`),
envSelectorTrigger: () => collectionHeader.getByTestId('environment-selector-trigger'),
actions: () => collectionHeader.getByTestId('collection-header-actions'),
envSelectorGlobalTitle: () => page.getByTestId('env-title-global'),
workspaceActionsTrigger: () => collectionHeader.getByTestId('collection-header-actions').getByTestId('workspace-actions-trigger'),
workspaceActionsItem: (itemId: string) => page.getByTestId(`workspace-actions-${itemId}`),
workspaceNameInput: () => collectionHeader.getByTestId('workspace-inline-name-input'),
openApiSync: () => collectionHeader.getByRole('button', { name: 'OpenAPI', exact: true })
};
};
2 changes: 1 addition & 1 deletion e2e/pages/collection/manage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
export const openCollection = async (page: Page, collectionName: string) => {
await test.step(`Open collection "${collectionName}"`, async () => {
await revealCollectionsTop(page);
await page.locator('#sidebar-collection-name').filter({ hasText: collectionName }).click();

Check failure on line 86 in e2e/pages/collection/manage.ts

View workflow job for this annotation

GitHub Actions / Playwright E2E Tests (Linux) 1/4

[default] › e2e/tests/apps/apps-ui.spec.ts:195:7 › Apps - request-level UI › TC-3375 Enable App and code persist; an enabled app opens in preview mode by default

1) [default] › e2e/tests/apps/apps-ui.spec.ts:195:7 › Apps - request-level UI › TC-3375 Enable App and code persist; an enabled app opens in preview mode by default › Create yml collection "apps-persist" › Open collection "apps-persist" Error: locator.click: Target page, context or browser has been closed Call log: - waiting for locator('#sidebar-collection-name').filter({ hasText: 'apps-persist' }) - locator resolved to <div class="ml-1 min-w-0" title="apps-persist" id="sidebar-collection-name">apps-persist</div> - attempting click action - waiting for element to be visible, enabled and stable - element was detached from the DOM, retrying at e2e/pages/collection/manage.ts:86 84 | await test.step(`Open collection "${collectionName}"`, async () => { 85 | await revealCollectionsTop(page); > 86 | await page.locator('#sidebar-collection-name').filter({ hasText: collectionName }).click(); | ^ 87 | }); 88 | }; 89 | at /home/runner/work/bruno/bruno/e2e/pages/collection/manage.ts:86:88 at openCollection (/home/runner/work/bruno/bruno/e2e/pages/collection/manage.ts:84:3) at /home/runner/work/bruno/bruno/e2e/pages/collection/manage.ts:227:5 at createCollection (/home/runner/work/bruno/bruno/e2e/pages/collection/manage.ts:159:3) at /home/runner/work/bruno/bruno/e2e/tests/apps/apps-ui.spec.ts:197:5
});
};

Expand Down Expand Up @@ -254,7 +254,7 @@
await deleteModal.waitFor({ state: 'visible', timeout: 5000 });

// Type 'delete' to confirm
await deleteModal.locator('#delete-confirm-input').fill('delete');
await page.getByTestId('delete-collection-modal-confirm-input').fill('delete');

// Click the Delete button
await deleteModal.getByRole('button', { name: 'Delete', exact: true }).click();
Expand Down
20 changes: 18 additions & 2 deletions e2e/pages/environment/environment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Page, test } from '../../playwright';
import { buildTitleBarLocators } from '../app-shell/title-bar';
import { buildCollectionHeaderLocators } from '../collection/header';

export type EnvironmentScope = 'collection' | 'global';
Expand Down Expand Up @@ -346,11 +347,26 @@ export const selectNoEnvironment = async (page: Page) => {

/**
* Opens the workspace-level Environments tab, which edits global-scoped environments.
* The workspace header's environment selector offers Configure once an environment exists;
* with none, its Create dialog opens the tab after creating one (named by `firstEnvironmentName`).
* @param page - The page object
* @param firstEnvironmentName - Name for the environment created when the workspace has none
*/
export const openWorkspaceEnvironmentsTab = async (page: Page) => {
export const openWorkspaceEnvironmentsTab = async (page: Page, firstEnvironmentName = 'Default') => {
await test.step('Open the workspace Environments tab', async () => {
await buildEnvironmentLocators(page).workspaceEnvTab().click();
const locators = buildEnvironmentLocators(page);
await buildTitleBarLocators(page).homeButton().click();
await buildCollectionHeaderLocators(page).envSelectorTrigger().click();

const configureButton = locators.configureButton();
await configureButton.or(locators.createEnvButton()).waitFor();
if (await configureButton.isVisible()) {
await configureButton.click();
} else {
await locators.createEnvButton().click();
await locators.createModalNameInput().fill(firstEnvironmentName);
await locators.createModalCreateButton().click();
}
await page
.locator('.request-tab.active')
.locator('.tab-label')
Expand Down
5 changes: 5 additions & 0 deletions e2e/pages/locators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { buildSetAsVariableLocators } from './variable/set-as-variable';
import { buildDevToolsLocators } from './app-shell/devtools';
import { buildVariablesTabLocators } from './variable/variables-tab';
import { buildWorkspaceOverviewLocators } from './workspace/workspace-overview';
import { buildStartPageLocators } from './workspace/start-page';
import { buildDeleteWorkspaceModalLocators } from './workspace/delete-workspace-modal';
import { buildManageWorkspaceLocators } from './workspace/manage-workspace';
import { buildCreateWorkspaceModalLocators } from './workspace/create-workspace-modal';
import { buildTitleBarLocators } from './app-shell/title-bar';
Expand Down Expand Up @@ -94,6 +96,9 @@ export const buildCommonLocators = (page: Page) => ({
openPreferences: () => page.getByRole('button', { name: 'Open Preferences' }),
sidebar: buildSidebarLocators(page),
workspaceOverview: buildWorkspaceOverviewLocators(page),
startPage: buildStartPageLocators(page),
appCrashScreen: () => page.getByText('Oops! Something went wrong'),
deleteWorkspaceModal: buildDeleteWorkspaceModalLocators(page),
manageWorkspace: buildManageWorkspaceLocators(page),
createWorkspaceModal: buildCreateWorkspaceModalLocators(page),
cloneGitRepository: buildCloneGitRepositoryLocators(page),
Expand Down
11 changes: 11 additions & 0 deletions e2e/pages/workspace/delete-workspace-modal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Page } from '../../playwright';

export const buildDeleteWorkspaceModalLocators = (page: Page) => {
const modal = () => page.getByTestId('delete-workspace-modal');

return {
modal,
confirmInput: () => page.getByTestId('delete-workspace-modal-confirm-input'),
submitButton: () => page.getByTestId('delete-workspace-modal-submit-btn')
};
};
10 changes: 10 additions & 0 deletions e2e/pages/workspace/start-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Page } from '../../playwright';

type StartLink = 'overview' | 'open-or-import' | 'import' | 'open' | 'clone';
type CreateButton = 'http' | 'graphql' | 'grpc' | 'ws' | 'workspace' | 'collection' | 'environment' | 'api-spec' | 'mock-server';

export const buildStartPageLocators = (page: Page) => ({
root: () => page.getByTestId('start-page'),
link: (id: StartLink) => page.getByTestId(`start-page-${id}`),
createButton: (id: CreateButton) => page.getByTestId(`start-page-new-${id}`)
});
5 changes: 3 additions & 2 deletions e2e/tests/snapshots/global-tabs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
createEnvironment,
buildCommonLocators
} from '../../pages';
import { openWorkspaceEnvironmentsTab } from '../../pages/environment/environment';
import { waitForReadyPage } from '../../utils';

test.describe('Snapshot: Global Tab Restoration', () => {
Expand Down Expand Up @@ -62,9 +63,9 @@ test.describe('Snapshot: Global Tab Restoration', () => {
const app = await launchElectronApp({ userDataPath });
const page = await waitForReadyPage(app);

await test.step('Switch to workspace environments tab', async () => {
await test.step('Open the workspace environments tab', async () => {
const locators = buildCommonLocators(page);
await locators.tabs.requestTab('Environments').click();
await openWorkspaceEnvironmentsTab(page);
await expect(locators.tabs.activeRequestTab()).toContainText('Environments');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ test.describe('Close workspace returns to default workspace', () => {
await test.step('Close WorkspaceB via the workspace-actions ellipsis', async () => {
await expect(workspaceActionsTrigger).toBeVisible({ timeout: 10000 });
await workspaceActionsTrigger.click();
await locators.dropdown.item('Close').click();
await expect(locators.modal.byTitle('Close Workspace')).toBeVisible({ timeout: 5000 });
await locators.modal.button('Close').click();
await locators.dropdown.item('Remove').click();
await expect(locators.modal.byTitle('Remove Workspace')).toBeVisible({ timeout: 5000 });
await locators.modal.button('Remove').click();
});

await test.step('App returns to My Workspace, header reads "My Workspace", and ColA reloads', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import yaml from 'js-yaml';
import { test, expect, closeElectronApp } from '../../../playwright';
import { waitForReadyPage } from '../../../utils';
import { buildCreateWorkspaceModalLocators, openCreateWorkspaceModal } from '../../../pages/workspace/create-workspace-modal';
import { buildCollectionHeaderLocators } from '../../../pages/collection/header';

type WorkspaceConfig = {
opencollection?: string;
Expand Down Expand Up @@ -752,9 +753,9 @@ test.describe('Create Workspace', () => {

await test.step('Rename existing workspace - cog should NOT be visible', async () => {
// Use workspace actions dropdown to start rename
const actionsIcon = page.locator('.workspace-actions-trigger');
await actionsIcon.click();
await page.locator('.dropdown-item').filter({ hasText: 'Rename' }).click();
const collectionHeader = buildCollectionHeaderLocators(page);
await collectionHeader.workspaceActionsTrigger().click();
await collectionHeader.workspaceActionsItem('rename').click();

// Inline rename input should appear
await expect(page.locator('.workspace-name-input')).toBeVisible({ timeout: 5000 });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import path from 'path';
import { test, expect, closeElectronApp } from '../../../playwright';
import { buildCommonLocators, createTransientRequestFromPreset } from '../../../pages';
import { openWorkspaceEnvironmentsTab, SELECT_MODIFIER } from '../../../pages/environment/environment';
import { waitForReadyPage } from '../../../utils';

const initUserDataPath = path.join(__dirname, 'init-user-data');

test.describe('Closable workspace tabs', () => {
test('Overview and Environments close like any tab, and closing every tab shows the start page', async ({ launchElectronApp, createTmpDir }) => {
const wsLocation = await createTmpDir('closable-workspace-tabs');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await waitForReadyPage(app);
const { tabs, startPage, titleBar } = buildCommonLocators(page);
const overviewTab = tabs.workspaceTab('workspaceOverview');
const environmentsTab = tabs.workspaceTab('workspaceEnvironments');

try {
await test.step('The workspace opens on Overview, which has a close button', async () => {
await expect(overviewTab).toBeVisible();
await expect(tabs.closeTabIcon(overviewTab)).toHaveCount(1);
});

await test.step('Environments closes with its close button and focus returns to Overview', async () => {
await openWorkspaceEnvironmentsTab(page);
await expect(tabs.closeTabIcon(environmentsTab)).toHaveCount(1);

await tabs.closeTabIcon(environmentsTab).click({ force: true });

await expect(environmentsTab).toHaveCount(0);
await expect(tabs.activeRequestTab()).toContainText('Overview');
});

await test.step('Closing the last tab with the keyboard shows the start page', async () => {
await page.keyboard.press(`${SELECT_MODIFIER}+w`);

await expect(overviewTab).toHaveCount(0);
await expect(startPage.root()).toBeVisible();
await expect(tabs.activeRequestTab()).toHaveCount(0);
});

await test.step('The Home button brings Overview back', async () => {
await titleBar.homeButton().click();

await expect(overviewTab).toBeVisible();
await expect(startPage.root()).toHaveCount(0);
});
} finally {
await closeElectronApp(app);
}
});

test('closing a workspace with an unsaved request open returns to the default workspace without crashing', async ({ launchElectronApp, createTmpDir }) => {
const wsLocation = await createTmpDir('closable-workspace-tabs-transient');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await waitForReadyPage(app);
const { tabs, startPage, collectionHeader, modal, titleBar, appCrashScreen } = buildCommonLocators(page);
const overviewTab = tabs.workspaceTab('workspaceOverview');

try {
await test.step('Create a second workspace from the start page', async () => {
await expect(overviewTab).toBeVisible();
await page.keyboard.press(`${SELECT_MODIFIER}+w`);
await startPage.createButton('workspace').click();
await expect(overviewTab).toBeVisible();

const nameInput = collectionHeader.workspaceNameInput();
await expect(nameInput).toBeVisible();
await nameInput.press('Enter');
await expect(nameInput).toHaveCount(0);
});

await createTransientRequestFromPreset(page);

await test.step('Closing the workspace returns to the default workspace, not the crash screen', async () => {
await collectionHeader.workspaceActionsTrigger().click();
await collectionHeader.workspaceActionsItem('remove').click();
await expect(modal.byTitle('Remove Workspace')).toBeVisible();
await modal.button('Remove').click();

await expect(appCrashScreen()).toHaveCount(0);
await expect(titleBar.activeWorkspaceName()).toHaveText('My Workspace');
});
} finally {
await closeElectronApp(app);
}
});
});
54 changes: 54 additions & 0 deletions e2e/tests/workspace/workspace-ux/delete-workspace.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import path from 'path';
import fs from 'fs';
import { test, expect, closeElectronApp } from '../../../playwright';
import { buildCommonLocators, createCollection, createWorkspace } from '../../../pages';
import { waitForReadyPage } from '../../../utils';

const initUserDataPath = path.join(__dirname, 'init-user-data');

test.describe('Delete workspace', () => {
test('deletes the workspace folder with its inner collections and keeps outside collections', async ({ launchElectronApp, createTmpDir }) => {
const wsLocation = await createTmpDir('delete-workspace');
const outsideLocation = await createTmpDir('delete-workspace-outside');
const workspaceFolder = path.join(wsLocation, 'Delete Me WS');
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await waitForReadyPage(app);
const { titleBar, collectionHeader, deleteWorkspaceModal } = buildCommonLocators(page);

try {
await test.step('Create a workspace with one collection inside its folder and one outside', async () => {
await createWorkspace(page, 'Delete Me WS');
await expect.poll(() => fs.existsSync(path.join(workspaceFolder, 'workspace.yml'))).toBe(true);

await createCollection(page, 'Inner Col', workspaceFolder);
await createCollection(page, 'Outer Col', outsideLocation);
});

await test.step('Delete stays disabled until "delete" is typed', async () => {
await titleBar.homeButton().click();
await collectionHeader.workspaceActionsTrigger().click();
await collectionHeader.workspaceActionsItem('delete').click();

await expect(deleteWorkspaceModal.modal()).toBeVisible();
await expect(deleteWorkspaceModal.submitButton()).toBeDisabled();

await deleteWorkspaceModal.confirmInput().fill('delete');
await expect(deleteWorkspaceModal.submitButton()).toBeEnabled();
});

await test.step('Confirming deletes the folder and lands on My Workspace', async () => {
await deleteWorkspaceModal.submitButton().click();

await expect(deleteWorkspaceModal.modal()).toHaveCount(0);
await expect(titleBar.activeWorkspaceName()).toHaveText('My Workspace');
await expect.poll(() => fs.existsSync(workspaceFolder)).toBe(false);
});

await test.step('The collection stored outside the workspace folder is kept', async () => {
expect(fs.existsSync(path.join(outsideLocation, 'Outer Col'))).toBe(true);
});
} finally {
await closeElectronApp(app);
}
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"preferences": {
"onboarding": {
"hasLaunchedBefore": true,
"hasSeenWelcomeModal": true
},
"general": {
"defaultLocation": "{{wsLocation}}"
}
}
}
48 changes: 48 additions & 0 deletions e2e/tests/workspace/workspace-ux/lands-on-overview.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import path from 'path';
import { test, expect, closeElectronApp } from '../../../playwright';
import { buildCommonLocators, createCollection, createRequest, createWorkspace, openRequest, switchWorkspace } from '../../../pages';
import { readSnapshot, waitForReadyPage } from '../../../utils';

const initUserDataPath = path.join(__dirname, 'init-user-data');

test.describe('Workspace landing tab', () => {
test('create and switch land on Overview, and switching back restores the last request', async ({ launchElectronApp, createTmpDir }) => {
const wsLocation = await createTmpDir('lands-on-overview');
const collectionLocation = await createTmpDir('lands-on-overview-col');
const userDataPath = await createTmpDir('lands-on-overview-userdata');
const app = await launchElectronApp({ initUserDataPath, userDataPath, templateVars: { wsLocation } });
const page = await waitForReadyPage(app);
const { tabs } = buildCommonLocators(page);
const snapshot = () => readSnapshot(userDataPath);

try {
await test.step('A newly created workspace opens on Overview', async () => {
await createWorkspace(page, 'Landing WS');
await expect(tabs.activeRequestTab()).toContainText('Overview');
});

await test.step('Open a request in that workspace', async () => {
await createCollection(page, 'Landing Col', collectionLocation);
await createRequest(page, 'Landing Req', 'Landing Col', { url: 'https://echo.usebruno.com', method: 'GET' });
await openRequest(page, 'Landing Col', 'Landing Req', { persist: true });
await expect(tabs.activeRequestTab()).toContainText('Landing Req');
});

await test.step('Switching to a workspace with nothing to restore lands on Overview', async () => {
// The last active tab is read from the snapshot, which is written on a short debounce
await expect.poll(() => snapshot()?.workspaces?.find((w) => w.pathname?.includes('Landing WS'))?.lastActiveCollectionPathname)
.toContain('Landing Col');
await switchWorkspace(page, 'My Workspace');
await expect(tabs.activeRequestTab()).toContainText('Overview');
});

await test.step('Switching back restores the request that was open', async () => {
await expect.poll(() => snapshot()?.activeWorkspacePath).not.toContain('Landing WS');
await switchWorkspace(page, 'Landing WS');
await expect(tabs.activeRequestTab()).toContainText('Landing Req');
});
} finally {
await closeElectronApp(app);
}
});
});
Loading
Loading