Files
bruno/tests/environments/api-setEnvVar/api-setEnvVar-without-persist.spec.ts
Sanjai Kumar c5325c732f feat: enhance environment variable persistence handling (#5783)
* feat: enhance environment variable persistence handling

* feat: experiment playwright with multiple workers

---------

Co-authored-by: Bijin Bruno <bijin@usebruno.com>
2025-10-25 19:02:45 +05:30

49 lines
2.2 KiB
TypeScript

import { test, expect } from '../../../playwright';
test.describe.serial('bru.setEnvVar(name, value)', () => {
test('set env var using script', async ({ pageWithUserData: page, restartApp }) => {
// Select the collection and request
await page.locator('#sidebar-collection-name').click();
await page.getByText('api-setEnvVar-without-persist', { exact: true }).click();
// open environment dropdown
await page.getByTestId('environment-selector-trigger').click();
// select stage environment
await expect(page.locator('.environment-list .dropdown-item', { hasText: 'Stage' })).toBeVisible();
await page.locator('.environment-list .dropdown-item', { hasText: 'Stage' }).click();
await expect(page.locator('.current-environment', { hasText: 'Stage' })).toBeVisible();
// Send the request
await page.getByTestId('send-arrow-icon').click();
await page.getByTestId('response-status-code').getByText(/200/).waitFor({ state: 'visible' });
await page.waitForTimeout(100);
// confirm that the environment variable is set
await page.getByTestId('environment-selector-trigger').click();
await page.locator('#configure-env').click();
await expect(page.getByRole('row', { name: 'token' }).getByRole('cell').nth(1)).toBeVisible();
await expect(page.getByRole('row', { name: 'secret' }).getByRole('cell').nth(2)).toBeVisible();
await page.getByTestId('modal-close-button').click();
// we restart the app to confirm that the environment variable is not persisted
const newApp = await restartApp();
const newPage = await newApp.firstWindow();
// select the collection and request
await newPage.locator('#sidebar-collection-name').click();
await newPage.getByText('api-setEnvVar-without-persist', { exact: true }).click();
// open environment dropdown
await newPage.getByTestId('environment-selector-trigger').click();
await newPage.locator('#configure-env').click();
// ensure that the environment variable is not persisted
await expect(newPage.locator('table.environment-variables tbody')).not.toContainText('token');
// close the environment variable modal
await newPage.getByTestId('modal-close-button').click();
await newPage.close();
});
});