Skip to content

Commit

Permalink
ci: Add script to workflow for testing storybooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilscb committed Nov 3, 2023
1 parent ae75b98 commit a2c1340
Show file tree
Hide file tree
Showing 7 changed files with 3,572 additions and 259 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/smoke_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Smoke Tests

on:
push:
branches: [master]
pull_request:
branches: [master]

defaults:
run:
working-directory: typescript
jobs:
test:
name: Smoke Tests
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Install dependencies
run: npm ci

- name: Install Test Dependencies
run: npm install concurrently http-server wait-on

- name: Build Storybook
run: npm run build-storybook

- 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 http-server storybook-static --port $PORT -a $HOST" \
"npx wait-on http://$HOST:$PORT/ && npm run storybook:test -- --ci --url http://$HOST:$PORT/"
3,717 changes: 3,492 additions & 225 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 @@ -58,6 +59,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 @@ -27,8 +27,8 @@ const GroupTreeComponent: React.FC<GroupTreeProps> = React.memo(
({

Check failure on line 27 in typescript/packages/group-tree/src/components/GroupTreeComponent.tsx

View workflow job for this annotation

GitHub Actions / typescript

Replace `⏎········id,⏎········data,⏎········edgeOptions,⏎········nodeOptions,⏎···` with `·id,·data,·edgeOptions,·nodeOptions`
id,
data,
edgeOptions: edge_options,
nodeOptions: node_options,
edgeOptions,
nodeOptions,
}: GroupTreeProps) => {
const [index, setIndex] = useState([0, 0] as [number, number]);

Expand All @@ -49,14 +49,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
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,31 @@ export default {
title: "SubsurfaceViewer/Components/Settings/LayerSettingsButton",
};

const Template = (args) => {
return <LayerSettingsButton layer={args.layer} />;
};
// Note: Disabled for now will be fixed later. Missing redux context.

export const DrawingSettings = Template.bind({});
DrawingSettings.args = {
layer: {
name: "Drawing",
"@@type": "DrawingLayer",
id: "drawing-layer",
visible: true,
mode: "drawLineString",
},
};
// const Template = (args) => {
// return <LayerSettingsButton layer={args.layer} />;
// };

export const WellsSettings = Template.bind({});
WellsSettings.args = {
layer: {
name: "Wells",
"@@type": "WellsLayer",
id: "wells-layer",
opacity: 1,
pointRadiusScale: 8,
visible: true,
},
};
// export const DrawingSettings = Template.bind({});
// DrawingSettings.args = {
// layer: {
// name: "Drawing",
// "@@type": "DrawingLayer",
// id: "drawing-layer",
// visible: true,
// mode: "drawLineString",
// },
// };

// export const WellsSettings = Template.bind({});
// WellsSettings.args = {
// layer: {
// name: "Wells",
// "@@type": "WellsLayer",
// id: "wells-layer",
// opacity: 1,
// pointRadiusScale: 8,
// visible: true,
// },
// };

0 comments on commit a2c1340

Please sign in to comment.