fix: return null when workspace selection is cancelled in openWorkspaceDialog

This commit is contained in:
abhishekp-bruno
2026-05-29 16:17:53 +05:30
parent 39308bc03c
commit 472241b51c
2 changed files with 40 additions and 0 deletions

View File

@@ -250,6 +250,8 @@ export const openWorkspaceDialog = () => {
await dispatch(switchWorkspace(workspaceUid));
return result;
} else {
return null;
}
} catch (error) {
throw error;

View File

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