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

chore: 🤖 Introduce VRT #41

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 45 additions & 0 deletions .github/workflows/reg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: reg-suit

on: push

jobs:
visual-regression-test:
name: Visual Regression Test
runs-on: ubuntu-latest
timeout-minutes: 15

container:
image: regviz/node-xcb
env:
GIT_DISCOVERY_ACROSS_FILESYSTEM: 1
GITHUB_WORKSPACE: /home/runner/work/ubie-oss/ubie-ui
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
path: /home/runner/work/ubie-oss/ubie-ui

- uses: ./actions/setup-node-and-install-deps

- name: Installing Chrome via Puppeteer
run: node ./node_modules/puppeteer/install.js

- name: Build
if: success()
run: npm run build

# https://github.com/reg-viz/reg-suit/tree/master?tab=readme-ov-file#workaround-for-detached-head
- name: workaround for detached HEAD
run: |
git config --global --add safe.directory /__w/ubie-oss/ubie-ui
git checkout ${GITHUB_REF#refs/heads/} || git checkout -b ${GITHUB_REF#refs/heads/} && git pull

- name: Capture screen shots
run: npm run screenshot

- name: Run reg-suit
run: npm run regression

env:
# TODO: Set your service account key
GCLOUD_SERVICE_KEY: ${{ secrets.GCLOUD_SERVICE_KEY }}
Comment on lines +44 to +45
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the service account key for the cloud storage access.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ build-storybook.log
# Test
/test-results/
/playwright-report/
/playwright/.cache/
/playwright/.cache/
.reg
__screenshots__
2 changes: 1 addition & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { StorybookConfig } from '@storybook/react-vite';

const config: StorybookConfig = {
stories: ['../src/**/*.@(mdx|stories.@(ts|tsx))'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions', 'storycap'],
framework: '@storybook/react-vite',
docs: {
autodocs: true,
Expand Down
11 changes: 0 additions & 11 deletions .storybook/preview.js

This file was deleted.

44 changes: 44 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import '@ubie/design-tokens/dist/tokens.css';
import type { Parameters, Decorator } from '@storybook/react';
import { withScreenshot, isScreenshot } from 'storycap';

export const decorators: Decorator[] = [
// https://github.com/reg-viz/storycap/issues/810
withScreenshot(),
// https://github.com/reg-viz/storycap/issues/464
(StoryFn) => {
Comment on lines +5 to +9
Copy link
Contributor Author

@kodai3 kodai3 Mar 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workarounds I already know.
One for storybook > v7
One for animated components's flakiness

if (isScreenshot()) {
function addStyle(styleString: string) {
const style = document.createElement('style');
style.textContent = styleString;
document.head.append(style);
}
addStyle(`
*,
*::before,
*::after {
transition: none !important;
animation: none !important;
}
input {
caret-color: transparent !important;
}
`);
}
return StoryFn();
},
];

export const parameters: Parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
screenshot: {
// TODO: スクリーンしショットをしたいデバイスがあれば指定する
// viewport: 'iPhone X',
},
Comment on lines +40 to +43
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have any preference.

};
Loading