🐛 Rewrite relative urls in the bookend#26490
Conversation
|
Hey @gmajoulet, these files were changed:
Hey @newmuis, these files were changed:
|
| }; | ||
|
|
||
| storyUtils.getDocLocation.restore(); | ||
| const fakeDoc = { |
There was a problem hiding this comment.
Can you try using one of these methods to mock the location object? I've found three ways to do it that'd yield easier code and much better test coverage. By order of personal preference:
There was a problem hiding this comment.
Whenever we get the location in the bookend, we do it by calling document.location. Mocking the document object properties in the tests is not as straightforward since it is an iframe inside a shadow dom created by Sinon.
We could use the window object instead of the document in the bookend code, do you prefer it this way?
| 'amp-story-bookend', | ||
| { | ||
| win: { | ||
| location: |
There was a problem hiding this comment.
Can we do something like this instead? It's almost impossible to review this change otherwise :(
const location = 'foo';
describes.realWin('amp-story-bookend', {location, amp: true}, env => {
There was a problem hiding this comment.
Sure, just note that we have to use fakeWin in order to use win.location.resetHref
|
PTAL @gmajoulet |
gmajoulet
left a comment
There was a problem hiding this comment.
What caused this massive diff? :(
|
I grouped semantically similar tests into separate
|
…frame-pymjs-support * 'master' of github.com:ampproject/amphtml: (436 commits) 🐛Add computed styles to fake win (ampproject#26514) 📦 Update dependency eslint-config-prettier to v6.10.0 (ampproject#26518) 🐛 Rewrite relative urls in the bookend (ampproject#26490) ✨ [amp-list] Introduce "amp-state:" as a usable protocol for the src attribute. (ampproject#26284) Add terminal newline to files.txt (ampproject#26513) 📦 Update dependency chromedriver to v79.0.2 (ampproject#26515) ♻️ Change the opt-in cookie values to reflect upcoming CDN changes (ampproject#26489) ♻️<amp-next-page> v2 minor renaming and fixes (ampproject#26468) fix link (ampproject#26508) amp-list: fix broken test re. missing layout (ampproject#26509) performance: emit timeOrigin w/ polyfill (ampproject#26485) Position n+1 story desktop page before positioning attributes are set. (ampproject#26488) ✨amp-nested-menu: allow svg into (ampproject#26502) Log user warning when missing URL arg for shadow doc (ampproject#26290) 📦 Update dependency puppeteer to v2.1.0 (ampproject#26501) Ensure that fluid slots hidden by media queries do not issue ad requests. (ampproject#26352) 📦 Update dependency mocha to v7.0.1 (ampproject#26495) 📦 Update dependency fetch-mock to v8.3.2 (ampproject#26491) Revert 'Move mutator implementations out to a standalone service' (ampproject#26479) Fix syntax error (ampproject#26481) ...
Closes #26316
Resolves relative URLs specified in the bookend configuration. See linked issue for more details.
document.location / window.locationand I've seen other tests do similar things.