Skip to content
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 199 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
199 commits
Select commit Hold shift + click to select a range
6f508f8
test playwrigth regression
bdahle Jan 20, 2025
abc4cb6
bruk master
bdahle Jan 20, 2025
ab788bb
remove updating snapshots comment
bdahle Jan 20, 2025
7fc35b0
add node auth token
bdahle Jan 20, 2025
9180055
add id-token permission
bdahle Jan 20, 2025
5a15cb5
test legg til registry-url
bdahle Jan 20, 2025
d966e65
bruk config fra eksempel
bdahle Jan 20, 2025
82112d7
legg til workflow generate-report
bdahle Jan 20, 2025
5a12726
add testDir playwright config
bdahle Jan 20, 2025
ca0da47
fjern updtes snapshots i workflow
bdahle Jan 20, 2025
c79ce3e
test fjern Playwright Browsers
bdahle Jan 20, 2025
3da7fe9
commit snapshots selv om tester feiler
bdahle Jan 20, 2025
d084bc0
Update playwright snapshots
bdahle Jan 20, 2025
62a1db4
revert bakgrunnsfarge
bdahle Jan 21, 2025
2232b3b
Update playwright snapshots
bdahle Jan 21, 2025
fe598d5
fjern kommentert kode
bdahle Jan 21, 2025
669ce29
bruk testbranchen som "master" foreløpig
bdahle Jan 21, 2025
7cad32f
bruk screenshots istedenfor snapshots
bdahle Jan 22, 2025
885717e
fjern chromatic modes config
bdahle Jan 23, 2025
c58ab4f
avinstaller chromatic
bdahle Jan 23, 2025
4740e03
ta kun screenshot av storybook-diven
bdahle Jan 23, 2025
552a32f
fjern chromatic addon
bdahle Jan 23, 2025
924fb34
sett maksbredde på containeren
bdahle Jan 23, 2025
571f20c
midlertidig fjern stories som krasjer
bdahle Jan 23, 2025
187476a
test paralellkjøring for veldig mye bedre performance
bdahle Jan 23, 2025
405ef50
bruk master i workflow
bdahle Jan 23, 2025
48432d3
endre branch i workflow
bdahle Jan 23, 2025
08700df
Update Playwright screenshots
bdahle Jan 23, 2025
411bd8b
todo, fremprovoser action
bdahle Jan 23, 2025
388fcbf
Update Playwright screenshots
bdahle Jan 23, 2025
40f19b0
Merge pull request #2152 from navikt/playwright-endringsbranch-test3
bdahle Jan 23, 2025
ef4baae
bruk master-branch
bdahle Jan 23, 2025
33530ea
bruk 12 workers
bdahle Feb 24, 2025
32551b8
fjern Todo
bdahle Feb 24, 2025
fdba3f6
Update Playwright screenshots workflow to use main branch
bdahle Feb 24, 2025
5c86b99
Configure Jest to ignore spec.ts files
bdahle Feb 25, 2025
09b6b95
provoke test run
bdahle Feb 27, 2025
6234943
Update Playwright screenshots
bdahle Feb 27, 2025
5353ef5
bruk 16-cores og fjern kommnetar
bdahle Feb 27, 2025
efc40b9
Update Playwright screenshots workflow branch to playwright-regresiio…
bdahle Feb 27, 2025
b4b4853
provoke test run
bdahle Feb 27, 2025
ab01eda
Enhance Playwright screenshots workflow with PR review creation
bdahle Feb 27, 2025
1784bff
Remove border-radius from Expandable component header
bdahle Feb 27, 2025
e5ec452
Add green background color to default button
bdahle Feb 27, 2025
7a5b63f
Update Playwright screenshots
bdahle Feb 27, 2025
69a79bb
Improve error handling in Playwright screenshots workflow
bdahle Feb 27, 2025
18afd3b
Change default button background color from green to yellow
bdahle Feb 27, 2025
260461e
Update Playwright screenshots
bdahle Feb 27, 2025
849be31
Change default button background color from yellow to orange
bdahle Feb 27, 2025
f361130
Update Playwright screenshots
bdahle Feb 27, 2025
75fa66c
Enhance Playwright screenshots workflow with detailed PR review
bdahle Feb 27, 2025
08dae42
Change default button background color from orange to purple
bdahle Feb 27, 2025
7dd05ed
Update Playwright screenshots
bdahle Feb 27, 2025
c330b37
Improve Playwright screenshots PR review with enhanced details and St…
bdahle Feb 27, 2025
3067647
Update Playwright screenshots
bdahle Feb 27, 2025
5548b47
Change default button background color to grey and add padding
bdahle Feb 27, 2025
d9180fa
Update Playwright screenshots
bdahle Feb 27, 2025
733f7ef
Simplify Playwright screenshot PR review message
bdahle Feb 27, 2025
a6f9585
Change default button background color from grey to orangered
bdahle Feb 27, 2025
07f5165
Update Playwright screenshots
bdahle Feb 27, 2025
17551de
Enhance Playwright screenshot workflow with check run and improved re…
bdahle Feb 27, 2025
b2b6edc
Change default button background color to aquamarine
bdahle Feb 27, 2025
50cbb30
Update Playwright screenshots
bdahle Feb 27, 2025
c57d081
Improve Playwright screenshot workflow with enhanced check run and re…
bdahle Feb 27, 2025
633dc18
Change default button background color to beige
bdahle Feb 27, 2025
6a8011e
Update Playwright screenshots
bdahle Feb 27, 2025
35d6766
Revert "Improve Playwright screenshot workflow with enhanced check ru…
bdahle Feb 27, 2025
b93e98b
Revert "Enhance Playwright screenshot workflow with check run and imp…
bdahle Feb 27, 2025
296f9c5
Modify Playwright screenshot workflow review message generation
bdahle Feb 27, 2025
0f7dc81
Change default button background color to black
bdahle Feb 27, 2025
04b05f3
Update Playwright screenshots
bdahle Feb 27, 2025
7b4d008
Refactor Playwright screenshot workflow review message generation
bdahle Feb 27, 2025
64e738f
Change default button background color to white
bdahle Feb 27, 2025
9bc8c74
Update Playwright screenshots
bdahle Feb 27, 2025
2ff99c8
Refactor Playwright screenshot workflow to extract filename in review…
bdahle Feb 27, 2025
8e747b6
Add direct link to changed files in Playwright screenshot review message
bdahle Feb 27, 2025
63f9f73
Change default button background color to gold
bdahle Feb 27, 2025
6294086
Update Playwright screenshots
bdahle Feb 27, 2025
e2ebeac
revert testendringer
bdahle Feb 28, 2025
ca8726c
Update Playwright screenshots
bdahle Feb 28, 2025
b28f1ee
Improve Playwright screenshot workflow to filter and validate changes
bdahle Feb 28, 2025
af96a31
Change default button background color to green
bdahle Feb 28, 2025
2dcbdc8
Update Playwright screenshots
bdahle Feb 28, 2025
289be4f
Simplify Playwright screenshot review workflow logic
bdahle Feb 28, 2025
a0466d0
Enhance Playwright screenshot review workflow with duplicate review p…
bdahle Feb 28, 2025
9f2816f
Change default button background color to yellow
bdahle Feb 28, 2025
ba6b209
Update Playwright screenshots
bdahle Feb 28, 2025
f03d3b1
Remove yellow background color from default button
bdahle Feb 28, 2025
e4ce2fd
Update Playwright screenshots
bdahle Feb 28, 2025
e8e9796
Refactor Playwright screenshot review workflow to simplify change det…
bdahle Feb 28, 2025
db9c134
Change default button background color to teal
bdahle Feb 28, 2025
7f7adf7
Update Playwright screenshots
bdahle Feb 28, 2025
bd02eb1
Refine Playwright screenshot review workflow logic for better change …
bdahle Feb 28, 2025
017287c
Change default button background color to goldenrod
bdahle Feb 28, 2025
3399720
Update Playwright screenshots
bdahle Feb 28, 2025
5a89f06
Remove goldenrod background color from default button
bdahle Feb 28, 2025
c3a4456
Update Playwright screenshots
bdahle Feb 28, 2025
f237e93
Enhance Playwright screenshot review workflow with bot-specific revie…
bdahle Feb 28, 2025
b162122
Add blueviolet background color to default button
bdahle Feb 28, 2025
0615e28
Update Playwright screenshots
bdahle Feb 28, 2025
0d1681e
Simplify Playwright screenshot workflow PR review condition
bdahle Feb 28, 2025
14d5e6d
Remove blueviolet background color from default button
bdahle Feb 28, 2025
1f63ed9
Update Playwright screenshots
bdahle Feb 28, 2025
e906cc1
Improve Playwright screenshot workflow change detection
bdahle Feb 28, 2025
b78f3ed
provoke change
bdahle Feb 28, 2025
5248664
Remove blueviolet background color from button
bdahle Feb 28, 2025
c1f5a59
Update Playwright screenshot workflow branch names
bdahle Feb 28, 2025
ba98136
Add aquamarine background color to default button
bdahle Feb 28, 2025
7ced528
Update Playwright screenshots
bdahle Feb 28, 2025
bee0f3c
Refactor Playwright screenshot workflow review logic
bdahle Feb 28, 2025
c0d5770
Remove aquamarine background color from default button
bdahle Feb 28, 2025
6719bd1
Update Playwright screenshots
bdahle Feb 28, 2025
2728178
Enhance Playwright screenshot workflow logging and review logic
bdahle Feb 28, 2025
a640c1e
Add red background color to default button
bdahle Feb 28, 2025
fe52d9d
Update Playwright screenshots
bdahle Feb 28, 2025
1cccc56
Improve Playwright screenshot workflow PR context handling
bdahle Feb 28, 2025
568c95a
Remove red background color from default button
bdahle Feb 28, 2025
daff5f6
Update Playwright screenshots
bdahle Feb 28, 2025
d8e9809
Improve Playwright screenshot workflow file change detection
bdahle Feb 28, 2025
0cc640a
Add green background color to default button
bdahle Feb 28, 2025
985b401
Update Playwright screenshots
bdahle Feb 28, 2025
b7eae9a
Enhance Playwright screenshot workflow with improved file detection a…
bdahle Feb 28, 2025
9872dbf
Remove green background color from default button
bdahle Feb 28, 2025
4c602c7
Update Playwright screenshots
bdahle Feb 28, 2025
41d1932
Add blue background color to default button
bdahle Feb 28, 2025
92e72e8
Update Playwright screenshots
bdahle Feb 28, 2025
7fb6a2b
Improve Playwright screenshot workflow review message generation
bdahle Feb 28, 2025
36b00d0
Remove blue background color from default button
bdahle Feb 28, 2025
073e117
Update Playwright screenshots
bdahle Feb 28, 2025
02e7236
Add blue background color to default button
bdahle Feb 28, 2025
ec06b6f
Update Playwright screenshots
bdahle Feb 28, 2025
d3a030b
Change default button background color from blue to green
bdahle Feb 28, 2025
3968e95
Update Playwright screenshots
bdahle Feb 28, 2025
9e4ee86
Enhance Playwright screenshot workflow review identification
bdahle Feb 28, 2025
d5210f6
Remove green background color from default button
bdahle Feb 28, 2025
f452d95
Update Playwright screenshots
bdahle Feb 28, 2025
eb8d717
Update Playwright screenshots workflow branch name
bdahle Feb 28, 2025
9aac3e9
Merge pull request #2189 from navikt/test-playwright-fredag
bdahle Feb 28, 2025
02a0770
Merge pull request #2188 from navikt/test-playwright-torsdag
bdahle Feb 28, 2025
2f1efc9
Update Playwright screenshots workflow branch name to playwright-regr…
bdahle Feb 28, 2025
5fb6e50
Add red background color to default button
bdahle Feb 28, 2025
a55505c
Update Playwright screenshots
bdahle Feb 28, 2025
98241b1
Update Playwright screenshot workflow review comment with emoji
bdahle Feb 28, 2025
93b8250
Update Playwright screenshot review message with emoji
bdahle Feb 28, 2025
b634b56
Increase Playwright workers from 12 to 13
bdahle Feb 28, 2025
eda8a15
Update Playwright screenshot review link generation
bdahle Feb 28, 2025
ab61e52
Remove red background color from default button
bdahle Feb 28, 2025
dc450a3
Update Playwright screenshots
bdahle Feb 28, 2025
1410781
Add green background color to default button
bdahle Feb 28, 2025
157b191
Update Playwright screenshots
bdahle Feb 28, 2025
db0bffb
Update Playwright screenshot review link generation with blob_id
bdahle Feb 28, 2025
8787669
Remove green background color from default button
bdahle Feb 28, 2025
6ec5b00
Update Playwright screenshots
bdahle Feb 28, 2025
3999a9e
Add green background color to default button
bdahle Feb 28, 2025
cfbabd6
Update Playwright screenshots
bdahle Feb 28, 2025
313a467
Update Playwright screenshot review link generation to filter PNG files
bdahle Feb 28, 2025
f1eadbe
Remove green background color from default button
bdahle Mar 3, 2025
f197467
Update Playwright screenshots
bdahle Mar 3, 2025
71091d0
Merge pull request #2193 from navikt/test-playwright-fredag-2
bdahle Mar 3, 2025
e36c5c3
TODO: change to main
bdahle Mar 3, 2025
b4ae38e
Update pull-request-comment-branch GitHub Action to v3
bdahle Mar 6, 2025
619b9f4
commit_user_name: Visual changes[bot]
bdahle Mar 6, 2025
161e677
Merge remote-tracking branch 'origin/main' into playwright-regresiion…
bdahle Mar 7, 2025
27e91b9
Add Playwright test dependency to project
bdahle Mar 7, 2025
1f90bfb
rename testfil
bdahle Mar 7, 2025
92cc2a1
rename testmappe
bdahle Mar 7, 2025
97311ad
Refactor Playwright screenshot review workflow to use external script
bdahle Mar 7, 2025
e4668e3
button teal
bdahle Mar 7, 2025
097cd48
button yellow
bdahle Mar 7, 2025
752d7bb
Update Playwright screenshot workflow build script
bdahle Mar 7, 2025
81cbe53
flytt playwright-mappe inn i packages/nextjs
bdahle Mar 7, 2025
cf459e4
slett gamle snapshots
bdahle Mar 7, 2025
caf42d5
Update Playwright Docker image to v1.51.0
bdahle Mar 7, 2025
eeab8cf
Update screenshots
bdahle Mar 7, 2025
40b1540
rename til visual changes bot
bdahle Mar 7, 2025
c4f5180
fjern farge knapp
bdahle Mar 7, 2025
77cecd8
Merge pull request #2210 from navikt/playwright-test-separat-js
bdahle Mar 7, 2025
7a2005d
Add aqua background color to button
bdahle Mar 7, 2025
596a132
Update screenshots
bdahle Mar 7, 2025
39d6d5a
Update handle-review.js path in visual changes bot workflow
bdahle Mar 7, 2025
fd1190d
flytt script tibake til workflow, fikk det ikke til å funke
bdahle Mar 7, 2025
3dd55fa
Fix visual changes bot workflow username capitalization
bdahle Mar 7, 2025
87ae25d
reduce delay
bdahle Mar 7, 2025
ebca238
Update screenshots
bdahle Mar 7, 2025
749a5da
fjern farge
bdahle Mar 7, 2025
b9e43a7
Merge pull request #2211 from navikt/playwright-test-igjen
bdahle Mar 7, 2025
f78dc6e
Remove commented-out mobile configuration in Playwright config
bdahle Mar 9, 2025
3ff5de0
Enable networkidle wait in Storybook screenshot tests
bdahle Mar 9, 2025
a588478
Add Storybook stories for AuthDependantRender component and improve s…
bdahle Mar 9, 2025
2bb4178
legg tilbake LenkeBase-story
bdahle Mar 9, 2025
7a8d498
Merge pull request #2212 from navikt/playwright-test-igjen
bdahle Mar 9, 2025
17266f3
fjern screenshots
bdahle Mar 9, 2025
fa6bd74
Add blue background color to default button
bdahle Mar 9, 2025
1019aec
Update screenshots
bdahle Mar 9, 2025
5846301
fjern farge
bdahle Mar 9, 2025
b2543b4
Fjern commit name, funker ikke
bdahle Mar 9, 2025
e1b9abb
Update screenshots
bdahle Mar 9, 2025
97fcc88
Merge pull request #2213 from navikt/test-og-oppdater-screenshots
bdahle Mar 9, 2025
282b170
Update visual changes bot workflow to target main branch
bdahle Mar 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions .github/workflows/visual-changes-bot.yml
Copy link
Contributor Author

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

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');
}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@
**/.vscode
**/.env.prod-local.local
**/analyze

# Playwright
**/test-results
**/playwright-report
**/blob-report
**/playwright/.cache
Loading
Loading