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 2 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
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'
hkfb marked this conversation as resolved.
Show resolved Hide resolved

- name: Install dependencies
run: npm ci

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

- name: Build Storybook
hkfb marked this conversation as resolved.
Show resolved Hide resolved
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,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 @@ -27,8 +27,8 @@ const GroupTreeComponent: React.FC<GroupTreeProps> = React.memo(
({
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) => {
hkfb marked this conversation as resolved.
Show resolved Hide resolved
// 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,
// },
// };