-
-
Notifications
You must be signed in to change notification settings - Fork 17
Fix test suite compatibility with Navigation API router #135
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
base: refactor/navigation-api
Are you sure you want to change the base?
Changes from 4 commits
15f16cf
c77a900
4c1fb66
837867e
89941d4
2f0fd87
d5179ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,6 @@ describe('Router', () => { | |
| history.replaceState(null, null, '/'); | ||
| }); | ||
|
|
||
|
|
||
| it('should throw a clear error if the LocationProvider is missing', () => { | ||
| const Home = () => <h1>Home</h1>; | ||
|
|
||
|
|
@@ -571,10 +570,10 @@ describe('Router', () => { | |
|
|
||
| let triedToNavigate = false; | ||
| const handler = (e) => { | ||
| e.intercept(); | ||
sbesh91 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (e['preact-iso-ignored']) { | ||
| triedToNavigate = true; | ||
| } | ||
| if (e.canIntercept) e.intercept(); | ||
| } | ||
|
|
||
| const App = () => { | ||
|
|
@@ -611,15 +610,11 @@ describe('Router', () => { | |
| }); | ||
| } | ||
|
|
||
| // TODO: These tests are rather flakey, for some reason the additional handler | ||
| // occasionally isn't running prior browser actually navigates away. | ||
| for (const target of shouldNavigate) { | ||
| it(`should allow default browser navigation for links with ${getName(target)}`, async () => { | ||
| // Currently cross-window navigations, (e.g., `target="_blank"`), do not trigger a | ||
| // `navigate` event, which makes this difficult to observe. Per the spec, however, this | ||
| // might be a bug in Chrome's implementation: | ||
| // https://github.com/WICG/navigation-api?tab=readme-ov-file#restrictions-on-firing-canceling-and-responding | ||
| if (target === '_blank' || target === '_BLANK' || target === 'custom') return; | ||
| // WTR runs tests in an iframe, so _top/_parent target the WTR runner frame | ||
| // (canIntercept=false). _blank/custom don't fire navigate events at all. | ||
| if (target === '_top' || target === '_parent' || target === '_blank' || target === '_BLANK' || target === 'custom') return; | ||
|
||
|
|
||
| scratch.querySelector(`#${createId(target)}`).click(); | ||
| await sleep(1); | ||
|
|
@@ -645,10 +640,10 @@ describe('Router', () => { | |
|
|
||
| let triedToNavigate = false; | ||
| const handler = (e) => { | ||
| e.intercept(); | ||
| if (e['preact-iso-ignored']) { | ||
| triedToNavigate = true; | ||
| } | ||
| if (e.canIntercept) e.intercept(); | ||
| } | ||
|
|
||
| it('should support the `scope` prop (string)', async () => { | ||
|
|
@@ -968,12 +963,12 @@ describe('Router', () => { | |
|
|
||
| expect(loc).to.deep.include({ url: '/foo', path: '/foo', searchParams: {} }); | ||
|
|
||
| navigation.back(); | ||
| await navigation.back().finished; | ||
sbesh91 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| await sleep(10); | ||
|
|
||
| expect(loc).to.deep.include({ url: '/', path: '/', searchParams: {} }); | ||
|
|
||
| navigation.forward(); | ||
| await navigation.forward().finished; | ||
| await sleep(10); | ||
|
|
||
| expect(loc).to.deep.include({ url: '/foo', path: '/foo', searchParams: {} }); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.