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); + }); + }); +});