Repository navigation
Upgrade Next.js and add page smoke tests #21
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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,76 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { readdirSync } from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| import { allAgentSlugs } from '../lib/agents'; | ||
| import { getAllDocSlugs, getAllLegacyDocSlugs } from '../lib/docs-nav'; | ||
|
|
||
| const webDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); | ||
| const appDir = path.join(webDir, 'app'); | ||
| const contentDir = path.join(webDir, 'content'); | ||
|
|
||
| function filesIn(dir: string, filename: string): string[] { | ||
| return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => { | ||
| const absolutePath = path.join(dir, entry.name); | ||
| if (entry.isDirectory()) return filesIn(absolutePath, filename); | ||
| return entry.name === filename ? [absolutePath] : []; | ||
| }); | ||
| } | ||
|
|
||
| function mdxSlugs(dir: string): string[] { | ||
| return readdirSync(dir, { withFileTypes: true }) | ||
| .filter((entry) => entry.isFile() && entry.name.endsWith('.mdx')) | ||
| .map((entry) => entry.name.slice(0, -4)); | ||
| } | ||
|
|
||
| function staticPageRoutes(): string[] { | ||
| return filesIn(appDir, 'page.tsx') | ||
| .map((file) => path.relative(appDir, path.dirname(file))) | ||
| .filter((route) => !route.includes('[')) | ||
| .map((route) => (route ? `/${route}` : '/')); | ||
| } | ||
|
|
||
| function pageRoutes(): string[] { | ||
| const currentDocs = getAllDocSlugs(); | ||
| const legacyDocs = getAllLegacyDocSlugs(); | ||
| const productDocs = ['agents', 'file', 'loop'].flatMap((product) => | ||
| mdxSlugs(path.join(contentDir, `docs/${product}`)).map((slug) => `/docs/${product}/${slug}`), | ||
| ); | ||
|
|
||
| const dynamicRoutes = [ | ||
| ...mdxSlugs(path.join(contentDir, 'blog')).map((slug) => `/blog/${slug}`), | ||
| ...allAgentSlugs().map((slug) => `/agents/${slug}`), | ||
| ...[...new Set([...currentDocs, ...legacyDocs])].map((slug) => `/docs/${slug}`), | ||
| ...legacyDocs.map((slug) => `/docs/7.1.1/${slug}`), | ||
| ...currentDocs.map((slug) => `/docs/8.0.0/${slug}`), | ||
| ...legacyDocs.map((slug) => `/docs/pre-v8/${slug}`), | ||
| ...productDocs, | ||
| '/openclaw/skill/invite/rk_live_smoke_test', | ||
| ]; | ||
|
|
||
| return [...new Set([...staticPageRoutes(), ...dynamicRoutes])].sort(); | ||
| } | ||
|
|
||
| test.describe.configure({ mode: 'parallel' }); | ||
|
|
||
| for (const route of pageRoutes()) { | ||
| test(`${route} renders visible page content`, async ({ page }) => { | ||
| const pageErrors: Error[] = []; | ||
| page.on('pageerror', (error) => pageErrors.push(error)); | ||
|
|
||
| const response = await page.goto(route, { waitUntil: 'domcontentloaded' }); | ||
| await page.waitForLoadState('load'); | ||
| // Let initial hydration and mount effects surface errors before asserting. | ||
| await page.waitForTimeout(100); | ||
|
|
||
| expect(response, 'navigation should return an HTTP response').not.toBeNull(); | ||
| expect(response!.status(), 'page should not return an HTTP error').toBeLessThan(400); | ||
| const body = page.locator('body'); | ||
| await expect(body).toBeVisible(); | ||
| expect((await body.innerText()).trim().length, 'page should render meaningful visible text').toBeGreaterThan(100); | ||
| await expect(page).toHaveTitle(/\S+/); | ||
| await expect(page.locator('body')).not.toContainText('Application error'); | ||
| expect(pageErrors, 'page should hydrate without uncaught browser errors').toEqual([]); | ||
| }); | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| /// <reference types="next" /> | ||
| /// <reference types="next/image-types/global" /> | ||
| import "./.next/dev/types/routes.d.ts"; | ||
| import "./.next/types/routes.d.ts"; | ||
|
|
||
| // NOTE: This file should not be edited | ||
| // see https://nextjs.org/docs/app/api-reference/config/typescript for more information. |
This file contains hidden or 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 hidden or 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,26 @@ | ||
| import { defineConfig, devices } from '@playwright/test'; | ||
|
|
||
| export default defineConfig({ | ||
| testDir: './e2e', | ||
| fullyParallel: true, | ||
| forbidOnly: Boolean(process.env.CI), | ||
| retries: process.env.CI ? 2 : 0, | ||
| workers: process.env.CI ? 4 : undefined, | ||
| reporter: process.env.CI ? 'github' : 'line', | ||
| use: { | ||
| baseURL: 'http://localhost:3100', | ||
| trace: 'retain-on-failure', | ||
| }, | ||
| projects: [ | ||
| { | ||
| name: 'chromium', | ||
| use: { ...devices['Desktop Chrome'] }, | ||
| }, | ||
| ], | ||
| webServer: { | ||
| command: 'npm run build && npm run start -- -p 3100', | ||
| url: 'http://localhost:3100', | ||
| reuseExistingServer: !process.env.CI, | ||
| timeout: 180_000, | ||
| }, | ||
|
willwashburn marked this conversation as resolved.
|
||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.