-
Notifications
You must be signed in to change notification settings - Fork 42
test: replace story screenshots with DOM snapshots #2619
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
Open
hkfb
wants to merge
17
commits into
equinor:master
Choose a base branch
from
hkfb:test_runner/compose_dom_snapshots
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2cd4d26
refactor: refactor WellLogScaleSelector to functional component
hkfb 2ffbc25
test: add story for WellLogScaleSelector component
hkfb 64e9da9
test: add story play functions for WellLogScaleSelector
hkfb 64ef39a
test: add dom snapshot tests for stories
hkfb 4147467
test: remove redundant story snapshots
hkfb 0758cef
refactor: add test-runner typing
hkfb ecd4ce4
refactor: fix typing and prettier conditions
hkfb b780725
Merge branch 'master' of github.com:equinor/webviz-subsurface-compone…
hkfb b92d99c
refactor: remove unused ts-expect directive
hkfb 4cf0ddf
build: downgrade playwright to v 1.39
hkfb bbffde4
build: really downgrade playwright to v 1.39
hkfb 493bcee
test: remove wait conditions in DOM test runners
hkfb 4938ec1
test: add docker compose config for running static storybook testing
hkfb 8808dd4
Merge branch 'master' of github.com:equinor/webviz-subsurface-compone…
hkfb 2d8792d
test: update story snapshots
hkfb a404eea
Merge branch 'master' of github.com:equinor/webviz-subsurface-compone…
hkfb 6fa0a2e
docs: update readme with new testing instructions
hkfb 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,16 @@ | ||
node_modules | ||
npm-debug.log* | ||
.git | ||
.gitignore | ||
README.md | ||
.env | ||
.nyc_output | ||
coverage | ||
.nyc_output | ||
.cache | ||
dist | ||
.DS_Store | ||
*.log | ||
.vscode | ||
.idea | ||
storybook-static |
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 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
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,22 @@ | ||
services: | ||
storybook: | ||
build: | ||
context: .. | ||
dockerfile: typescript/config/docker/storybook/Dockerfile | ||
ports: | ||
- "6006:6006" | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://localhost:6006"] | ||
|
||
test-storybook: | ||
build: | ||
context: . | ||
dockerfile: config/docker/test_runner/Dockerfile | ||
depends_on: | ||
storybook: | ||
condition: service_healthy | ||
volumes: | ||
- ./.storybook:/home/pwuser/test/.storybook:ro | ||
- ./packages:/home/pwuser/test/packages | ||
environment: | ||
TARGET_URL: "http://storybook:6006/" |
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,34 @@ | ||
FROM node:22-alpine | ||
|
||
# Install curl for health checks and http-server globally in one layer | ||
RUN apk add --no-cache curl && \ | ||
npm install -g http-server | ||
|
||
WORKDIR /app/typescript | ||
|
||
# Copy package files first for better caching | ||
COPY typescript/package.json typescript/package-lock.json ./ | ||
|
||
# Install dependencies early to cache this expensive step | ||
RUN npm ci CYPRESS_INSTALL_BINARY=0 --ignore-scripts --workspace-root | ||
|
||
# Copy configuration files | ||
COPY typescript/tsconfig.json typescript/nx.json ./ | ||
|
||
COPY typescript/.storybook ./.storybook | ||
COPY example-data ../example-data | ||
|
||
# Copy source code (these change more frequently) | ||
COPY typescript/packages ./packages | ||
|
||
# Install remaining workspace dependencies | ||
RUN npm ci CYPRESS_INSTALL_BINARY=0 --ignore-scripts | ||
|
||
# Build storybook statically | ||
RUN npm run build-storybook | ||
|
||
# Expose port 6006 | ||
EXPOSE 6006 | ||
|
||
# Serve the built storybook with http-server | ||
CMD ["http-server", "storybook-static", "--port", "6006", "-a", "0.0.0.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,14 @@ | ||
FROM mcr.microsoft.com/playwright:v1.39.0-jammy | ||
|
||
RUN mkdir -p /home/pwuser/test && chown -R pwuser:pwuser /home/pwuser/test | ||
WORKDIR /home/pwuser/test | ||
|
||
COPY package.json ./ | ||
COPY package-lock.json ./ | ||
|
||
RUN npm ci | ||
|
||
COPY .storybook ./.storybook | ||
|
||
# Create entrypoint that accepts additional arguments | ||
ENTRYPOINT ["npm", "run", "storybook:test"] |
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
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
Binary file removed
BIN
-6.11 KB
...ts/__image_snapshots__/subsurfaceviewer-components-distancescale--dark-mode.png
Binary file not shown.
Binary file removed
BIN
-6.1 KB
...s/__image_snapshots__/subsurfaceviewer-components-distancescale--light-mode.png
Binary file not shown.
Binary file removed
BIN
-9 KB
..._image_snapshots__/subsurfaceviewer-components-infocard--mutiple-properties.png
Binary file not shown.
Binary file removed
BIN
-9 KB
...s/__image_snapshots__/subsurfaceviewer-components-infocard--single-property.png
Binary file not shown.
21 changes: 21 additions & 0 deletions
21
...s/subsurface-viewer/src/storybook/components/__snapshots__/DistanceScale.stories.tsx.snap
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,21 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`SubsurfaceViewer / Components / DistanceScale DarkMode smoke-test 1`] = ` | ||
<div style="position: absolute; color: white;"> | ||
<label style="color: white;"> | ||
800m | ||
</label> | ||
<div style="width: 100px; height: 4px; border-top: none; border-right: 2px solid; border-bottom: 2px solid; border-left: 2px solid; border-image: initial; display: inline-block; margin-left: 3px;"> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`SubsurfaceViewer / Components / DistanceScale LightMode smoke-test 1`] = ` | ||
<div style="position: absolute;"> | ||
<label> | ||
800m | ||
</label> | ||
<div style="width: 100px; height: 4px; border-top: none; border-right: 2px solid; border-bottom: 2px solid; border-left: 2px solid; border-image: initial; display: inline-block; margin-left: 3px;"> | ||
</div> | ||
</div> | ||
`; |
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.
Does this replace the previous version (ie. docker:build and docker:storybook:test), that is running in the docker ?
If so we can remove the docker:* version.
If not, add in the doc how to do it (needed for windows devs to update the ref images).
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.
I hoped everyone could use the new compose:* version. Could you give it a try?
DOM snapshots are not the same when running storybook dynamically. In CI it runs static, so you won't be able to create DOM snapshots locally with the previous scripts.
However, for creating screenshots, the dynamic version (docker:*) still works and is probably quicker.
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.
In that case, keep both version in the README and explain the difference.
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.
I deleted a reference .snap file and ran
npm run compose:storybook:test
=> Result was green with a written snapshot :/Unfortunately, the EOL was not matching the initial file's EOL :/
A second run failed because of 2 image comparison failures...
Then I deleted a reference .snap file and ran
npm run compose:storybook:test:update
twice => it ended green, but without restoring the missing .snap file.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.
Is this new behaviour?
I don't understand how this could happen. Does it fail the tests?
Are the tests more flaky than before?
I haven't seen the update not working before. Can you show me more precisely what you did so that I can try to reproduce it?