-
Notifications
You must be signed in to change notification settings - Fork 141
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
SDK: better support for SPA routing - STEP 2/2 : filter out html anchor tags changes #466
SDK: better support for SPA routing - STEP 2/2 : filter out html anchor tags changes #466
Conversation
Codecov Report
@@ Coverage Diff @@
## maxime.quentin/betterSupportForSPArouting #466 +/- ##
=============================================================================
+ Coverage 87.35% 87.67% +0.32%
=============================================================================
Files 32 32
Lines 2024 2028 +4
Branches 410 410
=============================================================================
+ Hits 1768 1778 +10
+ Misses 256 250 -6
Continue to review full report at Codecov.
|
…g' into maxime.quentin/betterSupportForSPAroutingFilterOutAnchorNav
…quentin/betterSupportForSPAroutingFilterOutAnchorNav
packages/rum/src/viewCollection.ts
Outdated
// Anchor navigations would modify the location without generating a new view. | ||
// These changes need to be acknowledged so they don't interfer with the next change areDifferentViews call | ||
currentLocation = { ...location } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about enforcing that by a unit test?
|
||
it('should acknowledge the view location hash change after an Anchor navigation', (done) => { | ||
const { lifeCycle } = setupBuilder.build() | ||
const spyObj = mockGetElementById() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about something more expressive than spyObj
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as we just "clear" it, I did not look for a better name. Also the comment helps understanding the usage of spyObj.and.callThrough()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it could have been an opportunity to be more expressive
* SDK: better support for SPA routing - STEP 1/2 : add hash tracking (#463) * add hash tracking * ✅ add hash change tests * introduce renewViewOnChange * add better management and comments of the areViewDifferent hash part * set async tests for hashchanges * reset window.location.hash of previous tests * skip tesst using Promise for IE * replace jasmine promise with callback process * remove anchor check on this PR * ✅ and implem reviews * SDK: better support for SPA routing - STEP 2/2 : filter out html anchor tags changes (#466) * add hash tracking * ✅ add hash change tests * introduce renewViewOnChange * add better management and comments of the areViewDifferent hash part * set async tests for hashchanges * reset window.location.hash of previous tests * skip tesst using Promise for IE * replace jasmine promise with callback process * remove anchor check on this PR * add anchor nav filter * patch tslint error * ✅ and implem reviews * implement reviews regarding func naming and hash cleaning * simplify mockGetElementById * add e2e tests * simply anchor filter out proccess * implement reviews * unit test the hash change acknowledgement after an anchor nav * fix typo * fix typo v2 * fix mock hash Co-authored-by: Bastien Caudan <[email protected]>
Motivation
Given
startViewCollection
When
on window.location.hash changes
Then
check if the views are different.
If the hash fragment has changed and that it is not an Anchor nav, then the views are different.
Changes
noAnchorNavHashChange
check in thetrackHash
function that check if there is an equivalent id on one of the HTML elementsTesting
✅ test added that check if the hashchange is related to an Anchor nav