-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(timeout): allow inherit request timeout for yaml requests #8382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| opencollection: "1.0.0" | ||
|
|
||
| info: | ||
| name: settings-yaml | ||
|
|
||
| bundled: false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| info: | ||
| name: timeout-test-yaml | ||
| type: http | ||
| seq: 1 | ||
|
|
||
| http: | ||
| method: GET | ||
| url: https://testbench-sanity.usebruno.com/redirect-to-ping | ||
| auth: inherit | ||
|
|
||
| settings: | ||
| followRedirects: false | ||
| maxRedirects: 0 | ||
| timeout: 5 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,56 +1,143 @@ | ||
| import { test, expect } from '../../../playwright'; | ||
| import { expect, Page, test } from '../../../playwright'; | ||
| import { closeAllCollections, selectRequestPaneTab } from '../../utils/page'; | ||
|
|
||
| const setGlobalRequestTimeout = async (page: Page, value: string) => { | ||
| // Open preferences tab | ||
| await page.locator('.status-bar button[data-trigger="preferences"]').click(); | ||
|
|
||
| // Navigate to General tab (default, but ensure it) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
| const generalTab = page.getByRole('tab', { name: 'General' }); | ||
| await expect(generalTab).toBeVisible({ timeout: 10000 }); | ||
| await generalTab.click(); | ||
|
|
||
| // Update the Request Timeout (in ms) preference | ||
| const timeoutPreference = page.locator('input[name="timeout"]'); | ||
| await expect(timeoutPreference).toBeVisible({ timeout: 10000 }); | ||
| await timeoutPreference.fill(value); | ||
| await expect(timeoutPreference).toHaveValue(value, { timeout: 5000 }); | ||
|
|
||
| // Closing the preferences tab unmounts the form, which flushes the debounced save immediately | ||
| const preferencesTab = page.locator('.request-tab').filter({ hasText: 'Preferences' }); | ||
| await preferencesTab.hover(); | ||
| await preferencesTab.locator('.close-icon').click({ force: true }); | ||
| await expect(preferencesTab).not.toBeVisible({ timeout: 10000 }); | ||
| }; | ||
|
|
||
| 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(); | ||
| test.afterEach(async ({ pageWithUserData: page }) => { | ||
| await closeAllCollections(page); | ||
| }); | ||
|
|
||
| await page.locator('#sidebar-collection-name').getByText('settings-test').click(); | ||
| // Navigate to thetimeout request | ||
| await page.getByRole('complementary').getByText('timeout-test').click(); | ||
| test.describe('bru request timeout settings', () => { | ||
| 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(); | ||
|
|
||
| // Go to Settings tab | ||
| await selectRequestPaneTab(page, 'Settings'); | ||
| await page.locator('#sidebar-collection-name').getByText('settings-test').click(); | ||
| // Navigate to thetimeout request | ||
| await page.getByRole('complementary').getByText('timeout-test').click(); | ||
|
|
||
| // Test Timeout Settings with custom value | ||
| const timeoutInput = page.locator('input[id="timeout"]'); | ||
| await expect(timeoutInput).toBeVisible(); | ||
| // Go to Settings tab | ||
| await selectRequestPaneTab(page, 'Settings'); | ||
|
|
||
| // Verify default value from .bru file (5) | ||
| await expect(timeoutInput).toHaveValue('5'); | ||
| // Test Timeout Settings with custom value | ||
| const timeoutInput = page.locator('input[id="timeout"]'); | ||
| await expect(timeoutInput).toBeVisible(); | ||
|
|
||
| await page.getByTestId('send-arrow-icon').click(); | ||
| // Verify default value from .bru file (5) | ||
| await expect(timeoutInput).toHaveValue('5'); | ||
|
|
||
| const responsePane = page.locator('.response-pane'); | ||
| await expect(responsePane).toContainText('timeout of 5ms exceeded'); | ||
| await page.getByTestId('send-arrow-icon').click(); | ||
|
|
||
| // Now test inherit functionality | ||
| // Click the X button to reset to inherit | ||
| const resetButton = page.locator('button[title="Reset to inherit"]'); | ||
| await expect(resetButton).toBeVisible(); | ||
| await resetButton.click(); | ||
| const responsePane = page.locator('.response-pane'); | ||
| await expect(responsePane).toContainText('timeout of 5ms exceeded'); | ||
|
|
||
| // After reset, should see "Inherit" button instead of input | ||
| const inheritButton = page.locator('button:has-text("Inherit")'); | ||
| await expect(inheritButton).toBeVisible(); | ||
| await expect(timeoutInput).not.toBeVisible(); | ||
| // Change the global request timeout preference that "inherit" should fall back to | ||
| await setGlobalRequestTimeout(page, '10'); | ||
|
|
||
| // Run the request with inherit timeout | ||
| await page.getByTestId('send-arrow-icon').click(); | ||
| // Return to the request and Settings tab | ||
| await page.getByRole('complementary').getByText('timeout-test').click(); | ||
| await selectRequestPaneTab(page, 'Settings'); | ||
|
|
||
| // Verify the request runs successfully with inherited timeout (should not timeout) | ||
| await expect(responsePane).toContainText('302'); | ||
| // Now test inherit functionality | ||
| // Click the X button to reset to inherit | ||
| const resetButton = page.locator('button[title="Reset to inherit"]'); | ||
| await expect(resetButton).toBeVisible(); | ||
| await resetButton.click(); | ||
|
|
||
| // 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(); | ||
| // After reset, should see "Inherit" button instead of input | ||
| const inheritButton = page.locator('button:has-text("Inherit")'); | ||
| await expect(inheritButton).toBeVisible(); | ||
| await expect(timeoutInput).not.toBeVisible(); | ||
|
|
||
| // Run the request with inherit timeout | ||
| await page.getByTestId('send-arrow-icon').click(); | ||
|
|
||
| // Verify the request runs successfully with inherited timeout (should not timeout) | ||
| await expect(responsePane).toContainText('302'); | ||
|
Check failure on line 79 in tests/request/settings/timeout.spec.ts
|
||
|
|
||
| // 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(); | ||
| }); | ||
| }); | ||
|
|
||
| test.afterEach(async ({ pageWithUserData: page }) => { | ||
| // cleanup: close all collections | ||
| await closeAllCollections(page); | ||
| test.describe('yaml request timeout settings', () => { | ||
| test('should configure and test timeout settings for yaml request', async ({ | ||
| pageWithUserData: page | ||
| }) => { | ||
| // Navigate to the yaml test collection and request | ||
| await expect(page.locator('#sidebar-collection-name').getByText('settings-yaml')).toBeVisible(); | ||
|
|
||
| await page.locator('#sidebar-collection-name').getByText('settings-yaml').click(); | ||
| // Navigate to the timeout request | ||
| await page.getByRole('complementary').getByText('timeout-test-yaml').click(); | ||
|
|
||
| // Go to Settings tab | ||
| await selectRequestPaneTab(page, 'Settings'); | ||
|
|
||
| // Test Timeout Settings with custom value | ||
| const timeoutInput = page.locator('input[id="timeout"]'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we can use page.locator('#timeout'); directly |
||
| await expect(timeoutInput).toBeVisible(); | ||
|
|
||
| // Verify default value from .yml file (5) | ||
| await expect(timeoutInput).toHaveValue('5'); | ||
|
|
||
| await page.getByTestId('send-arrow-icon').click(); | ||
|
|
||
| // Verify the custom timeout (5ms) is applied | ||
| const responsePane = page.locator('.response-pane'); | ||
| await expect(responsePane).toContainText('timeout of 5ms exceeded'); | ||
|
|
||
| // Change the global request timeout preference that "inherit" should fall back to | ||
| await setGlobalRequestTimeout(page, '10'); | ||
|
|
||
| // Return to the request and Settings tab | ||
| await page.getByRole('complementary').getByText('timeout-test-yaml').click(); | ||
| await selectRequestPaneTab(page, 'Settings'); | ||
|
|
||
| // Now test inherit functionality | ||
| // Click the X button to reset to inherit | ||
| const resetButton = page.locator('button[title="Reset to inherit"]'); | ||
| await expect(resetButton).toBeVisible(); | ||
| await resetButton.click(); | ||
|
|
||
| // After reset, should see "Inherit" button instead of input | ||
| const inheritButton = page.locator('button:has-text("Inherit")'); | ||
| await expect(inheritButton).toBeVisible(); | ||
| await expect(timeoutInput).not.toBeVisible(); | ||
|
|
||
| // Run the request with inherit timeout | ||
| await page.getByTestId('send-arrow-icon').click(); | ||
|
|
||
| // Verify the inherited timeout resolves to the new global preference (10ms), not the file value (5ms) | ||
| await expect(responsePane).toContainText('timeout of 10ms exceeded', { timeout: 15000 }); | ||
|
|
||
| // Close without saving to avoid modifying the .yml file | ||
| await page.locator('.close-icon-container').click({ force: true }); | ||
| await page.locator('button:has-text("Don\'t Save")').first().click(); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| }); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant comment. please remove this