-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
β»οΈ Migration to app router, Upgrade to Next 15/React 19 (#450)
* β Added Playwright behavior tests to image api endpoints Screenshot all 4 GET image api endpoints with complex config per viewport type (Chrome and Mobile Chrome) in preparation for migration. Also updated TailwindCSS config from .js to .ts. * π¨ Strongly typed preview card and card theme wrapper, separeted exports. * β»οΈ Full (verified) api migration from page to app router. * π¨ (Header) Moved GitHub corner styling to global.css, removed styled-jsx dep. * β»οΈ Full front+backend migration from page router to app router. Followed nextjs official docs and best practices, backed by Playwright behavior regression test passing. Upated unit tests to reflect the new framework. * π Added changeset reflecting page to app router migration. * β¬οΈ Upgraded successfully to Next15/React19 with minor fixes. Upgraded using the official NextJS codemod. No file modded by the codemod. Updated types and deps. Fully compatible with exising behavior tests, all passed. * β Added component update timeout to prevent flaky tests. * π¨ Polished code based on comments and added server-only dep Regressively tested all the requested changes, and determined safe to keep them. Added server-only prod dep to explicitly limit code involving GITHUB_TOKEN to only run server-side. * β¬οΈ Upgraded depedencies to latest patch/minor verisons w/out breakage. * π Updated favicon, web app icons, and manifest per nextjs standard. * β Updated user story playwright test and snapshots Replaced next <Head> with html <head> in preview to resolve font not updating issue. Updated Playwright user story regressing test and snapshot to cover this weak point. Updated select wrapper component to be more accessible and compatible with Playwright. Not sure why config panel width changed after editing component, thus had to update one UI snapshot as well. Further polished pnpm scripts to better match actual flag name, i.e. pnpm test:e2e:update-snapshots to match playwright test --update-snapshots (with an 's') * π Fix preview font, update linting and snapshots --------- Co-authored-by: Wei He <[email protected]> Co-authored-by: Wei He <[email protected]>
- Loading branch information
1 parent
811ccd2
commit d73c1be
Showing
80 changed files
with
1,230 additions
and
778 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"socialify": minor | ||
--- | ||
|
||
Full migration from page router to app router. | ||
|
||
Upgraded to nextjs15/react19 via official codemod and applied type fixes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { type Page, expect, test } from '@playwright/test' | ||
|
||
const customTimeout = { timeout: 30000 } | ||
|
||
const defaultImageURL: string = | ||
'/wei/socialify/image?description=1&font=Raleway&language=1&name=1&owner=1&pattern=Diagonal%20Stripes&theme=Dark' | ||
const svgImageURL: string = | ||
'/wei/socialify/svg?description=1&font=Raleway&language=1&name=1&owner=1&pattern=Diagonal%20Stripes&theme=Dark' | ||
const pngImageURL: string = | ||
'/wei/socialify/png?description=1&font=Raleway&language=1&name=1&owner=1&pattern=Diagonal%20Stripes&theme=Dark' | ||
// Backward compatibility route. | ||
const jpgImageURL: string = | ||
'/wei/socialify/jpg?description=1&font=Raleway&language=1&name=1&owner=1&pattern=Diagonal%20Stripes&theme=Dark' | ||
|
||
test.describe('Socialify image api', () => { | ||
test('respond consistently for default endpoint', async ({ | ||
page, | ||
}: { page: Page }): Promise<void> => { | ||
await page.goto(defaultImageURL, customTimeout) | ||
|
||
// Wait for the page to load/hydrate completely. | ||
await page.waitForLoadState('networkidle', customTimeout) | ||
|
||
const image = await page.screenshot() | ||
expect(image).toMatchSnapshot() | ||
}) | ||
|
||
test('respond consistently for svg endpoint', async ({ | ||
page, | ||
}: { page: Page }): Promise<void> => { | ||
await page.goto(svgImageURL, customTimeout) | ||
|
||
// Wait for the page to load/hydrate completely. | ||
await page.waitForLoadState('networkidle', customTimeout) | ||
|
||
const image = await page.screenshot() | ||
expect(image).toMatchSnapshot() | ||
}) | ||
|
||
test('respond consistently for png endpoint', async ({ | ||
page, | ||
}: { page: Page }): Promise<void> => { | ||
await page.goto(pngImageURL, customTimeout) | ||
|
||
// Wait for the page to load/hydrate completely. | ||
await page.waitForLoadState('networkidle', customTimeout) | ||
|
||
const image = await page.screenshot() | ||
expect(image).toMatchSnapshot() | ||
}) | ||
|
||
test('respond consistently for backwards-compatible jpg endpoint', async ({ | ||
page, | ||
}: { page: Page }): Promise<void> => { | ||
await page.goto(jpgImageURL, customTimeout) | ||
|
||
// Wait for the page to load/hydrate completely. | ||
await page.waitForLoadState('networkidle', customTimeout) | ||
|
||
const image = await page.screenshot() | ||
expect(image).toMatchSnapshot() | ||
}) | ||
}) |
Binary file added
BIN
+120 KB
...nd-consistently-for-backwards-compatible-jpg-endpoint-1-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+48.4 KB
...respond-consistently-for-backwards-compatible-jpg-endpoint-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+71.2 KB
...y-image-api-respond-consistently-for-default-endpoint-1-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+59.3 KB
...ialify-image-api-respond-consistently-for-default-endpoint-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+120 KB
...alify-image-api-respond-consistently-for-png-endpoint-1-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+48.4 KB
.../Socialify-image-api-respond-consistently-for-png-endpoint-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+71.2 KB
...alify-image-api-respond-consistently-for-svg-endpoint-1-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+59.3 KB
.../Socialify-image-api-respond-consistently-for-svg-endpoint-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.96 KB
(98%)
...ts/Socialify-UI-is-consistent-for-preview-config-page-1-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+116 Bytes
(100%)
...apshots/Socialify-UI-is-consistent-for-preview-config-page-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.53 KB
(98%)
...ts/Socialify-UI-is-consistent-for-preview-config-page-2-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-63 Bytes
(100%)
...apshots/Socialify-UI-is-consistent-for-preview-config-page-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+198 Bytes
(100%)
...ows-error-when-svg-data-uri-input-length-exceeds-the-limit-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+414 Bytes
(100%)
...ub-r-50b6f-click-URL-and-get-the-social-preview-image-1-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-443 Bytes
(99%)
...-GitHub-r-50b6f-click-URL-and-get-the-social-preview-image-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use client' | ||
|
||
import { JSX } from 'react' | ||
|
||
import MainRenderer from '@/src/components/mainRenderer' | ||
|
||
export default function PreviewConfigPage(): JSX.Element { | ||
return <MainRenderer /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { isBot } from 'next/dist/server/web/spec-extension/user-agent' | ||
import type { NextRequest, NextResponse } from 'next/server' | ||
|
||
import { GET as GETPng } from '@/app/api/png/route' | ||
import { GET as GETSvg } from '@/app/api/svg/route' | ||
|
||
export const runtime = 'edge' | ||
|
||
export async function GET(req: NextRequest): Promise<NextResponse> { | ||
if (isBot(req.headers.get('user-agent') ?? '')) { | ||
return GETPng(req) | ||
} else { | ||
return GETSvg(req) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes.
Oops, something went wrong.