Skip to content
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

feat(ui-mode): display list of query params in request tab #32443

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/trace-viewer/src/ui/networkResourceDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ const RequestTab: React.FunctionComponent<{
Status Code: <span className={statusClass(resource.response.status)} style={{ display: 'inline-flex' }}>
{`${resource.response.status} ${resource.response.statusText}`}
</span></div>}
{resource.request.queryString.length ? <>
<div className='network-request-details-header'>Query String Parameters</div>
<div className='network-request-details-headers'>
{resource.request.queryString.map(param => `${param.name}: ${param.value}`).join('\n')}
</div>
</> : null}
<div className='network-request-details-header'>Request Headers</div>
<div className='network-request-details-headers'>{resource.request.headers.map(pair => `${pair.name}: ${pair.value}`).join('\n')}</div>
{requestBody && <div className='network-request-details-header'>Request Body</div>}
Expand Down
1 change: 1 addition & 0 deletions tests/assets/network-tab/network.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</style>
<script src='script.js'></script>
<script>fetch('/api/endpoint')</script>
<script>fetch('/call-with-query-params?param1=value1&param1=value2&param2=value2')</script>
<script>
const body = JSON.stringify({
data: {
Expand Down
25 changes: 25 additions & 0 deletions tests/playwright-test/ui-mode-test-network-tab.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,28 @@ test('should format JSON request body', async ({ runUITest, server }) => {
'}',
]);
});

test('should display list of query parameters (only if present)', async ({ runUITest, server }) => {
const { page } = await runUITest({
'network-tab.test.ts': `
import { test, expect } from '@playwright/test';
test('network tab test', async ({ page }) => {
await page.goto('${server.PREFIX}/network-tab/network.html');
});
`,
});

await page.getByText('network tab test').dblclick();
await page.getByText('Network', { exact: true }).click();

await page.getByText('call-with-query-params').click();

await expect(page.getByText('Query String Parameters')).toBeVisible();
await expect(page.getByText('param1: value1')).toBeVisible();
await expect(page.getByText('param1: value2')).toBeVisible();
await expect(page.getByText('param2: value2')).toBeVisible();

await page.getByText('endpoint').click();

await expect(page.getByText('Query String Parameters')).not.toBeVisible();
});
Loading