mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
fix: return null when workspace selection is cancelled in openWorkspaceDialog
This commit is contained in:
@@ -250,6 +250,8 @@ export const openWorkspaceDialog = () => {
|
|||||||
await dispatch(switchWorkspace(workspaceUid));
|
await dispatch(switchWorkspace(workspaceUid));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
38
tests/workspace/open-workspace/open-workspace.spec.ts
Normal file
38
tests/workspace/open-workspace/open-workspace.spec.ts
Normal 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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user