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

fix: keep only necessary fields for network info #467

Merged
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
232 changes: 87 additions & 145 deletions __tests__/fixtures/networkinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,184 +25,126 @@

import { NetworkInfo } from '../../src/common_types';

export const NETWORK_INFO: Array<Partial<NetworkInfo>> = [
export const NETWORK_INFO: Array<NetworkInfo> = [
{
browser: { name: 'HeadlessChrome', version: '90.0.4392.0' },
step: {
name: 'go to app',
index: 1,
},
timestamp: 1612482095137858,
url: 'https://vigneshh.in/',
browser: { name: 'HeadlessChrome', version: '94.0.4595.0' },
step: null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we not actually use the step info in the UI? I had thought we did. Even if this is the case, this seems really useful to include for ad-hoc usage by users.

Copy link
Member Author

@vigneshshanmugam vigneshshanmugam Mar 10, 2022

Choose a reason for hiding this comment

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

We do, I just removed from the fixture and only for the tests as there is none for this test.

timestamp: 1646782451347652.5,
url: 'http://localhost:56899/index',
type: 'Document',
request: {
url: 'https://vigneshh.in/',
url: 'http://localhost:56899/index',
vigneshshanmugam marked this conversation as resolved.
Show resolved Hide resolved
method: 'GET',
headers: {
'Upgrade-Insecure-Requests': '1',
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4392.0 Safari/537.36',
':method': 'GET',
':path': '/',
'user-agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4392.0 Safari/537.36',
'accept-encoding': 'gzip, deflate, br',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/94.0.4595.0 Safari/537.36 Elastic/Synthetics',
Host: 'localhost:56899',
Connection: 'keep-alive',
},
mixedContentType: 'none',
initialPriority: 'VeryHigh',
referrerPolicy: 'strict-origin-when-cross-origin',
bytes: 0,
referrer: undefined,
},
type: 'Document',
method: 'GET',
requestSentTime: 2355505.10179,
isNavigationRequest: true,
status: 200,
loadEndTime: 2355505.448326,
responseReceivedTime: 2355505.4514,
response: {
url: 'https://vigneshh.in/',
headers: {},
url: 'http://localhost:56899/index',
status: 200,
statusText: '',
protocol: 'http/1.1',
statusText: 'OK',
headers: {
'content-type': 'text/html',
Date: 'Tue, 08 Mar 2022 23:34:11 GMT',
Connection: 'keep-alive',
'Keep-Alive': 'timeout=5',
'Content-Length': '46',
},
mimeType: 'text/html',
connectionReused: false,
connectionId: 12,
remoteIPAddress: '[2606:4700:3035::ac43:83e0]',
remotePort: 443,
fromDiskCache: false,
remoteIPAddress: '[::1]',
remotePort: 56899,
fromServiceWorker: false,
fromPrefetchCache: false,
encodedDataLength: 3329,
responseTime: 1612482095476.922,
protocol: 'h2',
securityState: 'secure',
securityDetails: {
protocol: 'TLS 1.3',
keyExchange: '',
keyExchangeGroup: 'X25519',
cipher: 'AES_128_GCM',
certificateId: 0,
subjectName: 'sni.cloudflaressl.com',
sanList: [],
issuer: 'Cloudflare Inc ECC CA-3',
validFrom: 1595980800,
validTo: 1627560000,
signedCertificateTimestampList: [],
certificateTransparencyCompliance: 'unknown',
redirectURL: undefined,
timing: {
requestTime: 300869.367875,
proxyStart: -1,
proxyEnd: -1,
dnsStart: 0.25,
dnsEnd: 0.25,
connectStart: 0.25,
connectEnd: 0.5,
sslStart: -1,
sslEnd: -1,
workerStart: -1,
workerReady: -1,
workerFetchStart: -1,
workerRespondWithSettled: -1,
sendStart: 0.5,
sendEnd: 0.5,
pushStart: 0,
pushEnd: 0,
receiveHeadersEnd: 5.125,
},
body: { bytes: 194 },
},
transferSize: 3392,
resourceSize: 7634,
isNavigationRequest: true,
requestSentTime: 300869.36725,
responseReceivedTime: 300869.3735,
loadEndTime: 300869.373125,
resourceSize: 46,
transferSize: 194,
timings: {
blocked: 2.080999780446291,
queueing: 2.145999576896429,
blocked: 0.24999998277053237,
queueing: 0.6249999860301614,
proxy: -1,
dns: 45.81400007009506,
ssl: 61.003000009804964,
connect: 78.5130001604557,
send: 0.5449997261166573,
wait: 212.02100021764636,
receive: 3.9220000617206097,
total: 346.5359997935593,
dns: 0,
ssl: -1,
connect: 0.2500000409781933,
send: 0,
wait: 4.625000001396984,
receive: 0.12499996228143573,
total: 5.874999973457307,
},
},
{
browser: { name: 'HeadlessChrome', version: '90.0.4392.0' },
step: {
name: 'go to app',
index: 1,
},
timestamp: 1612482095517516,
url: 'https://vigneshh.in/static/main.js',
browser: { name: 'HeadlessChrome', version: '94.0.4595.0' },
step: null,
timestamp: 1646782451408470,
url: 'http://localhost:56899/delay100',
type: 'Script',
request: {
url: 'https://vigneshh.in/static/main.js',
url: 'http://localhost:56899/delay100',
method: 'GET',
headers: {
Referer: 'https://vigneshh.in/',
Referer: 'http://localhost:56899/index',
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4392.0 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/94.0.4595.0 Safari/537.36 Elastic/Synthetics',
Host: 'localhost:56899',
Connection: 'keep-alive',
},
mixedContentType: 'none',
initialPriority: 'Low',
referrerPolicy: 'strict-origin-when-cross-origin',
bytes: 0,
referrer: undefined,
},
type: 'Script',
method: 'GET',
requestSentTime: 2355505.472502,
isNavigationRequest: false,
status: 200,
loadEndTime: 2355505.589043,
responseReceivedTime: 2355505.603987,
response: {
url: 'https://vigneshh.in/static/main.js',
status: 200,
statusText: '',
status: -1,
mimeType: 'x-unknown',
headers: {},
mimeType: 'application/javascript',
connectionReused: true,
connectionId: 12,
remoteIPAddress: '[2606:4700:3035::ac43:83e0]',
remotePort: 443,
fromDiskCache: false,
fromServiceWorker: false,
fromPrefetchCache: false,
encodedDataLength: 425,
responseTime: 1612482095622.864,
protocol: 'h2',
securityState: 'secure',
securityDetails: {
protocol: 'TLS 1.3',
keyExchange: '',
keyExchangeGroup: 'X25519',
cipher: 'AES_128_GCM',
certificateId: 0,
subjectName: 'sni.cloudflaressl.com',
sanList: [],
issuer: 'Cloudflare Inc ECC CA-3',
validFrom: 1595980800,
validTo: 1627560000,
signedCertificateTimestampList: [],
certificateTransparencyCompliance: 'unknown',
},
timing: null,
},
isNavigationRequest: false,
requestSentTime: 300869.377,
responseReceivedTime: -1,
loadEndTime: 300869.45675,
resourceSize: 0,
transferSize: 0,
timings: {
blocked: 1.058999914675951,
queueing: 46.335999853909016,
blocked: 79.75000003352761,
queueing: -1,
proxy: -1,
dns: -1,
ssl: -1,
connect: -1,
send: 0.2100002020597458,
wait: 68.73499974608421,
receive: 0.2009999006986618,
total: 116.54099961742759,
send: -1,
wait: -1,
receive: -1,
total: 79.75000003352761,
},
},
{
browser: { name: 'HeadlessChrome', version: '90.0.4392.0' },
timestamp: 1612482095713278,
url: 'https://www.google-analytics.com/',
request: {
url: 'https://www.google-analytics.com/',
method: 'POST',
headers: {
Referer: 'https://vigneshh.in/',
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4392.0 Safari/537.36',
'Content-Type': 'text/plain',
},
hasPostData: true,
mixedContentType: 'none',
initialPriority: 'High',
referrerPolicy: 'strict-origin-when-cross-origin',
},
type: 'XHR',
method: 'POST',
requestSentTime: 2355505.677688,
isNavigationRequest: false,
status: 0,
loadEndTime: -1,
responseReceivedTime: -1,
response: null,
timings: null,
},
];
17 changes: 9 additions & 8 deletions __tests__/plugins/network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ describe('network', () => {
request: expect.any(Object),
response: expect.any(Object),
type: 'Document',
method: 'GET',
requestSentTime: expect.any(Number),
status: 200,
loadEndTime: expect.any(Number),
responseReceivedTime: expect.any(Number),
timings: expect.any(Object),
Expand Down Expand Up @@ -90,9 +88,9 @@ describe('network', () => {
await driver.page.goto(server.PREFIX + '/route1');
const netinfo = await network.stop();
expect(netinfo.length).toEqual(3);
expect(netinfo[0].status).toBe(302);
expect(netinfo[1].status).toBe(302);
expect(netinfo[2].status).toBe(200);
expect(netinfo[0].response.status).toBe(302);
expect(netinfo[1].response.status).toBe(302);
expect(netinfo[2].response.status).toBe(200);
await Gatherer.stop();
});

Expand Down Expand Up @@ -136,8 +134,12 @@ describe('network', () => {
expect(netinfo.length).toBe(2);
expect(netinfo[1]).toMatchObject({
url: `${server.PREFIX}/delay100`,
status: 0,
response: null,
response: {
headers: {},
mimeType: 'x-unknown',
status: -1,
timing: null,
},
timings: expect.any(Object),
});
expect(netinfo[1].timings.total).toBeGreaterThan(delayTime);
Expand Down Expand Up @@ -172,7 +174,6 @@ describe('network', () => {
expect(netinfo.length).toBe(2);
expect(netinfo[1]).toMatchObject({
url: `${server.PREFIX}/chunked`,
status: 200,
response: expect.any(Object),
timings: expect.any(Object),
});
Expand Down
Loading