Skip to content

test(workspace):Automation script for Renaming and removing the Workspace#8356

Open
guru-sharan-bruno wants to merge 9 commits into
usebruno:mainfrom
guru-sharan-bruno:BRU-3576
Open

test(workspace):Automation script for Renaming and removing the Workspace#8356
guru-sharan-bruno wants to merge 9 commits into
usebruno:mainfrom
guru-sharan-bruno:BRU-3576

Conversation

@guru-sharan-bruno

@guru-sharan-bruno guru-sharan-bruno commented Jun 24, 2026

Copy link
Copy Markdown

JIRA: https://usebruno.atlassian.net/browse/BRU-3576

Description

This JIRA ticket is about adding the sanity automation script for Open workspace and manage workspace.

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

Summary by CodeRabbit

  • Tests
    • Refactored workspace management tests to reuse a shared workspace setup flow and start from the “Manage Workspace” view.
    • Improved Open in Terminal assertions to validate the correct workspace context via UI state and the displayed terminal entry.
    • Added coverage for Rename Workspace and Remove Workspace, including modal confirmation and post-action verification.
    • Added an Electron-based Open workspace test for both successful opening (matching workspace name) and canceling (ensuring no change).

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The workspace action tests now use shared setup, cover terminal, rename, and remove flows, and add open-workspace coverage for dialog selection and cancel behavior. The ManageWorkspace actions button also gains a test id.

Changes

Workspace E2E Coverage

Layer / File(s) Summary
Action button test id
packages/bruno-app/src/components/ManageWorkspace/index.js
The ManageWorkspace actions button includes a data-testid for opening the actions menu.
Setup, terminal, rename, and remove actions
tests/workspace/manage-workspace/manage-workspace.spec.ts
The manage-workspace spec creates Custom Workspace in beforeEach, navigates to Manage Workspace, updates the Open in Terminal test, and adds rename and remove action tests.
Open workspace dialog flow
tests/workspace/open-workspace/open-workspace.spec.ts
The open-workspace spec adds a test for selecting an existing workspace path from the dialog and updates the cancel-path test to preserve the current workspace name.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • usebruno/bruno#6424: Touches the same ManageWorkspace action button that now carries the data-testid.
  • usebruno/bruno#7437: Implements the workspace rename flow exercised by the new rename test.
  • usebruno/bruno#7877: Implements the Open in Terminal workspace action covered by the updated terminal test.

Suggested reviewers

  • bijin-bruno
  • lohit-bruno
  • helloanoop

Poem

