improve: tests (#6321)

* improve: tests

* fixes

* fixes
This commit is contained in:
naman-bruno
2025-12-06 15:36:58 +05:30
committed by GitHub
parent 4a8d787f31
commit e93e545b81
29 changed files with 822 additions and 684 deletions

View File

@@ -1,9 +1,20 @@
import { test, expect } from '../../playwright';
import { createCollection, closeAllCollections, createRequest } from '../utils/page';
import {
createCollection,
closeAllCollections,
createRequest,
createEnvironment,
addEnvironmentVariables,
saveEnvironment,
closeEnvironmentPanel
} from '../utils/page';
import { buildCommonLocators } from '../utils/page/locators';
test.describe('Variable Tooltip', () => {
test.afterEach(async ({ page }) => {
await closeAllCollections(page);
if (!page.isClosed()) {
await closeAllCollections(page);
}
});
test('should test tooltip functionality with environment variables', async ({ page, createTmpDir }) => {
@@ -13,33 +24,16 @@ test.describe('Variable Tooltip', () => {
await createCollection(page, collectionName, await createTmpDir('tooltip-collection'), {
openWithSandboxMode: 'safe'
});
await expect(page.locator('#sidebar-collection-name').filter({ hasText: collectionName })).toBeVisible();
// Open environment settings
await page.locator('[data-testid="environment-selector-trigger"]').click();
await expect(page.locator('[data-testid="env-tab-collection"]')).toHaveClass(/active/);
await createEnvironment(page, 'Test Env', 'collection');
// Create environment
await page.locator('button[id="create-env"]').click();
await page.locator('input[name="name"]').fill('Test Env');
await page.getByRole('button', { name: 'Create' }).click();
await addEnvironmentVariables(page, [
{ name: 'apiKey', value: 'test-key-123' },
{ name: 'secretToken', value: 'secret-xyz', isSecret: true }
]);
// Add apiKey variable
await page.locator('button[data-testid="add-variable"]').click();
await page.locator('input[name="0.name"]').fill('apiKey');
await page.locator('tr').filter({ has: page.locator('input[name="0.name"]') }).locator('.CodeMirror').click();
await page.keyboard.type('test-key-123');
// Add secretToken variable
await page.locator('button[data-testid="add-variable"]').click();
await page.locator('input[name="1.name"]').fill('secretToken');
await page.locator('tr').filter({ has: page.locator('input[name="1.name"]') }).locator('.CodeMirror').click();
await page.keyboard.type('secret-xyz');
await page.locator('input[name="1.secret"]').check();
// Save and close
await page.getByRole('button', { name: 'Save' }).click();
await page.getByText('×').click();
await saveEnvironment(page);
await closeEnvironmentPanel(page);
});
await test.step('Create request and test tooltip', async () => {
@@ -120,32 +114,16 @@ test.describe('Variable Tooltip', () => {
await createCollection(page, collectionName, await createTmpDir('tooltip-ref-collection'), {
openWithSandboxMode: 'safe'
});
await expect(page.locator('#sidebar-collection-name').filter({ hasText: collectionName })).toBeVisible();
// Open environment settings
await page.locator('[data-testid="environment-selector-trigger"]').click();
await expect(page.locator('[data-testid="env-tab-collection"]')).toHaveClass(/active/);
await createEnvironment(page, 'Ref Test Env', 'collection');
// Create environment
await page.locator('button[id="create-env"]').click();
await page.locator('input[name="name"]').fill('Ref Test Env');
await page.getByRole('button', { name: 'Create' }).click();
await addEnvironmentVariables(page, [
{ name: 'host', value: 'api.example.com' },
{ name: 'endpoint', value: 'https://{{host}}/users' }
]);
// Add host variable
await page.locator('button[data-testid="add-variable"]').click();
await page.locator('input[name="0.name"]').fill('host');
await page.locator('tr').filter({ has: page.locator('input[name="0.name"]') }).locator('.CodeMirror').click();
await page.keyboard.type('api.example.com');
// Add endpoint that references host
await page.locator('button[data-testid="add-variable"]').click();
await page.locator('input[name="1.name"]').fill('endpoint');
await page.locator('tr').filter({ has: page.locator('input[name="1.name"]') }).locator('.CodeMirror').click();
await page.keyboard.type('https://{{host}}/users');
// Save and close
await page.getByRole('button', { name: 'Save' }).click();
await page.getByText('×').click();
await saveEnvironment(page);
await closeEnvironmentPanel(page);
});
await test.step('Create request with variable references', async () => {
@@ -256,22 +234,18 @@ test.describe('Variable Tooltip', () => {
await createCollection(page, collectionName, await createTmpDir('tooltip-readonly-collection'), {
openWithSandboxMode: 'safe'
});
await expect(page.locator('#sidebar-collection-name').filter({ hasText: collectionName })).toBeVisible();
// Create environment
await page.locator('[data-testid="environment-selector-trigger"]').click();
await page.locator('button[id="create-env"]').click();
await page.locator('input[name="name"]').fill('Readonly Env');
await page.getByRole('button', { name: 'Create' }).click();
await page.getByRole('button', { name: 'Save' }).click();
await page.getByText('×').click();
await createEnvironment(page, 'Readonly Env', 'collection');
await saveEnvironment(page);
await closeEnvironmentPanel(page);
// Create request using utility method
await createRequest(page, 'Readonly Test', collectionName);
// Set the URL
await page.locator('.collection-item-name').filter({ hasText: 'Readonly Test' }).click();
const urlEditor = page.locator('#request-url .CodeMirror');
const locators = buildCommonLocators(page);
await locators.sidebar.request('Readonly Test').click();
const urlEditor = locators.request.urlInput();
await urlEditor.click();
await page.keyboard.type('https://example.com');
await page.keyboard.press('Control+s');