-
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
Open
shubh-bruno
wants to merge
5
commits into
usebruno:main
Choose a base branch
from
shubh-bruno:fix/timeout-yaml
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+212
−47
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
tests/request/settings/collection/requests-settings-yml/opencollection.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| opencollection: "1.0.0" | ||
|
|
||
| info: | ||
| name: settings-yaml | ||
|
|
||
| bundled: false |
14 changes: 14 additions & 0 deletions
14
tests/request/settings/collection/requests-settings-yml/timeout.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
8 changes: 7 additions & 1 deletion
8
tests/request/settings/init-user-data/collection-security.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,56 +1,186 @@ | ||
| import { test, expect } from '../../../playwright'; | ||
| import { execSync } from 'child_process'; | ||
| import fs from 'fs'; | ||
| import path from 'path'; | ||
| import { expect, Page, test } from '../../../playwright'; | ||
| import { closeAllCollections, selectRequestPaneTab } from '../../utils/page'; | ||
|
|
||
| const bruRequestPath = path.join(__dirname, 'collection', 'requests-settings-bru', 'timeout.bru'); | ||
| const yamlRequestPath = path.join(__dirname, 'collection', 'requests-settings-yml', 'timeout.yml'); | ||
|
|
||
| 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 }); | ||
|
|
||
| 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); | ||
| }); | ||
|
|
||
| test.afterAll(() => { | ||
| execSync(`git checkout -- "${bruRequestPath}" "${yamlRequestPath}"`); | ||
| }); | ||
|
|
||
| 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(); | ||
|
|
||
| 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 selectRequestPaneTab(page, 'Settings'); | ||
|
|
||
| // Test Timeout Settings with custom value | ||
| const timeoutInput = page.locator('input[id="timeout"]'); | ||
| await expect(timeoutInput).toBeVisible(); | ||
|
|
||
| await page.locator('#sidebar-collection-name').getByText('settings-test').click(); | ||
| // Navigate to thetimeout request | ||
| await page.getByRole('complementary').getByText('timeout-test').click(); | ||
| // Verify default value from .bru file (5) | ||
| await expect(timeoutInput).toHaveValue('5'); | ||
|
|
||
| // Go to Settings tab | ||
| await selectRequestPaneTab(page, 'Settings'); | ||
| await page.getByTestId('send-arrow-icon').click(); | ||
|
|
||
| // Test Timeout Settings with custom value | ||
| const timeoutInput = page.locator('input[id="timeout"]'); | ||
| await expect(timeoutInput).toBeVisible(); | ||
| const responsePane = page.locator('.response-pane'); | ||
| await expect(responsePane).toContainText('timeout of 5ms exceeded'); | ||
|
|
||
| // Verify default value from .bru file (5) | ||
| await expect(timeoutInput).toHaveValue('5'); | ||
| // Change the global request timeout preference that "inherit" should fall back to | ||
| await setGlobalRequestTimeout(page, '10'); | ||
|
|
||
| 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'); | ||
|
|
||
| const responsePane = page.locator('.response-pane'); | ||
| await expect(responsePane).toContainText('timeout of 5ms exceeded'); | ||
| // 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(); | ||
|
|
||
| // 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(); | ||
|
|
||
| // 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(); | ||
| // Save the request so the inherit setting is serialized to the .bru file | ||
| const saveShortcut = process.platform === 'darwin' ? 'Meta+s' : 'Control+s'; | ||
| await page.keyboard.press(saveShortcut); | ||
| await expect(page.getByText('Request saved successfully')).toBeVisible(); | ||
|
|
||
| // Run the request with inherit timeout | ||
| await page.getByTestId('send-arrow-icon').click(); | ||
| // Verify persistence: the serialized file must keep timeout: inherit (not reset to a custom value) | ||
| const savedContent = fs.readFileSync(bruRequestPath, 'utf-8'); | ||
| expect(savedContent).toMatch(/timeout:\s*['"]?inherit['"]?/); | ||
|
|
||
| // Verify the request runs successfully with inherited timeout (should not timeout) | ||
| await expect(responsePane).toContainText('302'); | ||
| // Reopen the request to confirm the inherit state persists in the Settings UI | ||
| const requestTab = page.locator('.request-tab').filter({ hasText: 'timeout-test' }); | ||
| await requestTab.hover(); | ||
| await requestTab.getByTestId('request-tab-close-icon').click({ force: true }); | ||
|
|
||
| // 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(); | ||
| await page.getByRole('complementary').getByText('timeout-test').click(); | ||
| await selectRequestPaneTab(page, 'Settings'); | ||
|
|
||
| // Settings UI should still show Inherit (not a custom value) after reopening | ||
| await expect(inheritButton).toBeVisible(); | ||
| await expect(timeoutInput).not.toBeVisible(); | ||
|
|
||
| // Run the request with the inherited timeout | ||
| await page.getByTestId('send-arrow-icon').click(); | ||
|
|
||
| // Verify the inherited timeout resolves to the global preference (10ms), not the file value (5ms) | ||
| await expect(responsePane).toContainText('timeout of 10ms exceeded', { timeout: 15000 }); | ||
| }); | ||
| }); | ||
|
|
||
| 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(); | ||
|
|
||
| // Save the request so the inherit setting is serialized to the .yml file | ||
| const saveShortcut = process.platform === 'darwin' ? 'Meta+s' : 'Control+s'; | ||
| await page.keyboard.press(saveShortcut); | ||
| await expect(page.getByText('Request saved successfully')).toBeVisible(); | ||
|
|
||
| // Verify YAML persistence: the serialized file must keep timeout: inherit (not reset to 0) | ||
| const savedContent = fs.readFileSync(yamlRequestPath, 'utf-8'); | ||
| expect(savedContent).toMatch(/timeout:\s*['"]?inherit['"]?/); | ||
|
|
||
| // Reopen the request to confirm the inherit state persists in the Settings UI | ||
| const requestTab = page.locator('.request-tab').filter({ hasText: 'timeout-test-yaml' }); | ||
| await requestTab.hover(); | ||
| await requestTab.getByTestId('request-tab-close-icon').click({ force: true }); | ||
|
|
||
| await page.getByRole('complementary').getByText('timeout-test-yaml').click(); | ||
| await selectRequestPaneTab(page, 'Settings'); | ||
|
|
||
| // Settings UI should still show Inherit (not a custom value) after reopening | ||
| await expect(inheritButton).toBeVisible(); | ||
| await expect(timeoutInput).not.toBeVisible(); | ||
|
|
||
| // Run the request with the inherited timeout | ||
| await page.getByTestId('send-arrow-icon').click(); | ||
|
|
||
| // Verify the inherited timeout resolves to the global preference (10ms), not the file value (5ms) | ||
| await expect(responsePane).toContainText('timeout of 10ms exceeded', { timeout: 15000 }); | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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