Skip to content
Open
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
21 changes: 14 additions & 7 deletions src/formatters/NetworkFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,24 @@ export class NetworkFormatter {
const httpResponse = request.response();
const failure = request.failure();
let status: string;
if (httpResponse) {
const responseStatus = httpResponse.status();
status =
responseStatus >= 200 && responseStatus <= 299
? `[success - ${responseStatus}]`
: `[failed - ${responseStatus}]`;
} else if (failure) {
if (failure) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved failure first because if we have this text should be more helpful than the status code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need add the status code if it exist in this branch as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am in favour of a regular structure. It is not like if the failure comes first the LLM would necessarily pay more attention (might be quite the opposite)

status = `[failed - ${failure.errorText}]`;
} else if (httpResponse) {
const responseStatus = httpResponse.status();

if (responseStatus >= 100 && responseStatus <= 199) {
status = `[info - ${responseStatus}]`;
} else if (responseStatus >= 200 && responseStatus <= 299) {
status = `[success - ${responseStatus}]`;
} else if (responseStatus >= 300 && responseStatus <= 399) {
status = `[redirect - ${responseStatus}]`;
} else {
status = `[failed - ${responseStatus}]`;
}
} else {
status = '[pending]';
}

return status;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/formatters/NetworkFormatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('NetworkFormatter', () => {

assert.equal(
formatter.toString(),
'reqid=1 GET http://example.com [failed - 199]',
'reqid=1 GET http://example.com [info - 199]',
);
});
it('shows correct status for request with response code above 200', async () => {
Expand All @@ -61,7 +61,7 @@ describe('NetworkFormatter', () => {

assert.equal(
formatter.toString(),
'reqid=1 GET http://example.com [failed - 300]',
'reqid=1 GET http://example.com [redirect - 300]',
);
});
it('shows correct status for request that failed', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/tools/network.test.js.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ exports[`network > network_list_requests > list requests from previous navigatio
# list_request response
## Network requests
Showing 1-3 of 3 (Page 1 of 1).
reqid=1 GET http://localhost:<port>/redirect [failed - 302]
reqid=1 GET http://localhost:<port>/redirect [redirect - 302]
reqid=2 GET http://localhost:<port>/redirected [success - 200]
reqid=3 GET http://localhost:<port>/redirected-page [success - 200]
`;
2 changes: 1 addition & 1 deletion tests/tools/performance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('performance', () => {
});
});

it.only('supports filePath', async () => {
it('supports filePath', async () => {
const rawData = loadTraceAsBuffer('basic-trace.json.gz');
// rawData is the decompressed buffer (based on loadTraceAsBuffer implementation).
// We want to simulate saving it as a .gz file, so the tool should compress it.
Expand Down
Loading