-
Notifications
You must be signed in to change notification settings - Fork 121
chore: Run automated tests on example pages #1285
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
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3182fa9
Added playwright config for examples tests
spuppo-mux cc10365
Added CI step
spuppo-mux 51c7510
Fix gh workflow calls
spuppo-mux 9220f01
Merge branch 'main' into chore/test-example-pages
spuppo-mux bef4f77
chore: Test custom elements are defined on examples (#1)
spuppo-mux 955723d
chore: Test Example Pages - Interaction Tests (#6)
spuppo-mux 1fd28ca
chore: Test Example Pages - Specific features and Playback Tests (#3)
spuppo-mux 63d0903
Switch nonDefinedThemes counter to a cdn health check
spuppo-mux 4df4114
Remove accidental only
spuppo-mux 347f984
chore: Test Example Pages - Improve CI (#4)
spuppo-mux 9108a6c
chore: Test Example Pages - Run react examples (#5)
spuppo-mux 19cf102
Fixed KNOWN_ERRORS path
spuppo-mux 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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,42 @@ | ||
| import { defineConfig, devices } from 'playwright/test'; | ||
| import { VANILLA_PORT, VITE_PORT, NEXT_PORT } from './ports.js'; | ||
|
|
||
| export default defineConfig({ | ||
| testDir: './examples', | ||
| retries: 2, | ||
| testIgnore: process.env.FEATURE_TESTS ? [] : ['**/features/**'], | ||
|
|
||
| webServer: [ | ||
| { | ||
| command: `npm run serve:test -- -p ${VANILLA_PORT}`, | ||
| url: `http://localhost:${VANILLA_PORT}`, | ||
| reuseExistingServer: !process.env.CI, | ||
| }, | ||
| { | ||
| command: `cd ../examples/vite-react-with-typescript && npx vite --port ${VITE_PORT}`, | ||
| url: `http://localhost:${VITE_PORT}`, | ||
| reuseExistingServer: !process.env.CI, | ||
| timeout: 60_000, | ||
| }, | ||
| { | ||
| command: `cd ../examples/nextjs-with-typescript && npx next dev -p ${NEXT_PORT}`, | ||
| url: `http://localhost:${NEXT_PORT}`, | ||
| reuseExistingServer: !process.env.CI, | ||
| timeout: 120_000, | ||
| }, | ||
| ], | ||
|
|
||
| use: { | ||
| baseURL: `http://localhost:${VANILLA_PORT}`, | ||
| screenshot: "only-on-failure", | ||
| video: "off", | ||
| trace: "retain-on-failure", | ||
| }, | ||
|
|
||
| projects: [ | ||
| { | ||
| name: 'chromium', | ||
| use: { ...devices['Desktop Chrome'] }, | ||
| }, | ||
| ], | ||
| }); |
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,88 @@ | ||
| /** | ||
| * Smoke tests — scope: React example pages | ||
| * | ||
| * Checks that every page: | ||
| * 1. Loads without uncaught JS errors | ||
| * 2. Renders non-empty content | ||
| * 3. (react-wrappers only) media-* custom elements are registered | ||
| */ | ||
| import { test, expect } from 'playwright/test'; | ||
| import { VITE_PORT, NEXT_PORT } from '../../ports.js'; | ||
|
|
||
| test.describe.configure({ mode: 'parallel' }); | ||
|
|
||
| // MUI + Emotion always produces a hydration mismatch in Next.js dev mode due to | ||
| // server-rendered <style> tags differing from the client. Known limitation of the example. | ||
| const KNOWN_ERRORS: Map<string, { patterns: string[] }> = new Map( | ||
| [['nextjs/material-ui-player-chrome', | ||
| { | ||
| patterns: ["Hydration failed because the server rendered HTML didn't match the client."] | ||
| }]] | ||
| ); | ||
|
|
||
| type Route = { url: string; label: string; checkMediaElements?: true }; | ||
|
|
||
| const ROUTES: Route[] = [ | ||
| { | ||
| url: `http://localhost:${VITE_PORT}/`, | ||
| label: 'vite-react', | ||
| }, | ||
| { | ||
| url: `http://localhost:${NEXT_PORT}/`, | ||
| label: 'nextjs/index', | ||
| }, | ||
| { | ||
| url: `http://localhost:${NEXT_PORT}/react-wrappers`, | ||
| label: 'nextjs/react-wrappers', | ||
| checkMediaElements: true, | ||
| }, | ||
| { | ||
| url: `http://localhost:${NEXT_PORT}/media-store-hooks`, | ||
| label: 'nextjs/media-store-hooks', | ||
| }, | ||
| { | ||
| url: `http://localhost:${NEXT_PORT}/material-ui-player-chrome`, | ||
| label: 'nextjs/material-ui-player-chrome', | ||
| }, | ||
| ]; | ||
|
|
||
| for (const route of ROUTES) { | ||
| test(`${route.label} - renders without errors`, async ({ page }) => { | ||
| const pageErrors: string[] = []; | ||
| page.on('pageerror', (error) => pageErrors.push(error.message)); | ||
|
|
||
| await page.goto(route.url, { waitUntil: 'load' }); | ||
|
|
||
| const hasContent = await page.evaluate( | ||
| () => document.body.innerHTML.trim().length > 0 | ||
| ); | ||
| expect(hasContent, 'Page body should have content').toBe(true); | ||
|
|
||
| if (route.checkMediaElements) { | ||
| const undefinedElements = await page.evaluate(() => { | ||
| const tagNames = new Set( | ||
| [...document.querySelectorAll('*')] | ||
| .map((el) => el.tagName.toLowerCase()) | ||
| .filter((tag) => tag.startsWith('media-')) | ||
| ); | ||
| return [...tagNames].filter((tag) => !customElements.get(tag)); | ||
| }); | ||
| expect( | ||
| undefinedElements, | ||
| `Unregistered custom elements: ${undefinedElements.join(', ')}` | ||
| ).toHaveLength(0); | ||
| } | ||
|
|
||
| if (KNOWN_ERRORS.has(route.label)) { | ||
| const known = KNOWN_ERRORS.get(route.label)!.patterns; | ||
| pageErrors.forEach(error => { | ||
| expect( | ||
| known.some(k => error.includes(k)), | ||
| `Unexpected error (not in KNOWN_ERRORS): ${error}` | ||
| ).toBe(true); | ||
| }); | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| } else { | ||
| expect(pageErrors, `Page errors: ${pageErrors.join('; ')}`).toHaveLength(0); | ||
| } | ||
| }); | ||
| } | ||
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,6 @@ | ||
| import { test, expect } from 'playwright/test'; | ||
|
|
||
| test('examples index page loads', async ({ page }) => { | ||
| await page.goto('/examples/vanilla/'); | ||
| await expect(page).toHaveTitle('Media Chrome Examples'); | ||
| }); |
Oops, something went wrong.
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.