-
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.
Merge pull request #273 from adobe/redirect-checkpoint
feat(navigation): add support for `redirect` checkpoint
- Loading branch information
Showing
4 changed files
with
94 additions
and
7 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,72 @@ | ||
<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; | ||
window.hlx = { | ||
RUM_MASK_URL: 'full' | ||
}; | ||
// 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 | ||
if (typeof payload === 'string') { | ||
window.called.push(JSON.parse(payload)); | ||
} else { | ||
// it's a blob | ||
payload.text().then((text) => { | ||
window.called.push(JSON.parse(text)); | ||
}); | ||
} | ||
}; | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<img src="/test/it/img.test.html"> | ||
<script type="module"> | ||
import { runTests } from '@web/test-runner-mocha'; | ||
import { sendMouse } from '@web/test-runner-commands'; | ||
import { assert } from '@esm-bundle/chai'; | ||
|
||
runTests(async () => { | ||
beforeEach(() => { | ||
const usp = new URLSearchParams(window.location.search); | ||
usp.append('redirect-from', 'https://www.example.com'); | ||
window.history.replaceState({}, '', `${window.location.pathname}?${usp.toString()}`); | ||
const script = document.createElement('script'); | ||
script.type = 'text/javascript'; | ||
script.src = '/.rum/@adobe/helix-rum-js@^2/dist/rum-standalone.js'; | ||
document.head.appendChild(script); | ||
}); | ||
|
||
describe('HTML Integration Tests', () => { | ||
|
||
it('Can load rum enhancer through a (prepared) helix-rum-js, while pretending to be redirected', async () => { | ||
|
||
await sendMouse({ type: 'click', position: [100, 100] }); | ||
|
||
await new Promise((resolve) => { | ||
setTimeout(resolve, 3000); | ||
}); | ||
|
||
await sendMouse({ type: 'click', position: [10, 10] }); | ||
|
||
assert(window.called.some((call) => call.checkpoint === 'top'), 'top checkpoint missing'); | ||
assert(window.called.some((call) => call.checkpoint === 'redirect'), 'redirect checkpoint missing'); | ||
assert(window.called.some((call) => call.checkpoint === 'enter'), 'enter checkpoint missing'); | ||
assert(window.called.some((call) => call.checkpoint === 'viewmedia'), 'viewmedia checkpoint missing'); | ||
assert(window.called.some((call) => call.checkpoint === 'cwv'), 'cwv checkpoint missing'); | ||
assert(window.called.some((call) => call.checkpoint === 'click'), 'click checkpoint missing'); | ||
}); | ||
|
||
}); | ||
}); | ||
</script> | ||
</body> |
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