mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
fix: flaky large response test and update app preferences for few tests (#5963)
* fix: flaky large response test and update app preferences for few tests * refactor: update createCollection function to accept sandbox mode
This commit is contained in:
@@ -7,7 +7,7 @@ test.describe('Copy and Paste Requests', () => {
|
||||
});
|
||||
|
||||
test('should copy and paste a request within the same collection', async ({ page, createTmpDir }) => {
|
||||
await createCollection(page, 'test-collection', createTmpDir);
|
||||
await createCollection(page, 'test-collection', await createTmpDir('test-collection'), { openWithSandboxMode: 'safe' });
|
||||
|
||||
// Create a new request
|
||||
const collection = page.locator('.collection-name').filter({ hasText: 'test-collection' });
|
||||
@@ -53,7 +53,7 @@ test.describe('Copy and Paste Requests', () => {
|
||||
});
|
||||
|
||||
test('should copy and paste a request into a different collection', async ({ page, createTmpDir }) => {
|
||||
await createCollection(page, 'test-collection-2', createTmpDir);
|
||||
await createCollection(page, 'test-collection-2', await createTmpDir('test-collection-2'), { openWithSandboxMode: 'safe' });
|
||||
const collection = page.locator('.collection-name').filter({ hasText: 'test-collection-2' });
|
||||
|
||||
// Paste into the collection root
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"maximized": true,
|
||||
"maximized": false,
|
||||
"lastOpenedCollections": [
|
||||
"{{projectRoot}}/tests/request/settings/collection"
|
||||
]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"maximized": true,
|
||||
"maximized": false,
|
||||
"lastOpenedCollections": ["{{projectRoot}}/tests/request/collections/custom-search"],
|
||||
"preferences": {}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ import { test, expect } from '../../playwright';
|
||||
import { closeAllCollections, createCollection } from '../utils/page/actions';
|
||||
|
||||
test.describe('Large Response Crash/High Memory Usage Prevention', () => {
|
||||
// Increase timeout to 1 minute for all tests in this describe block, default is 30 seconds.
|
||||
// Prevents tests from failing due to timeout while waiting for the response, especially on slower internet connections.
|
||||
test.setTimeout(1 * 60 * 1000); // 1 minute
|
||||
|
||||
test.afterAll(async ({ page }) => {
|
||||
// cleanup: close all collections
|
||||
await closeAllCollections(page);
|
||||
@@ -11,7 +15,7 @@ test.describe('Large Response Crash/High Memory Usage Prevention', () => {
|
||||
const collectionName = 'size-warning-test';
|
||||
|
||||
// Create collection
|
||||
await createCollection(page, collectionName, createTmpDir);
|
||||
await createCollection(page, collectionName, await createTmpDir(collectionName), { openWithSandboxMode: 'safe' });
|
||||
|
||||
// Create request
|
||||
await page.locator('#create-new-tab').getByRole('img').click();
|
||||
|
||||
@@ -42,21 +42,39 @@ const openCollectionAndAcceptSandbox = async (page, collectionName: string, sand
|
||||
const modeLabel = sandboxMode === 'safe' ? 'Safe Mode' : 'Developer Mode';
|
||||
await sandboxModal.getByLabel(modeLabel).check();
|
||||
await sandboxModal.locator('.bruno-modal-footer .submit').click();
|
||||
await sandboxModal.waitFor({ state: 'detached' });
|
||||
});
|
||||
};
|
||||
|
||||
const createCollection = async (page, collectionName: string, createDir: (tag?: string | undefined) => Promise<string>) => {
|
||||
test.step(`Create collection "${collectionName}" and accept sandbox "safe" mode`, async () => {
|
||||
type CreateCollectionOptions = {
|
||||
openWithSandboxMode?: 'safe' | 'developer';
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a collection
|
||||
* @param page - The page object
|
||||
* @param collectionName - The name of the collection to create
|
||||
* @param collectionLocation - The location of the collection to create (eg)
|
||||
* @param options - The options for creating the collection
|
||||
*
|
||||
* @returns void
|
||||
*/
|
||||
const createCollection = async (page, collectionName: string, collectionLocation: string, options: CreateCollectionOptions = {}) => {
|
||||
await test.step(`Create collection "${collectionName}"`, async () => {
|
||||
await page.locator('.collection-dropdown .dropdown-icon').click();
|
||||
await page.locator('.tippy-box .dropdown-item').filter({ hasText: 'Create Collection' }).click();
|
||||
|
||||
const createCollectionModal = page.locator('.bruno-modal-card').filter({ hasText: 'Create Collection' });
|
||||
|
||||
await createCollectionModal.getByLabel('Name').fill(collectionName);
|
||||
await createCollectionModal.getByLabel('Location').fill(await createDir(collectionName));
|
||||
await createCollectionModal.getByLabel('Location').fill(collectionLocation);
|
||||
await createCollectionModal.getByRole('button', { name: 'Create', exact: true }).click();
|
||||
|
||||
await openCollectionAndAcceptSandbox(page, collectionName, 'safe');
|
||||
await createCollectionModal.waitFor({ state: 'detached' });
|
||||
|
||||
if (options.openWithSandboxMode != undefined) {
|
||||
await openCollectionAndAcceptSandbox(page, collectionName, options.openWithSandboxMode);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user