From e04ba42a5ea9546549294460d72783998d089feb Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Thu, 29 Aug 2024 21:02:26 +0100 Subject: [PATCH] chore: clarify that tests are exercising our fetch wrapper (#1393) * chore: clarify that tests are exercising our fetch wrapper * comment * comment --- cypress/e2e/session-recording.cy.ts | 21 ++++++++++++++++++--- playground/cypress/index.html | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/session-recording.cy.ts b/cypress/e2e/session-recording.cy.ts index 54e37b3dc..f727e718f 100644 --- a/cypress/e2e/session-recording.cy.ts +++ b/cypress/e2e/session-recording.cy.ts @@ -113,14 +113,29 @@ describe('Session recording', () => { cy.phCaptures({ full: true }).then((captures) => { const snapshots = captures.filter((c) => c.event === '$snapshot') - const snapshotTypes: number[] = [] + const capturedRequests: Record[] = [] for (const snapshot of snapshots) { for (const snapshotData of snapshot.properties['$snapshot_data']) { - snapshotTypes.push(snapshotData.type) + if (snapshotData.type === 6) { + for (const req of snapshotData.data.payload.requests) { + capturedRequests.push(req) + } + } } } + // yay, includes type 6 network data - expect(snapshotTypes.filter((x) => x === 6)).to.have.length.above(0) + expect(capturedRequests).to.have.length.above(0) + + // the HTML file that cypress is operating on (playground/cypress/index.html) + // when the button for this test is click makes a post to https://example.com + const capturedFetchRequest = capturedRequests.find((cr) => cr.name === 'https://example.com/') + + expect(capturedFetchRequest.fetchStart).to.be.greaterThan(0) // proxy for including network timing info + + expect(capturedFetchRequest.initiatorType).to.eql('fetch') + expect(capturedFetchRequest.isInitial).to.be.undefined + expect(capturedFetchRequest.requestBody).to.eq('i am the fetch body') }) }) }) diff --git a/playground/cypress/index.html b/playground/cypress/index.html index 81ab457d6..f078dd791 100644 --- a/playground/cypress/index.html +++ b/playground/cypress/index.html @@ -15,7 +15,7 @@ Send custom event -