A helper steps in, the tests grow neat,
Terminal, rename, and remove all meet.
A dialog opens, then settles true,
Workspace paths and names shine through.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change by describing workspace automation for renaming and removing actions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/workspace/manage-workspace/manage-workspace.spec.ts`:
- Around line 95-97: The workspace action checks in manage-workspace.spec.ts are
order-dependent and should be scoped to the matching row instead of using
generic buttons or nth-child selectors. Update the interactions around the
workspace actions flow to locate the row by workspace name first, then click
that row’s actions menu and the Rename/Remove options from there. Replace the
`.workspace-item:nth-child(2)`-style assertions with name-based locators for
`New Workspace Name` and `Remove My Workspace`, and verify the removed workspace
is absent by name rather than by position.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 804a63c1-7ded-4181-97a5-81642d14b938

📥 Commits

Reviewing files that changed from the base of the PR and between 5777306 and c17dacd.

📒 Files selected for processing (1)
  • tests/workspace/manage-workspace/manage-workspace.spec.ts

Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
@guru-sharan-bruno guru-sharan-bruno changed the title feat(workspace):Automation script for Renaming and removing the Workspace test(workspace):Automation script for Renaming and removing the Workspace Jun 24, 2026
});
} finally {
await closeElectronApp(app);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need of try and final move the codeblock to test.beforeEach or test.afterEach

const page = await app.firstWindow();

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove timeout update in all other places

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/workspace/manage-workspace/manage-workspace.spec.ts (1)

55-55: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Test titles read as instructions, not behaviour. Titles like Click on the 3 dots icon on the workspace you want to rename. describe steps rather than the expected outcome. Prefer outcome-focused names, e.g. should rename a workspace / should remove a workspace, and move the step prose into the existing test.step blocks.

Also applies to: 83-83

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/workspace/manage-workspace/manage-workspace.spec.ts` at line 55, The
test titles in manage-workspace.spec.ts are written as user actions instead of
expected behavior, so rename the affected test cases to outcome-focused
descriptions. Update the relevant test declarations in the manage-workspace
suite to use names like “should rename a workspace” or “should remove a
workspace,” and keep the step-by-step interaction text inside the existing
test.step blocks rather than in the test title.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/workspace/manage-workspace/manage-workspace.spec.ts`:
- Line 19: The spec has an unused temporary-directory variable in the
manage-workspace test setup, which leaves misleading setup code behind. Remove
the wsLocation declaration from the workspace management spec and keep the test
focused on the values actually used; if the temp dir is still needed elsewhere,
reference the existing helper call through the relevant test setup identifiers
rather than storing an unused variable.

---

Nitpick comments:
In `@tests/workspace/manage-workspace/manage-workspace.spec.ts`:
- Line 55: The test titles in manage-workspace.spec.ts are written as user
actions instead of expected behavior, so rename the affected test cases to
outcome-focused descriptions. Update the relevant test declarations in the
manage-workspace suite to use names like “should rename a workspace” or “should
remove a workspace,” and keep the step-by-step interaction text inside the
existing test.step blocks rather than in the test title.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3f48b44e-d986-4498-8d67-a7f1966b76b6

📥 Commits

Reviewing files that changed from the base of the PR and between 0eb788a and 7039255.

📒 Files selected for processing (2)
  • packages/bruno-app/src/components/ManageWorkspace/index.js
  • tests/workspace/manage-workspace/manage-workspace.spec.ts

Comment thread tests/workspace/manage-workspace/manage-workspace.spec.ts Outdated
test('should open terminal from the workspace actions menu', async ({ launchElectronApp, createTmpDir }) => {
const wsLocation = await createTmpDir('ws-location-terminal');
test.describe('Manage Workspace Actions - Open in Terminal', () => {
test('should open terminal from the workspace actions menu', async ({ page }) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sanity tag is not added here. Do we not need it?

import type { ElectronApplication } from '@playwright/test';
import { expect, test } from '../../../playwright';
import { buildCommonLocators, waitForReadyPage } from '../../utils/page';
import fs from 'fs/promises';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this file changes add a separate PR for this.

&& fs.existsSync(path.join(fullPath, 'workspace.yml'))
);
await test.step('Open Manage Workspaces', async () => {
await page.locator('.workspace-name-container').click();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use data-testid

myWorkspaceDropdownItem: () => page.locator('.dropdown-item'),
manageWorkspaceTitle: () => page.getByText('Manage Workspace', { exact: true }),
defaultWorkspaceItem: () => page.locator('.workspace-item'),
moreActionsBtn: () => page.locator('.more-actions-btn'),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use datatest-id

submitRemoveBtn: () => page.getByTestId('modal-submit-btn')
});

export const manageWorkspace = async (page: Page) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function name can be more specific like openManageWorkspace or something else.

import { buildTitleBarLocators } from '../title-bar';

export const buildManageWorkspaceLocators = (page: Page) => ({
myWorkspaceDropdownItem: () => page.locator('.dropdown-item'),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

locaters structure and name can be improved.

export const buildManageWorkspaceLocators = (page: Page) => ({
  // The Manage Workspace panel heading.
  manageWorkspaceTitle: () => page.getByText('Manage Workspace', { exact: true }),
  // All workspace rows, or a single row matched by name.
  workspaceItem: (name?: string) => {
    const rows = page.locator('.workspace-item');
    return name ? rows.filter({ hasText: name }) : rows;
  },
  // The "..." actions button, scoped to a given workspace row.
  moreActionsBtn: (row: Locator) => row.getByTestId('more-actions-btn'),
  // Rename modal's name field.
  workspaceNameInput: () => page.locator('#workspace-name'),
  // The active workspace name shown in the title bar (updates after a rename).
  activeWorkspaceName: () => buildTitleBarLocators(page).activeWorkspaceName(),
  // First terminal session entry opened via "Open in Terminal".
  terminalSession: () => page.getByTestId('session-list-0')
})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Further minor enhancement

  1. use plural => workspaceItems: (name?: string) => {
  2. enhance => terminalSession: (index: number = 0) => page.getByTestId(`session-list-${index}`)

await clickOnMoreActionsButton(page, 'Custom Workspace');
await renameOrRemoveWorkspaceOnPopup(page, 'Rename');
await enterNewWorkspaceFilename(page, 'New Workspace Name', 'Rename');
await expect(locators.renamedWorkspaceItem()).toHaveText('New Workspace Name');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This renamedWorkspaceItem does not make sence we can just name it activeWorkspaveName

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can rename non-active workspaces too. Fix accordingly.

});
};

export const clickOnMoreActionsButton = async (page: Page, workspaceName: string) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rename it to openWorkspaceActionsMenu?

});
};

export const clickOnRemoveButtonOnPopup = async (page: Page) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename it to confirmRemoveWorkspace.

});
};

export const enterNewWorkspaceFilename = async (page: Page, workspaceName: string, btnName: string) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the name to enterNewWorkspaceName

});
};

export const renameOrRemoveWorkspaceOnPopup = async (page: Page, optionName: string) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change it to selectWorkspaceAction. More generic, and won't need renaming when new menu actions are added.

export const buildManageWorkspaceLocators = (page: Page) => ({
myWorkspaceDropdownItem: () => page.locator('.dropdown-item'),
manageWorkspaceTitle: () => page.getByText('Manage Workspace', { exact: true }),
defaultWorkspaceItem: () => page.locator('.workspace-item'),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not reliable. page.locator('.workspace-item') is not always default item

Comment on lines +16 to +18
submitRenameBtn: () => page.getByTestId('modal-submit-btn'),
renamedWorkspaceItem: () => page.getByTestId('workspace-name'),
submitRemoveBtn: () => page.getByTestId('modal-submit-btn')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

submitRenameBtn, submitRemoveBtn are both relying on the default testid from the modal component.
I suggest adding proper testid for the modals and use them.

// rename modal
<Modal 
    data-testid="rename-workspace-modal"
    ...
// usage becomes
submitRemoveBtn: () => page.getByTestId('rename-workspace-modal-submit-btn')

import { buildTitleBarLocators } from '../title-bar';

export const buildManageWorkspaceLocators = (page: Page) => ({
myWorkspaceDropdownItem: () => page.locator('.dropdown-item'),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. myWorkspaceDropdownItem: () => page.locator('.dropdown-item'), should be part of tests/utils/page/title-bar.ts
  2. rename myWorkspaceDropdownItem => importWorkspaceOption refer: importWorkspaceOption
  3. We can also add a dynamic option selector workspaceMenuOption: (name: string) => page.getByTestId('workspace-menu').locator('.dropdown-item');


export const renameOrRemoveWorkspaceOnPopup = async (page: Page, optionName: string) => {
const locators = buildManageWorkspaceLocators(page);
await test.step('Rename or remove workspace on popup', async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

step description is not accurate to action performed


export const clickOnRemoveButtonOnPopup = async (page: Page) => {
const locators = buildManageWorkspaceLocators(page);
await test.step('Verify the workspace name is updated in the workspace list.', async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step description is not accurate to action performed. Actions cannot have verify steps.

await createWorkspace(page, 'Custom Workspace');
});

await test.step('Open manage workspaces', async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeated/Duplicate step.
await manageWorkspace(page); internally have the same step.

await test.step('Open manage workspaces', async () => {
const locators = buildManageWorkspaceLocators(page);
await manageWorkspace(page);
await expect(locators.manageWorkspaceTitle()).toBeVisible();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beforeEach block cannot have test assertions.
use .waitFor({ state: 'visible' }) instead, if this is added as a dynamic wait logic.

await expect(defaultWorkspaceItem.locator('.more-actions-btn')).toHaveCount(0);
});
test.describe('Manage workspace actions-open in terminal', () => {
test('TC-3109: Verify that the workspace should open terminal from the workspace actions menu', { tag: '@sanity' }, async ({ page }) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Descriptions can be improved.

await clickOnMoreActionsButton(page, 'Custom Workspace');
await renameOrRemoveWorkspaceOnPopup(page, 'Rename');
await enterNewWorkspaceFilename(page, 'New Workspace Name', 'Rename');
await expect(locators.renamedWorkspaceItem()).toHaveText('New Workspace Name');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can rename non-active workspaces too. Fix accordingly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests are passing when run in parallel with multiple workers. But when run using single worker (npm run test:e2e tests/workspace/manage-workspace/manage-workspace.spec.ts -- --workers=1) it fails due to stale state from the previous test case is not cleaned up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants