diff --git a/playwright/index.ts b/playwright/index.ts index 9bbf6ce2e..9a98a55b6 100644 --- a/playwright/index.ts +++ b/playwright/index.ts @@ -41,7 +41,7 @@ export const test = baseTest.extend< } >({ createTmpDir: [ - async ({}, use) => { + async ({ }, use) => { const dirs: string[] = []; await use(async (tag?: string) => { const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), `pw-${tag || ''}-`)); @@ -85,7 +85,7 @@ export const test = baseTest.extend< } const app = await playwright._electron.launch({ - args: [electronAppPath], + args: [electronAppPath, '--disable-gpu'], env: { ...process.env, ELECTRON_USER_DATA_PATH: userDataPath, @@ -134,7 +134,7 @@ export const test = baseTest.extend< if (tracingOptions) { try { await context.tracing.start({ screenshots: true, snapshots: true, sources: true }); - } catch (e) {} + } catch (e) { } } await use(context); }, @@ -236,7 +236,7 @@ export const test = baseTest.extend< const tracePath = testInfo.outputPath(`trace-${testInfo.testId}.zip`); try { await context.tracing.start({ screenshots: true, snapshots: true, sources: true }); - } catch (e) {} + } catch (e) { } await context.tracing.startChunk(); await use(page); await context.tracing.stopChunk({ path: tracePath }); diff --git a/tests/collection/moving-requests/tag-persistence.spec.ts b/tests/collection/moving-requests/tag-persistence.spec.ts index 0818089ab..56a69ddb3 100644 --- a/tests/collection/moving-requests/tag-persistence.spec.ts +++ b/tests/collection/moving-requests/tag-persistence.spec.ts @@ -1,5 +1,5 @@ import { test, expect } from '../../../playwright'; -import { closeAllCollections, createCollection, createRequest, selectRequestPaneTab } from '../../utils/page'; +import { closeAllCollections, createCollection, createRequest, saveRequest, selectRequestPaneTab } from '../../utils/page'; import { buildCommonLocators } from '../../utils/page/locators'; test.describe('Tag persistence', () => { @@ -23,13 +23,11 @@ test.describe('Tag persistence', () => { await locators.sidebar.request(requestName).click(); await locators.tabs.requestTab(requestName).waitFor({ state: 'visible' }); await selectRequestPaneTab(page, 'Settings'); - await page.waitForTimeout(200); + await expect(locators.tags.input()).toBeVisible(); await locators.tags.input().fill(tagName); await locators.tags.input().press('Enter'); - await page.waitForTimeout(200); await expect(locators.tags.item(tagName)).toBeVisible(); - await page.keyboard.press('Meta+s'); - await page.waitForTimeout(200); + await saveRequest(page); } // Move the last request to just above the first request within the same collection @@ -53,7 +51,6 @@ test.describe('Tag persistence', () => { await r3Request.click(); await locators.tabs.requestTab('request-3').waitFor({ state: 'visible' }); await selectRequestPaneTab(page, 'Settings'); - await page.waitForTimeout(200); // Verify the tag is still present after the move await expect(locators.tags.item(tagName)).toBeVisible(); }); @@ -70,11 +67,10 @@ test.describe('Tag persistence', () => { await locators.dropdown.item('New Folder').click(); await page.locator('#folder-name').fill('folder-1'); await locators.modal.button('Create').click(); - await page.waitForTimeout(100); + await expect(locators.sidebar.folder('folder-1')).toBeVisible(); // Create a new request within folder-1 folder await locators.sidebar.folder('folder-1').click(); - await page.waitForTimeout(200); await locators.sidebar.folder('folder-1').hover(); await locators.actions.collectionItemActions('folder-1').click(); @@ -92,14 +88,16 @@ test.describe('Tag persistence', () => { await locators.request.newRequestUrl().click(); await page.keyboard.type('https://httpfaker.org/api/echo'); await locators.modal.button('Create').click(); - await page.waitForTimeout(200); + await expect(locators.sidebar.folderRequest('folder-1', 'request-2')).toBeVisible(); + await locators.sidebar.folderRequest('folder-1', 'request-2').click(); + await expect(locators.tabs.activeRequestTab()).toContainText('request-2'); // Add a tag to the request await selectRequestPaneTab(page, 'Settings'); - await page.waitForTimeout(200); + await expect(locators.tags.input()).toBeVisible(); + await locators.tags.input().fill('smoke'); await locators.tags.input().press('Enter'); - await page.waitForTimeout(200); await expect(locators.tags.item('smoke')).toBeVisible(); await page.keyboard.press('Meta+s'); @@ -125,17 +123,14 @@ test.describe('Tag persistence', () => { const f2Folder = locators.sidebar.folder('folder-2'); await r2Request.dragTo(f2Folder); - // Verify the requests are still in the collection and request-2 is now in folder-2 folder - await expect(locators.sidebar.request('request-2')).toBeVisible(); - await expect(locators.sidebar.folder('folder-2')).toBeVisible(); + const request2 = locators.sidebar.folderRequest('folder-2', 'request-2'); + await expect(request2).toBeVisible(); // Click on request-2 to verify the tag persisted after the move - await locators.sidebar.request('request-2').click(); - await page.waitForTimeout(200); - + await request2.click(); await locators.tabs.requestTab('request-2').waitFor({ state: 'visible' }); + await selectRequestPaneTab(page, 'Settings'); - await page.waitForTimeout(200); await expect(locators.tags.item('smoke')).toBeVisible(); }); }); diff --git a/tests/environments/api-setEnvVar/api-setEnvVar-with-persist.spec.ts b/tests/environments/api-setEnvVar/api-setEnvVar-with-persist.spec.ts index f1e424695..354825628 100644 --- a/tests/environments/api-setEnvVar/api-setEnvVar-with-persist.spec.ts +++ b/tests/environments/api-setEnvVar/api-setEnvVar-with-persist.spec.ts @@ -25,11 +25,14 @@ test.describe.serial('bru.setEnvVar(name, value, { persist: true })', () => { await sendRequest(page, 200); // confirm that the environment variable is set + await page.getByTestId('environment-selector-trigger').hover(); await page.getByTestId('environment-selector-trigger').click(); // open environment configuration + + await page.locator('#configure-env').hover(); await page.locator('#configure-env').click(); - const envTab = page.locator('.request-tab').filter({ hasText: 'Environments' }); + const envTab = page.locator('.request-tab').filter({ has: page.locator('.tab-label', { hasText: 'Environments' }) }); await expect(envTab).toBeVisible(); await expect(page.getByRole('row', { name: 'token' }).getByRole('cell').nth(1)).toBeVisible(); diff --git a/tests/environments/import-environment/bruno-env-import/collection-env-import/collection-env-import.spec.ts b/tests/environments/import-environment/bruno-env-import/collection-env-import/collection-env-import.spec.ts index 1dd030273..fd18920df 100644 --- a/tests/environments/import-environment/bruno-env-import/collection-env-import/collection-env-import.spec.ts +++ b/tests/environments/import-environment/bruno-env-import/collection-env-import/collection-env-import.spec.ts @@ -20,6 +20,7 @@ test.describe.serial('Collection Environment Import Tests', () => { await test.step('Navigate to collection environment import', async () => { // Open environment import + await page.getByTestId('environment-selector-trigger').hover(); await page.getByTestId('environment-selector-trigger').click(); await page.getByTestId('env-tab-collection').click(); await expect(page.getByTestId('env-tab-collection')).toHaveClass(/active/); @@ -74,7 +75,10 @@ test.describe.serial('Collection Environment Import Tests', () => { await test.step('Navigate to collection environment import', async () => { // Open environment import + + await page.getByTestId('environment-selector-trigger').hover(); await page.getByTestId('environment-selector-trigger').click(); + await page.getByTestId('env-tab-collection').click(); await expect(page.getByTestId('env-tab-collection')).toHaveClass(/active/); await page.getByText('Import', { exact: true }).click(); @@ -97,6 +101,8 @@ test.describe.serial('Collection Environment Import Tests', () => { await test.step('Verify both environments are available in selector', async () => { await page.waitForTimeout(500); + + await page.getByTestId('environment-selector-trigger').hover(); await page.getByTestId('environment-selector-trigger').click(); await page.waitForTimeout(300); @@ -110,6 +116,7 @@ test.describe.serial('Collection Environment Import Tests', () => { await expect(page.locator('.current-environment')).toContainText('prod'); // Verify prod environment variables by opening settings again + await page.getByTestId('environment-selector-trigger').hover(); await page.getByTestId('environment-selector-trigger').click(); await page.getByText('Configure', { exact: true }).click(); diff --git a/tests/utils/page/actions.ts b/tests/utils/page/actions.ts index f6ae74b25..709659d48 100644 --- a/tests/utils/page/actions.ts +++ b/tests/utils/page/actions.ts @@ -641,24 +641,29 @@ const getResponseBody = async (page: Page): Promise => { }; const selectRequestPaneTab = async (page: Page, tabName: string) => { + await test.step(`Wait for request to open up "${tabName}"`, async () => { + await expect(page.locator('.request-pane > .px-4')).toBeVisible(); + await expect(page.locator('.tabs')).toBeVisible(); + }); await test.step(`Select request pane tab "${tabName}"`, async () => { const visibleTab = page.locator('.tabs').getByRole('tab', { name: tabName }); - const overflowButton = page.locator('.tabs .more-tabs'); // Check if tab is directly visible if (await visibleTab.isVisible()) { await visibleTab.click(); + await expect(visibleTab).toContainClass('active'); return; } + const overflowButton = page.locator('.tabs .more-tabs'); // Check if there's an overflow dropdown if (await overflowButton.isVisible()) { await overflowButton.click(); // Wait for dropdown to appear and click the menu item (overflow tabs are rendered as menuitems) const dropdownItem = page.locator('.tippy-box .dropdown-item').filter({ hasText: tabName }); - await expect(dropdownItem).toBeVisible(); await dropdownItem.click(); + await expect(visibleTab).toContainClass('active'); return; }