-
Notifications
You must be signed in to change notification settings - Fork 1
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
👀 Visuell testing med Playwright 🧪 #2146
Merged
Merged
Changes from all commits
Commits
Show all changes
199 commits
Select commit
Hold shift + click to select a range
6f508f8
test playwrigth regression
bdahle abc4cb6
bruk master
bdahle ab788bb
remove updating snapshots comment
bdahle 7fc35b0
add node auth token
bdahle 9180055
add id-token permission
bdahle 5a15cb5
test legg til registry-url
bdahle d966e65
bruk config fra eksempel
bdahle 82112d7
legg til workflow generate-report
bdahle 5a12726
add testDir playwright config
bdahle ca0da47
fjern updtes snapshots i workflow
bdahle c79ce3e
test fjern Playwright Browsers
bdahle 3da7fe9
commit snapshots selv om tester feiler
bdahle d084bc0
Update playwright snapshots
bdahle 62a1db4
revert bakgrunnsfarge
bdahle 2232b3b
Update playwright snapshots
bdahle fe598d5
fjern kommentert kode
bdahle 669ce29
bruk testbranchen som "master" foreløpig
bdahle 7cad32f
bruk screenshots istedenfor snapshots
bdahle 885717e
fjern chromatic modes config
bdahle c58ab4f
avinstaller chromatic
bdahle 4740e03
ta kun screenshot av storybook-diven
bdahle 552a32f
fjern chromatic addon
bdahle 924fb34
sett maksbredde på containeren
bdahle 571f20c
midlertidig fjern stories som krasjer
bdahle 187476a
test paralellkjøring for veldig mye bedre performance
bdahle 405ef50
bruk master i workflow
bdahle 48432d3
endre branch i workflow
bdahle 08700df
Update Playwright screenshots
bdahle 411bd8b
todo, fremprovoser action
bdahle 388fcbf
Update Playwright screenshots
bdahle 40f19b0
Merge pull request #2152 from navikt/playwright-endringsbranch-test3
bdahle ef4baae
bruk master-branch
bdahle 33530ea
bruk 12 workers
bdahle 32551b8
fjern Todo
bdahle fdba3f6
Update Playwright screenshots workflow to use main branch
bdahle 5c86b99
Configure Jest to ignore spec.ts files
bdahle 09b6b95
provoke test run
bdahle 6234943
Update Playwright screenshots
bdahle 5353ef5
bruk 16-cores og fjern kommnetar
bdahle efc40b9
Update Playwright screenshots workflow branch to playwright-regresiio…
bdahle b4b4853
provoke test run
bdahle ab01eda
Enhance Playwright screenshots workflow with PR review creation
bdahle 1784bff
Remove border-radius from Expandable component header
bdahle e5ec452
Add green background color to default button
bdahle 7a5b63f
Update Playwright screenshots
bdahle 69a79bb
Improve error handling in Playwright screenshots workflow
bdahle 18afd3b
Change default button background color from green to yellow
bdahle 260461e
Update Playwright screenshots
bdahle 849be31
Change default button background color from yellow to orange
bdahle f361130
Update Playwright screenshots
bdahle 75fa66c
Enhance Playwright screenshots workflow with detailed PR review
bdahle 08dae42
Change default button background color from orange to purple
bdahle 7dd05ed
Update Playwright screenshots
bdahle c330b37
Improve Playwright screenshots PR review with enhanced details and St…
bdahle 3067647
Update Playwright screenshots
bdahle 5548b47
Change default button background color to grey and add padding
bdahle d9180fa
Update Playwright screenshots
bdahle 733f7ef
Simplify Playwright screenshot PR review message
bdahle a6f9585
Change default button background color from grey to orangered
bdahle 07f5165
Update Playwright screenshots
bdahle 17551de
Enhance Playwright screenshot workflow with check run and improved re…
bdahle b2b6edc
Change default button background color to aquamarine
bdahle 50cbb30
Update Playwright screenshots
bdahle c57d081
Improve Playwright screenshot workflow with enhanced check run and re…
bdahle 633dc18
Change default button background color to beige
bdahle 6a8011e
Update Playwright screenshots
bdahle 35d6766
Revert "Improve Playwright screenshot workflow with enhanced check ru…
bdahle b93e98b
Revert "Enhance Playwright screenshot workflow with check run and imp…
bdahle 296f9c5
Modify Playwright screenshot workflow review message generation
bdahle 0f7dc81
Change default button background color to black
bdahle 04b05f3
Update Playwright screenshots
bdahle 7b4d008
Refactor Playwright screenshot workflow review message generation
bdahle 64e738f
Change default button background color to white
bdahle 9bc8c74
Update Playwright screenshots
bdahle 2ff99c8
Refactor Playwright screenshot workflow to extract filename in review…
bdahle 8e747b6
Add direct link to changed files in Playwright screenshot review message
bdahle 63f9f73
Change default button background color to gold
bdahle 6294086
Update Playwright screenshots
bdahle e2ebeac
revert testendringer
bdahle ca8726c
Update Playwright screenshots
bdahle b28f1ee
Improve Playwright screenshot workflow to filter and validate changes
bdahle af96a31
Change default button background color to green
bdahle 2dcbdc8
Update Playwright screenshots
bdahle 289be4f
Simplify Playwright screenshot review workflow logic
bdahle a0466d0
Enhance Playwright screenshot review workflow with duplicate review p…
bdahle 9f2816f
Change default button background color to yellow
bdahle ba6b209
Update Playwright screenshots
bdahle f03d3b1
Remove yellow background color from default button
bdahle e4ce2fd
Update Playwright screenshots
bdahle e8e9796
Refactor Playwright screenshot review workflow to simplify change det…
bdahle db9c134
Change default button background color to teal
bdahle 7f7adf7
Update Playwright screenshots
bdahle bd02eb1
Refine Playwright screenshot review workflow logic for better change …
bdahle 017287c
Change default button background color to goldenrod
bdahle 3399720
Update Playwright screenshots
bdahle 5a89f06
Remove goldenrod background color from default button
bdahle c3a4456
Update Playwright screenshots
bdahle f237e93
Enhance Playwright screenshot review workflow with bot-specific revie…
bdahle b162122
Add blueviolet background color to default button
bdahle 0615e28
Update Playwright screenshots
bdahle 0d1681e
Simplify Playwright screenshot workflow PR review condition
bdahle 14d5e6d
Remove blueviolet background color from default button
bdahle 1f63ed9
Update Playwright screenshots
bdahle e906cc1
Improve Playwright screenshot workflow change detection
bdahle b78f3ed
provoke change
bdahle 5248664
Remove blueviolet background color from button
bdahle c1f5a59
Update Playwright screenshot workflow branch names
bdahle ba98136
Add aquamarine background color to default button
bdahle 7ced528
Update Playwright screenshots
bdahle bee0f3c
Refactor Playwright screenshot workflow review logic
bdahle c0d5770
Remove aquamarine background color from default button
bdahle 6719bd1
Update Playwright screenshots
bdahle 2728178
Enhance Playwright screenshot workflow logging and review logic
bdahle a640c1e
Add red background color to default button
bdahle fe52d9d
Update Playwright screenshots
bdahle 1cccc56
Improve Playwright screenshot workflow PR context handling
bdahle 568c95a
Remove red background color from default button
bdahle daff5f6
Update Playwright screenshots
bdahle d8e9809
Improve Playwright screenshot workflow file change detection
bdahle 0cc640a
Add green background color to default button
bdahle 985b401
Update Playwright screenshots
bdahle b7eae9a
Enhance Playwright screenshot workflow with improved file detection a…
bdahle 9872dbf
Remove green background color from default button
bdahle 4c602c7
Update Playwright screenshots
bdahle 41d1932
Add blue background color to default button
bdahle 92e72e8
Update Playwright screenshots
bdahle 7fb6a2b
Improve Playwright screenshot workflow review message generation
bdahle 36b00d0
Remove blue background color from default button
bdahle 073e117
Update Playwright screenshots
bdahle 02e7236
Add blue background color to default button
bdahle ec06b6f
Update Playwright screenshots
bdahle d3a030b
Change default button background color from blue to green
bdahle 3968e95
Update Playwright screenshots
bdahle 9e4ee86
Enhance Playwright screenshot workflow review identification
bdahle d5210f6
Remove green background color from default button
bdahle f452d95
Update Playwright screenshots
bdahle eb8d717
Update Playwright screenshots workflow branch name
bdahle 9aac3e9
Merge pull request #2189 from navikt/test-playwright-fredag
bdahle 02a0770
Merge pull request #2188 from navikt/test-playwright-torsdag
bdahle 2f1efc9
Update Playwright screenshots workflow branch name to playwright-regr…
bdahle 5fb6e50
Add red background color to default button
bdahle a55505c
Update Playwright screenshots
bdahle 98241b1
Update Playwright screenshot workflow review comment with emoji
bdahle 93b8250
Update Playwright screenshot review message with emoji
bdahle b634b56
Increase Playwright workers from 12 to 13
bdahle eda8a15
Update Playwright screenshot review link generation
bdahle ab61e52
Remove red background color from default button
bdahle dc450a3
Update Playwright screenshots
bdahle 1410781
Add green background color to default button
bdahle 157b191
Update Playwright screenshots
bdahle db0bffb
Update Playwright screenshot review link generation with blob_id
bdahle 8787669
Remove green background color from default button
bdahle 6ec5b00
Update Playwright screenshots
bdahle 3999a9e
Add green background color to default button
bdahle cfbabd6
Update Playwright screenshots
bdahle 313a467
Update Playwright screenshot review link generation to filter PNG files
bdahle f1eadbe
Remove green background color from default button
bdahle f197467
Update Playwright screenshots
bdahle 71091d0
Merge pull request #2193 from navikt/test-playwright-fredag-2
bdahle e36c5c3
TODO: change to main
bdahle b4ae38e
Update pull-request-comment-branch GitHub Action to v3
bdahle 619b9f4
commit_user_name: Visual changes[bot]
bdahle 161e677
Merge remote-tracking branch 'origin/main' into playwright-regresiion…
bdahle 27e91b9
Add Playwright test dependency to project
bdahle 1f90bfb
rename testfil
bdahle 92cc2a1
rename testmappe
bdahle 97311ad
Refactor Playwright screenshot review workflow to use external script
bdahle e4668e3
button teal
bdahle 097cd48
button yellow
bdahle 752d7bb
Update Playwright screenshot workflow build script
bdahle 81cbe53
flytt playwright-mappe inn i packages/nextjs
bdahle cf459e4
slett gamle snapshots
bdahle caf42d5
Update Playwright Docker image to v1.51.0
bdahle eeab8cf
Update screenshots
bdahle 40b1540
rename til visual changes bot
bdahle c4f5180
fjern farge knapp
bdahle 77cecd8
Merge pull request #2210 from navikt/playwright-test-separat-js
bdahle 7a2005d
Add aqua background color to button
bdahle 596a132
Update screenshots
bdahle 39d6d5a
Update handle-review.js path in visual changes bot workflow
bdahle fd1190d
flytt script tibake til workflow, fikk det ikke til å funke
bdahle 3dd55fa
Fix visual changes bot workflow username capitalization
bdahle 87ae25d
reduce delay
bdahle ebca238
Update screenshots
bdahle 749a5da
fjern farge
bdahle b9e43a7
Merge pull request #2211 from navikt/playwright-test-igjen
bdahle f78dc6e
Remove commented-out mobile configuration in Playwright config
bdahle 3ff5de0
Enable networkidle wait in Storybook screenshot tests
bdahle a588478
Add Storybook stories for AuthDependantRender component and improve s…
bdahle 2bb4178
legg tilbake LenkeBase-story
bdahle 7a8d498
Merge pull request #2212 from navikt/playwright-test-igjen
bdahle 17266f3
fjern screenshots
bdahle fa6bd74
Add blue background color to default button
bdahle 1019aec
Update screenshots
bdahle 5846301
fjern farge
bdahle b2543b4
Fjern commit name, funker ikke
bdahle e1b9abb
Update screenshots
bdahle 97fcc88
Merge pull request #2213 from navikt/test-og-oppdater-screenshots
bdahle 282b170
Update visual changes bot workflow to target main branch
bdahle 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 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,143 @@ | ||
name: Visual changes bot | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
jobs: | ||
update-screenshots: | ||
name: Update screenshots | ||
runs-on: ubuntu-latest-16-cores | ||
permissions: | ||
id-token: 'write' | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- name: Get branch of PR | ||
uses: xt0rted/pull-request-comment-branch@v3 | ||
id: comment-branch | ||
|
||
- name: Checkout PR branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ steps.comment-branch.outputs.head_ref }} | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
registry-url: 'https://npm.pkg.github.com' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} | ||
- run: npm run build:storybook | ||
|
||
- name: Run Playwright update screenshots | ||
run: docker run --rm -v $(pwd):/workspace -w /workspace --ipc=host mcr.microsoft.com/playwright:v1.51.0-noble /bin/bash -c "CI=true npx playwright test --update-snapshots" | ||
|
||
- name: Commit and push updated screenshots | ||
if: always() | ||
id: auto-commit-action | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: 'Update screenshots' | ||
|
||
- name: Handle PR Review | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
try { | ||
const { repo, owner } = context.repo; | ||
|
||
// Get PR number from event context | ||
let prNumber; | ||
if (context.payload.pull_request) { | ||
prNumber = context.payload.pull_request.number; | ||
} else { | ||
console.log('No PR number found in context'); | ||
return; | ||
} | ||
|
||
console.log('PR number:', prNumber); | ||
|
||
// Add a small delay to ensure files are available | ||
await new Promise(resolve => setTimeout(resolve, 1000)); | ||
|
||
const changedFiles = await github.rest.pulls.listFiles({ | ||
owner, | ||
repo, | ||
pull_number: prNumber | ||
}); | ||
|
||
console.log('Total files in PR:', changedFiles.data.length); | ||
console.log('All files in PR:', changedFiles.data.map(f => `${f.filename} (${f.status})`)); | ||
|
||
// Separate files by status | ||
const modifiedOrAddedPngs = changedFiles.data.filter(file => | ||
file.filename.endsWith('.png') && | ||
(file.status === 'modified' || file.status === 'added') | ||
); | ||
|
||
const removedPngs = changedFiles.data.filter(file => | ||
file.filename.endsWith('.png') && | ||
file.status === 'removed' | ||
); | ||
|
||
console.log('Modified/Added PNG files:', modifiedOrAddedPngs.map(f => `${f.filename} (${f.status})`)); | ||
console.log('Removed PNG files:', removedPngs.map(f => `${f.filename} (${f.status})`)); | ||
|
||
if (changedFiles.data.length === 0) { | ||
console.log('Warning: No files detected in PR. This might be a timing issue.'); | ||
return; | ||
} | ||
|
||
// Only consider files as "changed" if they are modified or added | ||
const hasScreenshotChanges = modifiedOrAddedPngs.length > 0; | ||
console.log('Has active screenshot changes:', hasScreenshotChanges); | ||
|
||
const reviews = await github.rest.pulls.listReviews({ | ||
owner, | ||
repo, | ||
pull_number: prNumber | ||
}); | ||
|
||
const REVIEW_MARKER = '<!-- playwright-screenshot-bot -->'; | ||
|
||
const botReview = reviews.data.find(review => | ||
review.user.login === 'github-actions[bot]' && | ||
review.state === 'CHANGES_REQUESTED' && | ||
review.body.includes(REVIEW_MARKER) | ||
); | ||
|
||
console.log('Found screenshot bot review:', botReview ? 'yes' : 'no'); | ||
|
||
if (hasScreenshotChanges && !botReview) { | ||
console.log('Creating new review'); | ||
const filesUrl = `https://github.com/${owner}/${repo}/pull/${prNumber}/files?file-filters[]=.png&file-filters[]=^playwright/`; | ||
await github.rest.pulls.createReview({ | ||
owner, | ||
repo, | ||
pull_number: prNumber, | ||
body: `${REVIEW_MARKER}\n## 👀 Visual changes detected\n\nPlease [review the screenshot changes](${filesUrl}) before merging.`, | ||
event: 'REQUEST_CHANGES' | ||
}); | ||
} else if (!hasScreenshotChanges && botReview) { | ||
console.log('Dismissing review because no PNG changes found'); | ||
await github.rest.pulls.dismissReview({ | ||
owner, | ||
repo, | ||
pull_number: prNumber, | ||
review_id: botReview.id, | ||
message: `${REVIEW_MARKER}\nVisual changes have been reverted` | ||
}); | ||
} else { | ||
console.log('No action needed:', | ||
hasScreenshotChanges ? 'Has changes' : 'No changes', | ||
botReview ? 'Has review' : 'No review' | ||
); | ||
} | ||
} catch (error) { | ||
console.log('Error:', error); | ||
console.log('Error details:', error.message); | ||
core.setFailed('Failed to handle review'); | ||
} |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kan sikkert fjerne noen av loggene og rydde litt i denne etterhvert, når vi har fått testa litt