From 39308bc03cb158777cb16dd7339192e9cc777029 Mon Sep 17 00:00:00 2001 From: DeviSriSaiCharan Date: Mon, 25 May 2026 20:57:11 +0530 Subject: [PATCH 1/2] fix: prevent success toast when workspace selection is cancelled --- packages/bruno-app/src/components/AppTitleBar/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/bruno-app/src/components/AppTitleBar/index.js b/packages/bruno-app/src/components/AppTitleBar/index.js index 3551556dd..2e2dff474 100644 --- a/packages/bruno-app/src/components/AppTitleBar/index.js +++ b/packages/bruno-app/src/components/AppTitleBar/index.js @@ -152,8 +152,10 @@ const AppTitleBar = () => { const handleOpenWorkspace = async () => { try { - await dispatch(openWorkspaceDialog()); - toast.success('Workspace opened successfully'); + const result = await dispatch(openWorkspaceDialog()); + if (result) { + toast.success('Workspace opened successfully'); + } } catch (error) { toast.error(error.message || 'Failed to open workspace'); } From 472241b51c06f2c2757b2eddd1c60e766e74e2cc Mon Sep 17 00:00:00 2001 From: abhishekp-bruno Date: Fri, 29 May 2026 16:17:53 +0530 Subject: [PATCH 2/2] fix: return null when workspace selection is cancelled in openWorkspaceDialog --- .../ReduxStore/slices/workspaces/actions.js | 2 + .../open-workspace/open-workspace.spec.ts | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/workspace/open-workspace/open-workspace.spec.ts diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js b/packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js index 27caa3a65..a8ff6d63c 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js @@ -250,6 +250,8 @@ export const openWorkspaceDialog = () => { await dispatch(switchWorkspace(workspaceUid)); return result; + } else { + return null; } } catch (error) { throw error; diff --git a/tests/workspace/open-workspace/open-workspace.spec.ts b/tests/workspace/open-workspace/open-workspace.spec.ts new file mode 100644 index 000000000..8984c9e3d --- /dev/null +++ b/tests/workspace/open-workspace/open-workspace.spec.ts @@ -0,0 +1,38 @@ +import type { ElectronApplication } from '@playwright/test'; +import { expect, test } from '../../../playwright'; +import { buildCommonLocators, waitForReadyPage } from '../../utils/page'; + +test.describe('Open Workspace', () => { + test('click on cancel button, should just close the dialog', async ({ + launchElectronApp, + createTmpDir + }) => { + const userDataPath = await createTmpDir('open-workspace-cancel'); + + let app: ElectronApplication = await launchElectronApp({ userDataPath }); + const page = await waitForReadyPage(app); + const locators = buildCommonLocators(page); + + const initialWorkspaceName = await page + .getByTestId('workspace-name') + .textContent(); + + await app.evaluate(({ dialog }) => { + ( + dialog as { showOpenDialog: typeof dialog.showOpenDialog } + ).showOpenDialog = () => + Promise.resolve({ canceled: true, filePaths: [] }); + }); + + await test.step('Open the workspace menu and click "Open workspace"', async () => { + await page.getByTestId('workspace-menu').click(); + await locators.dropdown.item('Open workspace').click(); + }); + + await test.step('Workspace unchanged after canceling the dialog', async () => { + expect(initialWorkspaceName).not.toBeNull(); + const workspaceName = initialWorkspaceName as string; + await expect(page.getByTestId('workspace-name')).toHaveText(workspaceName); + }); + }); +});