-
Notifications
You must be signed in to change notification settings - Fork 2.6k
test(workspace):Automation script for Renaming and removing the Workspace #8356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
c17dacd
0eb788a
7039255
f00746d
7ef9fbf
606cd06
067ffa6
de13061
e44fc35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,7 @@ | ||
| import path from 'path'; | ||
| import fs from 'fs'; | ||
| import { test, expect, closeElectronApp } from '../../../playwright'; | ||
|
|
||
| const initUserDataPath = path.join(__dirname, '../create-workspace/init-user-data'); | ||
| import { test, expect } from '../../../playwright'; | ||
| import { createWorkspace } from '../../utils/page/actions'; | ||
|
|
||
| function findCreatedWorkspaceDirs(location: string): string[] { | ||
| return fs.readdirSync(location).filter((e) => { | ||
|
|
@@ -16,53 +15,88 @@ | |
| } | ||
|
|
||
| test.describe('Manage Workspace', () => { | ||
| test('should open terminal from the workspace actions menu', async ({ launchElectronApp, createTmpDir }) => { | ||
| test.beforeEach(async ({ page, createTmpDir }) => { | ||
| const wsLocation = await createTmpDir('ws-location-terminal'); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| 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 }); | ||
| }); | ||
| await test.step('Create a workspace', async () => { | ||
| await createWorkspace(page, 'Custom Workspace'); | ||
| }); | ||
|
|
||
| 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('Open Manage Workspaces', async () => { | ||
| await page.locator('.workspace-name-container').click(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use data-testid |
||
| await page.locator('.dropdown-item').filter({ hasText: 'Manage workspaces' }).click(); | ||
| await expect(page.getByText('Manage Workspace', { exact: true })).toBeVisible(); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('Manage Workspace Actions - Open in Terminal', () => { | ||
| test('should open terminal from the workspace actions menu', async ({ page }) => { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sanity tag is not added here. Do we not need it? |
||
| 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 }); | ||
| const workspaceItem = page.locator('.workspace-item').filter({ hasText: 'Custom Workspace' }); | ||
| await expect(workspaceItem).toBeVisible(); | ||
| 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]); | ||
| await expect(terminalSession).toBeVisible(); | ||
| await expect(terminalSession).toContainText('Custom Workspace'); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('Manage Workspace Actions - Rename Workspace', () => { | ||
| test('Click on the 3 dots icon on the workspace you want to rename.', async ({ page }) => { | ||
| const workspaceItem = page.locator('.workspace-item').filter({ | ||
| has: page.locator('.workspace-name', { hasText: 'Custom Workspace' }) | ||
| }); | ||
|
|
||
| await workspaceItem.locator('.more-actions-btn').click(); | ||
|
Check failure on line 60 in tests/workspace/manage-workspace/manage-workspace.spec.ts
|
||
| await page.locator('.dropdown-item').filter({ hasText: 'Rename' }).click(); | ||
| await expect(page.locator('.bruno-modal-card')).toBeVisible(); | ||
|
|
||
| await test.step('Enter a new name for the workspace in the editing field.', async () => { | ||
| const workspaceNameInput = page.locator('#workspace-name'); | ||
| await expect(workspaceNameInput).toBeVisible(); | ||
| await workspaceNameInput.fill('New Workspace Name'); | ||
| await page.getByTestId('modal-submit-btn').filter({ hasText: 'Rename' }).click(); | ||
| }); | ||
|
|
||
| await test.step('Verify the workspace name is updated in the workspace list.', async () => { | ||
| const workspaceItem = page.getByTestId('workspace-name'); | ||
| await expect(workspaceItem).toHaveText('New Workspace Name'); | ||
| const manageWorkspaceItem = page.locator('.workspace-item').filter({ | ||
| has: page.locator('.workspace-name', { hasText: 'New Workspace Name' }) | ||
| }); | ||
| await expect(manageWorkspaceItem).toBeVisible(); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('Manage Workspace Actions - Remove Workspace', () => { | ||
| test('Should be able to remove a Workspace from manage workspace section', async ({ page }) => { | ||
| const workspaceItem = page.locator('.workspace-item').filter({ | ||
| has: page.locator('.workspace-name', { hasText: 'Custom Workspace' }) | ||
| }); | ||
|
|
||
| await test.step('Open Manage Workspaces', async () => { | ||
| await workspaceItem.locator('.more-actions-btn').click(); | ||
| await expect(page.getByTestId('menu-dropdown-dropdown')).toBeVisible(); | ||
| await page.getByTestId('menu-dropdown-remove').click(); | ||
| await expect(page.locator('.bruno-modal-card')).toBeVisible(); | ||
| await expect(page.locator('.bruno-modal-content span').first()).toHaveText('Custom Workspace'); | ||
| }); | ||
|
|
||
| await test.step('Click on the Remove button in the modal.', async () => { | ||
| await page.getByTestId('modal-submit-btn').click(); | ||
| await expect(page.locator('.workspace-item').filter({ hasText: 'Custom Workspace' })).not.toBeVisible({ timeout: 10000 }); | ||
| }); | ||
| } finally { | ||
| await closeElectronApp(app); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
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.