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

ci: Add script to workflow for testing storybooks. #1750

Merged
merged 5 commits into from
Nov 3, 2023
Merged
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
10 changes: 10 additions & 0 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,13 @@ jobs:
git commit -m "Update Github Pages"
git push "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" gh-pages
fi

- name: Serve Storybook and run tests
env:
PORT: 8080
HOST: 127.0.0.1
run: |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
"npx playwright install" \
"npx http-server storybook-static --port $PORT -a $HOST" \
"npx wait-on http://$HOST:$PORT/ && npm run storybook:test -- --ci --url http://$HOST:$PORT/"
3,715 changes: 3,491 additions & 224 deletions typescript/package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"validate": "npm run typecheck && npm run lint",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"storybook:test": "test-storybook",
"cy:run": "npx cypress run -b chrome --component --headed",
"postpack": "npm run tidy-up",
"git:hooks:enable": "cd .. && husky install",
Expand Down Expand Up @@ -52,6 +53,7 @@
"@storybook/addon-storysource": "^7.0.23",
"@storybook/react": "^7.0.23",
"@storybook/react-webpack5": "^7.0.23",
"@storybook/test-runner": "^0.13.0",
"@storybook/testing-react": "^2.0.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ export interface GroupTreeProps {
}

const GroupTreeComponent: React.FC<GroupTreeProps> = React.memo(
({
id,
data,
edgeOptions: edge_options,
nodeOptions: node_options,
}: GroupTreeProps) => {
({ id, data, edgeOptions, nodeOptions }: GroupTreeProps) => {
const [index, setIndex] = useState([0, 0] as [number, number]);

const currentDateTimeChangedCallBack = useCallback(
Expand All @@ -49,14 +44,14 @@ const GroupTreeComponent: React.FC<GroupTreeProps> = React.memo(
<DataProvider
id={id}
data={data}
edge_options={edge_options}
node_options={node_options}
edge_options={edgeOptions}
node_options={nodeOptions}
initial_index={index}
>
<GroupTreeViewer
id={id}
edge_options={edge_options}
node_options={node_options}
edge_options={edgeOptions}
node_options={nodeOptions}
currentDateTimeChangedCallBack={
currentDateTimeChangedCallBack
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export const Default = Template.bind({});
Default.args = {
id: "grouptree",
data: require("../../../../../example-data/group-tree.json"),
edge_options: edge_options,
node_options: node_options,
edgeOptions: edge_options,
nodeOptions: node_options,
};
5 changes: 3 additions & 2 deletions typescript/packages/subsurface-viewer/src/components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ function boundingBoxCenter(box: BoundingBox3D): [number, number, number] {
// Exclude "layerIds" when monitoring changes to "view" prop as we do not
// want to recalculate views when the layers change.
function compareViewsProp(views: ViewsType | undefined): string | undefined {
if (typeof views === "undefined") {
return views;
if (typeof views === "undefined" || Object.keys(views).length === 0) {
return undefined;
}

const copy = cloneDeep(views);
Expand Down Expand Up @@ -1352,6 +1352,7 @@ function createViewsAndViewStates(
const isOk =
deck &&
views &&
Object.keys(views).length !== 0 &&
views.layout[0] >= 1 &&
views.layout[1] >= 1 &&
widthViewPort > 0 &&
Expand Down

This file was deleted.