mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-29 07:34:07 +00:00
* test cases for workspace import and validation TC-969, jira: https://usebruno.atlassian.net/browse/BRU-3575 * incorporated comments, moved findWorkspaceDirByName function to helpers.ts, fixed all the comments * modified as per comment provided , removed css locators , used playwright inbuilt methods , handled timeout * Created file structure as per comment provided, added tc-id , resolved code-rabbit review * incorporated comments removed commented line, removed timeouts, modified package.json added package in dev dependencies * changed const l to locators for better readbility * - Reorganized test helpers: split title-bar locators into title-bar.ts and import-workspace flow into workspace/import-workspace.ts for reuse - Replaced brittle .bruno-modal-card/CSS locators with stable role/testid/label based locators - Added a data-testid for the Import Workspace modal and removed the redundant one - Cleaned up unnecessary comments - Updated package-lock.json * minor changes * minor changes * addressed comments * addressed comments for variable naming * minor changes
54 lines
2.2 KiB
TypeScript
54 lines
2.2 KiB
TypeScript
import path from 'path';
|
|
import fs from 'fs';
|
|
import yaml from 'js-yaml';
|
|
import { test, expect, closeElectronApp, waitForReadyPage } from '../../../playwright';
|
|
import {
|
|
createWorkspaceZip,
|
|
importWorkspaceFromZip
|
|
} from '../../utils/page/workspace/import-workspace';
|
|
import { buildTitleBarLocators } from '../../utils/page/title-bar';
|
|
|
|
type WorkspaceConfig = {
|
|
info?: { name: string; type: string };
|
|
};
|
|
|
|
const initUserDataPath = path.join(__dirname, 'init-user-data');
|
|
|
|
test.describe('Import Workspace', () => {
|
|
test('TC-969: Verify Import workspace from local directory containing valid workspace.zip file', { tag: '@sanity' }, async ({ launchElectronApp, createTmpDir }) => {
|
|
const wsLocation = await createTmpDir('import-ws-location');
|
|
const zipDir = await createTmpDir('import-ws-zip');
|
|
const workspaceName = 'Imported WS';
|
|
const zipPath = createWorkspaceZip(zipDir, workspaceName);
|
|
|
|
const app = await launchElectronApp({ initUserDataPath, templateVars: { wsLocation } });
|
|
const page = await waitForReadyPage(app);
|
|
const titleBar = buildTitleBarLocators(page);
|
|
|
|
await test.step('Import the workspace zip via the Import Workspace modal', async () => {
|
|
// extractLocation isn't passed as a parameter: the modal pre-fills the seeded default location.
|
|
await importWorkspaceFromZip(page, { zipPath });
|
|
});
|
|
|
|
await test.step('Verify success toast is shown', async () => {
|
|
await expect(page.getByText('Workspace imported successfully!')).toBeVisible();
|
|
});
|
|
|
|
await test.step('Verify the imported workspace becomes the active workspace', async () => {
|
|
await expect(titleBar.activeWorkspaceName()).toHaveText(workspaceName);
|
|
});
|
|
|
|
await test.step('Verify the workspace was extracted to the filesystem', async () => {
|
|
const wsDir = path.join(wsLocation, workspaceName);
|
|
const ymlPath = path.join(wsDir, 'workspace.yml');
|
|
expect(fs.existsSync(ymlPath)).toBe(true);
|
|
|
|
const wsConfig = yaml.load(fs.readFileSync(ymlPath, 'utf8')) as WorkspaceConfig;
|
|
expect(wsConfig?.info?.name).toBe(workspaceName);
|
|
expect(wsConfig?.info?.type).toBe('workspace');
|
|
});
|
|
|
|
await closeElectronApp(app);
|
|
});
|
|
});
|