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

[RUMF-407] improve resource timings collection #315

Merged
merged 8 commits into from
Mar 25, 2020
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}`)
BenoitZugmeyer marked this conversation as resolved.
Show resolved Hide resolved
} else {
res.redirect('../ok')
}
})
}

function send(res, data) {
Expand Down