-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(index): support to attach custom URL parameters to collection URL
- Loading branch information
Showing
3 changed files
with
65 additions
and
2 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
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
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,62 @@ | ||
<html> | ||
|
||
<head> | ||
<title>Test Runner</title> | ||
<script> | ||
// we load from localhost, and have the ability to | ||
// change the scripts that are being served. Check the | ||
// web-test-runner.config.js file for details | ||
window.RUM_BASE = window.origin; | ||
// we log what's being sent to the "server" | ||
window.called = []; | ||
// and navigator.sendBeacon has been replaced with | ||
// a call to fakeSendBeacon | ||
window.fakeSendBeacon = function (url, payload) { | ||
// if payload is a string, we assume it's a JSON string | ||
const searchParams = new URL(url).searchParams; | ||
if (typeof payload === 'string') { | ||
window.called.push({...JSON.parse(payload), searchParams}); | ||
} else { | ||
// it's a blob | ||
payload.text().then((text) => { | ||
window.called.push({...JSON.parse(text), searchParams}); | ||
}); | ||
} | ||
}; | ||
</script> | ||
<script defer type="text/javascript" data-program="pXXXXXX" data-environment="eYYYYYY" src="/.rum/@adobe/helix-rum-js@^2/dist/rum-standalone.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div class="block" data-block-status="loaded"> | ||
The first block | ||
<img src="/test/fixtures/fire.jpg" height="200" width="200"> | ||
</div> | ||
<script type="module"> | ||
import { runTests } from '@web/test-runner-mocha'; | ||
import { sendMouse, setViewport } from '@web/test-runner-commands'; | ||
import { assert } from '@esm-bundle/chai'; | ||
|
||
runTests(async () => { | ||
describe('Test Rum Params set as data attributes', () => { | ||
it('All cheeckpoints include routing parameters', async () => { | ||
|
||
await setViewport({ width: 800, height: 600 }); | ||
|
||
await sendMouse({ type: 'click', position: [100, 100] }); | ||
|
||
await new Promise((resolve) => { | ||
setTimeout(resolve, 0); | ||
}); | ||
|
||
await new Promise((resolve) => { | ||
setTimeout(resolve, 100); | ||
}); | ||
|
||
await sendMouse({ type: 'click', position: [10, 10] }); | ||
assert(window.called.every((call) => (call.searchParams?.get('program') === 'pXXXXXX' && call.searchParams?.get('environment') === 'eYYYYYY')), 'rum params missing in beacon url'); | ||
}); | ||
}); | ||
}); | ||
</script> | ||
</body> |