Files
bruno/tests/request/settings/no-redirects.spec.ts
2026-02-14 21:03:58 +05:30

50 lines
2.1 KiB
TypeScript

import { test, expect } from '../../../playwright';
import { selectRequestPaneTab } from '../../utils/page';
test.describe('No Redirects Settings Tests', () => {
test('should configure and test no redirects settings', async ({
pageWithUserData: page
}) => {
// Navigate to the test collection and request
await expect(page.locator('#sidebar-collection-name').getByText('settings-test')).toBeVisible();
await page.locator('#sidebar-collection-name').getByText('settings-test').click();
// Navigate to the no-redirects request
await page.getByRole('complementary').getByText('no-redirects').click();
// Go to Settings tab
await selectRequestPaneTab(page, 'Settings');
// Test No Redirects Settings
const maxRedirectsInput = page.locator('input[id="maxRedirects"]');
await expect(maxRedirectsInput).toBeVisible();
// Verify default value from .bru file (5)
await expect(maxRedirectsInput).toHaveValue('5');
// Test Follow Redirects toggle - should be unchecked
const followRedirectsToggle = page.getByTestId('follow-redirects-toggle');
await expect(followRedirectsToggle).toBeVisible();
await expect(followRedirectsToggle).not.toBeChecked();
// Send the request - should stop at first redirect (302) without following
await page.getByTestId('send-arrow-icon').click();
// Should get 302 because redirects are disabled, regardless of maxRedirects value
await expect(page.getByTestId('response-status-code')).toContainText('302', { timeout: 15000 });
// Toggle follow redirects to true
await followRedirectsToggle.click();
await expect(followRedirectsToggle).toBeChecked();
// Send request again - now should follow redirects and get 200
await page.getByTestId('send-arrow-icon').click();
await expect(page.getByTestId('response-status-code')).toContainText('200', { timeout: 15000 });
// Close without saving to avoid modifying the .bru file
await page.locator('.close-icon-container').click({ force: true });
await page.locator('button:has-text("Don\'t Save")').first().click();
});
});