Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions packages/kit/test/apps/basics/test/cross-platform/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,24 @@ test.describe('Navigation lifecycle functions', () => {
});

test('beforeNavigate is triggered after clicking a download link', async ({ page, baseURL }) => {
await page.goto('/navigation-lifecycle/before-navigate/prevent-navigation');
const pathname = '/navigation-lifecycle/before-navigate/prevent-navigation';

await page.click('a[download]');
expect(await page.innerHTML('pre')).toBe('0 false undefined');
await page.goto(pathname);

const download = page.waitForEvent('download', { timeout: 3000 });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to override the default timeout here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember if I added that because it was too short or too long. Let me try removing it.

await page.locator('a[download]').click();
await (await download).cancel();

const current_url = baseURL + pathname;

expect(page.url()).toBe(current_url);
expect(await page.locator('pre').innerText()).toBe('0 false undefined');
Comment thread
teemingc marked this conversation as resolved.
Outdated

await page.click('a[href="/navigation-lifecycle/before-navigate/a"]');
await page.waitForLoadState('networkidle');
Comment thread
teemingc marked this conversation as resolved.
Outdated

expect(page.url()).toBe(baseURL + '/navigation-lifecycle/before-navigate/prevent-navigation');
expect(await page.innerHTML('pre')).toBe('1 false link');
expect(page.url()).toBe(current_url);
expect(await page.locator('pre').innerText()).toBe('1 false link');
Comment thread
teemingc marked this conversation as resolved.
Outdated
});

test('afterNavigate calls callback', async ({ page, clicknav }) => {
Expand Down