mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-23 04:35:40 +00:00
* feat: Enhance EnvironmentVariables component with read-only support for non-string values * feat: minor refactor and cleanup worker app state * fix: playwright test flow --------- Co-authored-by: Bijin Bruno <bijin@usebruno.com>
49 lines
2.1 KiB
TypeScript
49 lines
2.1 KiB
TypeScript
import { test, expect } from '../../../playwright';
|
|
|
|
/**
|
|
* Close all collections
|
|
* @param page - The page object
|
|
* @returns void
|
|
*/
|
|
const closeAllCollections = async (page) => {
|
|
await test.step('Close all collections', async () => {
|
|
const numberOfCollections = await page.locator('.collection-name').count();
|
|
|
|
for (let i = 0; i < numberOfCollections; i++) {
|
|
await page.locator('.collection-name').first().locator('.collection-actions').click();
|
|
await page.locator('.dropdown-item').getByText('Close').click();
|
|
// Wait for the close collection modal to be visible
|
|
await page.locator('.bruno-modal-header-title', { hasText: 'Close Collection' }).waitFor({ state: 'visible' });
|
|
await page.locator('.bruno-modal-footer .submit').click();
|
|
// Wait for the close collection modal to be hidden
|
|
await page.locator('.bruno-modal-header-title', { hasText: 'Close Collection' }).waitFor({ state: 'hidden' });
|
|
}
|
|
|
|
// Wait until no collections are left open
|
|
await expect(page.locator('.collection-name')).toHaveCount(0);
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Open a collection from the sidebar and accept the JavaScript Sandbox modal
|
|
* @param page - The page object
|
|
* @param collectionName - The name of the collection to open
|
|
* @param sandboxMode - The mode to accept the sandbox modal
|
|
* @returns void
|
|
*/
|
|
const openCollectionAndAcceptSandbox = async (page, collectionName: string, sandboxMode: 'safe' | 'developer' = 'safe') => {
|
|
await test.step(`Open collection "${collectionName}" and accept sandbox "${sandboxMode}" mode`, async () => {
|
|
await page.locator('#sidebar-collection-name').filter({ hasText: collectionName }).click();
|
|
|
|
const sandboxModal = page
|
|
.locator('.bruno-modal-card')
|
|
.filter({ has: page.locator('.bruno-modal-header-title', { hasText: 'JavaScript Sandbox' }) });
|
|
|
|
const modeLabel = sandboxMode === 'safe' ? 'Safe Mode' : 'Developer Mode';
|
|
await sandboxModal.getByLabel(modeLabel).check();
|
|
await sandboxModal.locator('.bruno-modal-footer .submit').click();
|
|
});
|
|
};
|
|
|
|
export { closeAllCollections, openCollectionAndAcceptSandbox };
|