Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/bruno-app/src/components/ManageWorkspace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import StyledWrapper from './StyledWrapper';
import MenuDropdown from 'ui/MenuDropdown/index';
import Button from 'ui/Button';
import { getRevealInFolderLabel } from 'utils/common/platform';
import { openDevtoolsAndSwitchToTerminal } from 'utils/terminal';

const ManageWorkspace = () => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -157,6 +158,7 @@ const ManageWorkspace = () => {
<MenuDropdown
placement="bottom-end"
items={[
{ id: 'open-in-terminal', label: 'Open in Terminal', onClick: () => openDevtoolsAndSwitchToTerminal(dispatch, workspace.pathname) },
{ id: 'rename', label: 'Rename', onClick: () => handleRenameClick(workspace) },
{ id: 'remove', label: 'Remove', onClick: () => handleCloseClick(workspace) }
]}
Expand Down
68 changes: 68 additions & 0 deletions tests/workspace/manage-workspace/manage-workspace.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import path from 'path';
import fs from 'fs';
import { test, expect, closeElectronApp } from '../../../playwright';

const initUserDataPath = path.join(__dirname, '../create-workspace/init-user-data');

function findCreatedWorkspaceDirs(location: string): string[] {
return fs.readdirSync(location).filter((e) => {
const fullPath = path.join(location, e);
return (
fs.statSync(fullPath).isDirectory()
&& e !== 'default-workspace'
&& fs.existsSync(path.join(fullPath, 'workspace.yml'))
);
});
}

test.describe('Manage Workspace', () => {
test('should open terminal from the workspace actions menu', async ({ launchElectronApp, createTmpDir }) => {
const wsLocation = await createTmpDir('ws-location-terminal');

const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
const page = await app.firstWindow();

try {
await page.locator('[data-app-state="loaded"]').waitFor({ timeout: 30000 });

await test.step('Create a workspace', async () => {
await page.locator('.workspace-name-container').click();
await page.locator('.dropdown-item').filter({ hasText: 'Create workspace' }).click();
const renameInput = page.locator('.workspace-name-input');
await expect(renameInput).toBeVisible({ timeout: 5000 });
await renameInput.fill('Terminal Workspace');
await renameInput.press('Enter');
await expect(page.getByText('Workspace created!')).toBeVisible({ timeout: 10000 });
});

const wsDirs = findCreatedWorkspaceDirs(wsLocation);
expect(wsDirs).toHaveLength(1);

await test.step('Open Manage Workspaces', async () => {
await page.locator('.workspace-name-container').click();
await page.locator('.dropdown-item').filter({ hasText: 'Manage workspaces' }).click();
await expect(page.getByText('Manage Workspace')).toBeVisible({ timeout: 5000 });
});

await test.step('Verify default workspace has no actions menu', async () => {
const defaultWorkspaceItem = page.locator('.workspace-item').filter({ hasText: 'My Workspace' });
await expect(defaultWorkspaceItem.locator('.more-actions-btn')).toHaveCount(0);
});

await test.step('Open terminal from workspace actions', async () => {
const workspaceItem = page.locator('.workspace-item').filter({ hasText: 'Terminal Workspace' });
await expect(workspaceItem).toBeVisible({ timeout: 5000 });
await workspaceItem.locator('.more-actions-btn').click();
await page.locator('.dropdown-item').filter({ hasText: 'Open in Terminal' }).click();
});

await test.step('Verify terminal session opens at the workspace folder', async () => {
const terminalSession = page.getByTestId('session-list-0');
await expect(terminalSession).toBeVisible({ timeout: 5000 });
await expect(terminalSession).toContainText(wsDirs[0]);
});
} finally {
await closeElectronApp(app);
}
});
});
Loading