mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
Merge pull request #8146 from abhishekp-bruno/bugfix/workspace-open-success-toast-on-cancel
Bugfix/workspace open success toast on cancel
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
@@ -250,6 +250,8 @@ export const openWorkspaceDialog = () => {
|
||||
await dispatch(switchWorkspace(workspaceUid));
|
||||
|
||||
return result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (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