Skip to content

Commit

Permalink
✅ [RUM] add redirect timings tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitZugmeyer committed Mar 23, 2020
1 parent 7b0c4f4 commit 5a0ddca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/e2e/scenario/agents.scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ describe('rum', () => {
expectToHaveValidTimings(timing!)
})

it('should track redirect xhr timings', async () => {
const timing = await makeXHRAndCollectEvent(`${serverUrl.sameOrigin}/redirect/1`)
expect(timing!).not.toBeUndefined()
expect(timing!.http.method).toEqual('GET')
expect((timing!.http as any).status_code).toEqual(200)
expectToHaveValidTimings(timing!)
expect(timing!.http.performance!.redirect).not.toBeUndefined()
expect(timing!.http.performance!.redirect!.duration).toBeGreaterThan(0)
})

it('should not track disallowed cross origin xhr timings', async () => {
const timing = await makeXHRAndCollectEvent(`${serverUrl.crossOrigin}/ok`)
expect(timing).not.toBeUndefined()
Expand Down
9 changes: 9 additions & 0 deletions test/server/fake-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ module.exports = (app) => {
}
res.send('ok')
})

app.get('/redirect/:n', (req, res) => {
const n = Number(req.params.n)
if (!isNaN(n) && n > 1) {
res.redirect(`${n - 1}`)
} else {
res.redirect('../ok')
}
})
}

function send(res, data) {
Expand Down

0 comments on commit 5a0ddca

Please sign in to comment.