Skip to content
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

NextJS: Support next/navigation in Next.js v13 #20065

Merged
merged 22 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
46e702d
Document next/link component and create stories
valentinpalkovic Dec 1, 2022
d4d0e81
Document next/link component and create stories
valentinpalkovic Dec 1, 2022
240776b
Support next/navigation in Next.js v13
valentinpalkovic Dec 2, 2022
417dd1c
Update code/frameworks/nextjs/README.md
valentinpalkovic Dec 2, 2022
1ed89f7
Update code/frameworks/nextjs/README.md
valentinpalkovic Dec 2, 2022
51c4e83
Update code/frameworks/nextjs/README.md
valentinpalkovic Dec 2, 2022
15bb8f2
Document next/dynamic
valentinpalkovic Dec 2, 2022
66f9945
Update code/frameworks/nextjs/README.md
valentinpalkovic Dec 3, 2022
79c00af
Add E2E tests
valentinpalkovic Dec 6, 2022
95d9057
Merge branch 'valentin/document-next-link-component' into valentin/su…
valentinpalkovic Dec 6, 2022
6ad0975
Update code/e2e-tests/framework-nextjs.spec.ts
valentinpalkovic Dec 6, 2022
db814f2
Adjust newNextLinkBehavior to consider latest Next.js v13.0.6 release
valentinpalkovic Dec 6, 2022
6613e77
Adjust newNextLinkBehavior to consider latest Next.js v13.0.6 release
valentinpalkovic Dec 6, 2022
ab9e803
Update code/frameworks/nextjs/README.md
valentinpalkovic Dec 6, 2022
912ac0b
Update code/frameworks/nextjs/src/config/webpack.ts
valentinpalkovic Dec 6, 2022
1dbaac5
Rework nextjs parameters
valentinpalkovic Dec 6, 2022
a376841
Edit Readme
valentinpalkovic Dec 6, 2022
9a54fc0
Update code/frameworks/nextjs/README.md
valentinpalkovic Dec 6, 2022
c8bb3af
Merge remote-tracking branch 'origin/next' into valentin/support-next…
valentinpalkovic Dec 6, 2022
56e0fd4
Edit Readme
valentinpalkovic Dec 7, 2022
ab6a3ff
Merge remote-tracking branch 'origin/next' into valentin/support-next…
valentinpalkovic Dec 7, 2022
e456d04
Edit Readme
valentinpalkovic Dec 7, 2022
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
90 changes: 90 additions & 0 deletions code/e2e-tests/framework-nextjs.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/* eslint-disable jest/no-disabled-tests */
valentinpalkovic marked this conversation as resolved.
Show resolved Hide resolved
import type { Locator } from '@playwright/test';
import { test, expect } from '@playwright/test';
import process from 'process';
import { SbPage } from './util';

const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:6006';
const templateName = process.env.STORYBOOK_TEMPLATE_NAME;

test.describe('Next.js', () => {
test.beforeEach(async ({ page }) => {
await page.goto(storybookUrl);
await new SbPage(page).waitUntilLoaded();
});

test.describe('next/navigation', () => {
test.skip(
Copy link
Member

Choose a reason for hiding this comment

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

I wonder what this will do to the CI status report? cc @kasperpeulen

Copy link
Member

Choose a reason for hiding this comment

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

I guess everything will fail. But @kasperpeulen is working on adding metadata to tests, so I hope there's a way to configure this, either by adding the skip descrition or something, which allows us to get the results right

// eslint-disable-next-line jest/valid-title
!templateName.includes('nextjs/default-js'),
'Only run this test for the Frameworks that support next/navigation'
);

let root: Locator;
let sbPage: SbPage;

function testRoutingBehaviour(buttonText: string, action: string) {
test(`should trigger ${action} action`, async ({ page }) => {
const button = root.locator('button', { hasText: buttonText });
await button.click();

await sbPage.viewAddonPanel('Actions');
const logItem = await page.locator('#storybook-panel-root #panel-tab-content', {
hasText: `nextNavigation.${action}`,
});
await expect(logItem).toBeVisible();
});
}

test.beforeEach(async ({ page }) => {
sbPage = new SbPage(page);

await sbPage.navigateToStory('frameworks/nextjs_default-js/Navigation', 'default');
root = sbPage.previewRoot();
});

testRoutingBehaviour('Go back', 'back');
testRoutingBehaviour('Go forward', 'forward');
testRoutingBehaviour('Prefetch', 'prefetch');
testRoutingBehaviour('Push HTML', 'push');
testRoutingBehaviour('Refresh', 'refresh');
testRoutingBehaviour('Replace', 'replace');
});

test.describe('next/router', () => {
test.skip(
// eslint-disable-next-line jest/valid-title
!templateName.includes('nextjs'),
'Only run this test for the Frameworks that support next/router'
);

let root: Locator;
let sbPage: SbPage;

function testRoutingBehaviour(buttonText: string, action: string) {
test(`should trigger ${action} action`, async ({ page }) => {
const button = root.locator('button', { hasText: buttonText });
await button.click();

await sbPage.viewAddonPanel('Actions');
const logItem = await page.locator('#storybook-panel-root #panel-tab-content', {
hasText: `nextRouter.${action}`,
});
await expect(logItem).toBeVisible();
});
}

test.beforeEach(async ({ page }) => {
sbPage = new SbPage(page);

await sbPage.navigateToStory('frameworks/nextjs_default-js/Router', 'default');
root = sbPage.previewRoot();
});

testRoutingBehaviour('Go back', 'back');
testRoutingBehaviour('Go forward', 'forward');
testRoutingBehaviour('Prefetch', 'prefetch');
testRoutingBehaviour('Push HTML', 'push');
testRoutingBehaviour('Replace', 'replace');
});
});
Loading