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:
Bijin A B
2025-11-02 11:35:09 +05:30
committed by GitHub
parent c85a1ec1a5
commit 23843bb621
5 changed files with 31 additions and 9 deletions

View File

@@ -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

View File

@@ -1,5 +1,5 @@
{
"maximized": true,
"maximized": false,
"lastOpenedCollections": [
"{{projectRoot}}/tests/request/settings/collection"
]

View File

@@ -1,5 +1,5 @@
{
"maximized": true,
"maximized": false,
"lastOpenedCollections": ["{{projectRoot}}/tests/request/collections/custom-search"],
"preferences": {}
}

View File

@@ -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();

View File

@@ -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);
}
});
};