-
Notifications
You must be signed in to change notification settings - Fork 172
ci: adds Playwright tests #146
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
6 commits
Select commit
Hold shift + click to select a range
c961961
fix: keep the scheme in `origin` so local builds use http
bmuenzenmeyer 72d6846
fix: hydrate the theme toggle
bmuenzenmeyer b76c629
test: add Playwright smoke tests against Vercel previews
bmuenzenmeyer 768830f
fixes playwright error
bmuenzenmeyer d344845
fix: hydrate the sidebar so mobile navigation works
bmuenzenmeyer 8811993
Fix repository settings link
MattIPv4 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # Security Notes | ||
| # Only selected Actions are allowed within this repository. Please refer to (https://github.com/nodejs/learn/settings/actions) | ||
| # for the full list of available actions. If you want to add a new one, please reach out a maintainer with Admin permissions. | ||
| # REVIEWERS, please always double-check security practices before merging a PR that contains workflow changes!! | ||
| # AUTHORS, please only use actions with explicit SHA references, and avoid using `@master` or `@main` references or `@version` tags. | ||
|
|
||
| name: Playwright Tests | ||
|
|
||
| # Runs end-to-end tests against the Vercel preview of each pull request, so the | ||
| # site is exercised exactly as Vercel builds it (VERCEL_ENV=preview), not just | ||
| # as it builds locally. Ported from nodejs/nodejs.org's playwright.yml. | ||
| # | ||
| # Unlike nodejs.org, Dependabot PRs are NOT skipped here: dependency bumps | ||
| # (e.g. doc-kit, #138) are one of the likeliest ways for Learn to break. | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
| actions: read | ||
|
|
||
| jobs: | ||
| playwright: | ||
| name: Playwright Tests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Capture Vercel Preview | ||
| id: deployment | ||
| uses: patrickedqvist/wait-for-vercel-preview@d7982701e6fcd3ae073bff929e408e004404d38d # v1.3.3 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| max_timeout: 300 # timeout after 5 minutes | ||
| check_interval: 10 # check every 10 seconds | ||
|
|
||
| - name: Get Playwright version | ||
| id: playwright-version | ||
| run: echo "version=$(node_modules/.bin/playwright --version | awk '{print $2}')" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Cache Playwright browsers | ||
| id: playwright-cache | ||
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | ||
| with: | ||
| path: ~/.cache/ms-playwright | ||
| key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} | ||
|
|
||
| - name: Install Playwright Browsers | ||
| run: node_modules/.bin/playwright install --with-deps chromium | ||
|
|
||
| - name: Run Playwright tests | ||
| run: node --run test:e2e | ||
| env: | ||
| PLAYWRIGHT_BASE_URL: ${{ steps.deployment.outputs.url }} | ||
|
|
||
| - name: Upload Playwright test results | ||
| if: always() | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: playwright-report | ||
| path: playwright-report/ | ||
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,2 +1,8 @@ | ||
| node_modules | ||
| out | ||
|
|
||
| # Playwright | ||
| /test-results/ | ||
| /playwright-report/ | ||
| /blob-report/ | ||
| /playwright/.cache/ |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,32 @@ | ||
| import ThemeToggle from '@node-core/ui-components/Common/ThemeToggle'; | ||
| import NavBar from '@node-core/ui-components/Containers/NavBar'; | ||
| import styles from '@node-core/ui-components/Containers/NavBar/index.module.css'; | ||
| import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub'; | ||
|
|
||
| import SearchBox from '@doc-kit/generator-react/html/ui/components/SearchBox/index.jsx'; | ||
| import { useTheme } from '@doc-kit/generator-react/html/ui/hooks/useTheme.mjs'; | ||
| // doc-kit's ThemeToggle is registered as an island, so it hydrates on the | ||
| // client. Rendering `@node-core/ui-components`' toggle directly here leaves a | ||
| // static button that never opens. | ||
| import ThemeToggle from '@doc-kit/generator-react/html/ui/components/ThemeToggle.jsx'; | ||
| import { navigation } from '../../site.json' with { type: 'json' }; | ||
| import Logo from '#theme/Logo'; | ||
|
|
||
| /** | ||
| * NavBar component that displays the headings, search, etc. | ||
| */ | ||
| export default ({ metadata }) => { | ||
| const [themePreference, setThemePreference] = useTheme(); | ||
|
|
||
| return ( | ||
| <NavBar | ||
| Logo={Logo} | ||
| pathname="/learn" | ||
| sidebarItemTogglerAriaLabel="Toggle navigation menu" | ||
| navItems={navigation} | ||
| export default ({ metadata }) => ( | ||
| <NavBar | ||
| Logo={Logo} | ||
| pathname="/learn" | ||
| sidebarItemTogglerAriaLabel="Toggle navigation menu" | ||
| navItems={navigation} | ||
| > | ||
| <SearchBox pathname={metadata.path} /> | ||
| <ThemeToggle /> | ||
| <a | ||
| href={`https://github.com/nodejs/learn`} | ||
| className={styles.ghIconWrapper} | ||
| > | ||
| <SearchBox pathname={metadata.path} /> | ||
| <ThemeToggle | ||
| onChange={setThemePreference} | ||
| currentTheme={themePreference} | ||
| /> | ||
| <a | ||
| href={`https://github.com/nodejs/learn`} | ||
| className={styles.ghIconWrapper} | ||
| > | ||
| <GitHubIcon /> | ||
| </a> | ||
| </NavBar> | ||
| ); | ||
| }; | ||
| <GitHubIcon /> | ||
| </a> | ||
| </NavBar> | ||
| ); |
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
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.