feat: add redirect and timeout in request settings (#5672)

* feat: add redirect and timeout in request settings
This commit is contained in:
Pooja
2025-10-08 20:00:37 +05:30
committed by GitHub
parent ce40949564
commit 0c30357b01
29 changed files with 898 additions and 56 deletions

View File

@@ -0,0 +1,9 @@
{
"version": "1",
"name": "settings-test",
"type": "collection",
"ignore": [
"node_modules",
".git"
]
}

View File

@@ -0,0 +1,17 @@
meta {
name: max-redirects-test
type: http
seq: 1
}
get {
url: https://httpbun.com/redirect/2
body: none
auth: inherit
}
settings {
followRedirects: true
maxRedirects: 1
timeout: 0
}

View File

@@ -0,0 +1,17 @@
meta {
name: no-redirects-test
type: http
seq: 2
}
get {
url: https://httpbun.com/redirect/2
body: none
auth: inherit
}
settings {
followRedirects: false
maxRedirects: 5
timeout: 0
}

View File

@@ -0,0 +1,17 @@
meta {
name: timeout-test
type: http
seq: 3
}
get {
url: https://httpbun.com/redirect/2
body: none
auth: inherit
}
settings {
followRedirects: false
maxRedirects: 0
timeout: 5
}

View File

@@ -0,0 +1,10 @@
{
"collections": [
{
"path": "{{projectRoot}}/tests/request/settings/collection",
"securityConfig": {
"jsSandboxMode": "safe"
}
}
]
}

View File

@@ -0,0 +1,6 @@
{
"maximized": true,
"lastOpenedCollections": [
"{{projectRoot}}/tests/request/settings/collection"
]
}

View File

@@ -0,0 +1,46 @@
import { test, expect } from '../../../playwright';
test.describe('Max Redirects Settings Tests', () => {
test('should configure and test max 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 max-redirects request
await page.getByRole('complementary').getByText('max-redirects').click();
// Go to Settings tab
await page.getByRole('tab', { name: 'Settings' }).click();
// Test Max Redirects Settings
const maxRedirectsInput = page.locator('input[id="maxRedirects"]');
await expect(maxRedirectsInput).toBeVisible();
// Verify default value from .bru file (1)
await expect(maxRedirectsInput).toHaveValue('1');
// Test Follow Redirects toggle
const followRedirectsToggle = page.getByTestId('follow-redirects-toggle');
await expect(followRedirectsToggle).toBeVisible();
await expect(followRedirectsToggle).toBeChecked();
// Send the request
await page.getByTestId('send-arrow-icon').click();
await expect(page.getByTestId('response-status-code')).toContainText('302', { timeout: 15000 });
// change the max redirects to 2
await maxRedirectsInput.fill('2');
await page.getByTestId('send-arrow-icon').click();
await expect(page.getByTestId('response-status-code')).toContainText('200', { timeout: 15000 });
});
test.afterEach(async ({ pageWithUserData: page }) => {
// Close the single open tab
await page.locator('.close-icon-container').click();
await page.locator('button:has-text("Don\'t Save")').first().click();
});
});

View File

@@ -0,0 +1,50 @@
import { test, expect } from '../../../playwright';
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 page.getByRole('tab', { name: 'Settings' }).click();
// 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 });
});
test.afterEach(async ({ pageWithUserData: page }) => {
// Close the single open tab
await page.locator('.close-icon-container').click();
await page.locator('button:has-text("Don\'t Save")').first().click();
});
});

View File

@@ -0,0 +1,38 @@
import { test, expect } from '../../../playwright';
import { closeAllCollections } from '../../utils/page';
test.describe('Timeout Settings Tests', () => {
test('should configure and test timeout 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 thetimeout request
await page.getByRole('complementary').getByText('timeout-test').click();
// Go to Settings tab
await page.getByRole('tab', { name: 'Settings' }).click();
// Test Timeout Settings
const timeoutInput = page.locator('input[id="timeout"]');
await expect(timeoutInput).toBeVisible();
// Verify default value from .bru file (5)
await expect(timeoutInput).toHaveValue('5');
await page.getByTestId('send-arrow-icon').click();
const responsePane = page.locator('.response-pane');
await expect(responsePane).toContainText('timeout of 5ms exceeded');
// go to welcome page
await page.locator('.bruno-logo').click();
});
test.afterEach(async ({ pageWithUserData: page }) => {
// cleanup: close all collections
await closeAllCollections(page);
});
});