-
-
Notifications
You must be signed in to change notification settings - Fork 8
fix(http): show only valid http statuses #201
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
Merged
erkamyaman
merged 2 commits into
santoshyadavdev:main
from
abiramcodes:fix/http-statuses
Oct 2, 2026
Merged
Changes from all commits
Commits
Show all changes
2 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| import { TestBed, type ComponentFixture } from '@angular/core/testing'; | ||
| import { afterEach, beforeAll, describe, expect, it } from 'vitest'; | ||
| import { NetworkInspector } from '../pages/network-inspector'; | ||
|
|
||
| let fixture: ComponentFixture<NetworkInspector>; | ||
|
|
||
| async function mount() { | ||
| fixture = TestBed.createComponent(NetworkInspector); | ||
| document.body.append(fixture.nativeElement); | ||
| await fixture.whenStable(); | ||
| const host = fixture.nativeElement as HTMLElement; | ||
| const pattern = host.querySelector<HTMLInputElement>('#rule-pattern')!; | ||
| pattern.value = '/api/products'; | ||
| pattern.dispatchEvent(new Event('input')); | ||
| await fixture.whenStable(); | ||
| const trigger = host.querySelector<HTMLButtonElement>( | ||
| 'button[role="combobox"][aria-labelledby="rule-status-label"]', | ||
| )!; | ||
| const hint = () => host.querySelector('#rule-hint')!.textContent!.trim(); | ||
| return { host, trigger, hint, inspector: fixture.componentInstance }; | ||
| } | ||
|
|
||
| describe('NetworkInspector rule status', () => { | ||
| beforeAll(() => { | ||
| Element.prototype.scrollIntoView ??= () => {}; | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| fixture?.destroy(); | ||
| TestBed.resetTestingModule(); | ||
| }); | ||
|
|
||
| it('labels the status dropdown and lists no 1xx statuses', async () => { | ||
| const { host, trigger } = await mount(); | ||
| expect(host.querySelector('#rule-status-label')!.textContent!.trim()).toBe('Status'); | ||
| expect(trigger.textContent!.trim()).toBe('None'); | ||
| trigger.click(); | ||
| await fixture.whenStable(); | ||
| const labels = [...host.querySelectorAll('[role="option"]')].map((o) => o.textContent!.trim()); | ||
| expect(labels[0]).toBe('None'); | ||
| expect(labels.some((l) => l.startsWith('1'))).toBe(false); | ||
| expect(labels).toContain('499 Client Closed Request'); | ||
| expect(labels).toContain('524 A Timeout Occurred'); | ||
| }); | ||
|
|
||
| it('sets the rule status from the option picked in the dropdown', async () => { | ||
| const { host, trigger, inspector } = await mount(); | ||
| trigger.click(); | ||
| await fixture.whenStable(); | ||
| const option = [...host.querySelectorAll<HTMLElement>('[role="option"]')].find( | ||
| (o) => o.textContent!.trim() === '503 Service Unavailable', | ||
| )!; | ||
| option.click(); | ||
| await fixture.whenStable(); | ||
| expect(trigger.getAttribute('aria-expanded')).toBe('false'); | ||
| expect(trigger.textContent!.trim()).toBe('503 Service Unavailable'); | ||
| expect(inspector.draft().status).toBe('503'); | ||
| expect(inspector.draftRule()).toMatchObject({ pattern: '/api/products', status: 503 }); | ||
| }); | ||
|
|
||
| it('picks a status by typing its code', async () => { | ||
| const { trigger, inspector } = await mount(); | ||
| trigger.focus(); | ||
| for (const key of '404') { | ||
| trigger.dispatchEvent(new KeyboardEvent('keydown', { key, bubbles: true })); | ||
| } | ||
| await fixture.whenStable(); | ||
| expect(inspector.draft().status).toBe('404'); | ||
| expect(inspector.draftRule()).toMatchObject({ status: 404 }); | ||
| }); | ||
|
|
||
| it('refuses a status that is not in the list', async () => { | ||
| const { hint, inspector } = await mount(); | ||
| for (const status of ['599', '101', '42', 'abc']) { | ||
| inspector.setDraft('status', status); | ||
| await fixture.whenStable(); | ||
| expect(inspector.draftRule()).toBeNull(); | ||
| expect(hint()).toBe('Pick a status from the list.'); | ||
| } | ||
| inspector.setDraft('status', '520'); | ||
| await fixture.whenStable(); | ||
| expect(inspector.draftRule()).toMatchObject({ status: 520 }); | ||
| expect(hint()).toBe(''); | ||
| }); | ||
| }); |
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
2 changes: 1 addition & 1 deletion
2
...ts/browser-agent-rpc-BXhoSh1z-CX0hg10w.js → ...ts/browser-agent-rpc-BXhoSh1z-Puowg-lh.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.