-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Convert browser/spa/fetch-body-propagation-ext.browser.js (#970)
- Loading branch information
Showing
4 changed files
with
56 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>formdata on click interaction</title> | ||
{init} | ||
{config} | ||
{loader} | ||
</head> | ||
<body> | ||
this page tests formdata after a click then sends the interaction | ||
<script> | ||
document.addEventListener('click', function () { | ||
const formData = new FormData() | ||
formData.append("hi", "bye") // empty FormData causes fetch failure in Request.formData | ||
|
||
const req = new Request('/formdata', { method: 'POST', body: formData }) | ||
|
||
req.formData().then(function () { | ||
setTimeout(newrelic.interaction().save().createTracer('timer'), 0) | ||
}) | ||
}) | ||
</script> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { notIE } from '../../../tools/browser-matcher/common-matchers.mjs' | ||
|
||
describe('interaction tracking works inside', () => { | ||
it.withBrowsersMatching(notIE)('single fetch with formData', async () => { | ||
const url = await browser.testHandle.assetURL('spa/fetch-formdata-onclick.html') | ||
await Promise.all([ | ||
browser.testHandle.expectInteractionEvents(), // Discard the initial page load interaction | ||
browser.url(url).then(() => browser.waitForAgentLoad()) | ||
]) | ||
|
||
const [clickInteractionResults] = await Promise.all([ | ||
browser.testHandle.expectInteractionEvents(7000), | ||
$('body').click() | ||
]) | ||
|
||
expect(clickInteractionResults.request.body).toEqual(expect.arrayContaining([ | ||
expect.objectContaining({ | ||
category: 'Custom', | ||
type: 'interaction', | ||
trigger: 'click', | ||
children: [ | ||
expect.objectContaining({ | ||
type: 'customTracer', | ||
name: 'timer', | ||
children: [] | ||
}) | ||
] | ||
}) | ||
])) | ||
}) | ||
}) |