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,24 +1,23 @@
import { test, expect } from '../../../playwright';
import { closeAllCollections, openCollectionAndAcceptSandbox } from '../../utils/page';
import { closeAllCollections, openCollectionAndAcceptSandbox, sendRequest } from '../../utils/page';
import { buildCommonLocators } from '../../utils/page/locators';
test.describe.serial('Dynamic Variable Interpolation', () => {
test.afterEach(async ({ pageWithUserData: page }) => {
// cleanup: close all collections
await closeAllCollections(page);
});
test('Verifying if the bru.setVar method interpolates random generator functions properly', async ({ pageWithUserData: page }) => {
const locators = buildCommonLocators(page);
// Open collection and accept sandbox mode
await openCollectionAndAcceptSandbox(page, 'dynamic-variable-interpolation', 'safe');
// Navigate to the request
await page.getByRole('complementary').getByText('set-var-dynamic-variable').click();
await locators.sidebar.request('set-var-dynamic-variable').click();
// Send the request
await page.getByTestId('send-arrow-icon').click();
// Wait for the response and verify status code
await expect(page.getByTestId('response-status-code')).toHaveText(/200/);
await sendRequest(page, 200);
// Verify response contains the title field and that it's not the literal interpolation string
const responsePane = page.locator('.response-pane');

View File

@@ -1,28 +1,26 @@
import { test, expect } from '../../playwright';
import { closeAllCollections } from '../utils/page';
import { closeAllCollections, sendRequest } from '../utils/page';
import { buildCommonLocators } from '../utils/page/locators';
test.describe.serial('URL Interpolation', () => {
test.afterAll(async ({ pageWithUserData: page }) => {
// cleanup: close all collections
await closeAllCollections(page);
});
test('Interpolate basic path params', async ({ pageWithUserData: page }) => {
await page.locator('#sidebar-collection-name').click();
await page.getByRole('complementary').getByText('echo-request-url').click();
await page.getByTestId('send-arrow-icon').click();
await expect(page.getByTestId('response-status-code')).toHaveText(/200/);
const locators = buildCommonLocators(page);
await locators.sidebar.collection('interpolation').click();
await locators.sidebar.request('echo-request-url').click();
await sendRequest(page, 200);
const texts = await page.locator('div:nth-child(2) > .CodeMirror-scroll').allInnerTexts();
await expect(texts.some((d) => d.includes(`"url": "/path/some-data"`))).toBe(true);
});
test('Interpolate oData path params', async ({ pageWithUserData: page }) => {
await page.getByRole('complementary').getByText('echo-request-odata').click();
await page.getByTestId('send-arrow-icon').click();
await expect(page.getByTestId('response-status-code')).toHaveText(/200/);
const locators = buildCommonLocators(page);
await locators.sidebar.request('echo-request-odata').click();
await sendRequest(page, 200);
const texts = await page.locator('div:nth-child(2) > .CodeMirror-scroll').allInnerTexts();
await expect(texts.some((d) => d.includes(`"url": "/path/Category('category123')/Item(item456)/foobar/Tags(%22tag%20test%22)"`))).toBe(true);