Skip to content

Commit 6556e71

Browse files
authored
Merge pull request #254 from MetaCell/fix/e2e
Fix e2e tests
2 parents 23e0870 + 8871bf9 commit 6556e71

11 files changed

Lines changed: 2580 additions & 3345 deletions

File tree

.github/workflows/actions.yml

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
11
name: SDS Viewer Workflow
22

3-
# Controls when the workflow will run
43
on:
5-
# Triggers the workflow on push or pull request events but only for the specified branch
64
push:
75
branches:
8-
- "master"
9-
- "development"
6+
- "master"
7+
- "development"
108
pull_request:
119
branches:
12-
- "master"
13-
- "development"
10+
- "master"
11+
- "development"
1412

15-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
16-
jobs:
13+
jobs:
1714
sds_viewer_test:
18-
# The type of runner that the job will run on
19-
runs-on: ubuntu-20.04
15+
runs-on: ubuntu-22.04
2016
container: lironavon/docker-puppeteer-container:14.16.0
2117
env:
2218
CI: true
2319
steps:
24-
- uses: actions/checkout@v1
25-
- name: Use Node.js ${{ matrix.node-version }}
26-
uses: actions/setup-node@v1
27-
with:
28-
node-version: 16.X
29-
- name: SDS Viewer tests disabled
30-
run: echo "Tests disabled for this pipeline"
31-
env:
20+
- uses: actions/checkout@v4
21+
22+
- name: Use Node.js 18.x
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 18.x
26+
27+
- name: Install dependencies
28+
run: yarn
29+
30+
- name: Start development server in background
31+
run: |
32+
yarn start &
33+
npx wait-on http://localhost:3000
34+
env:
35+
CI: true
36+
37+
- name: Run E2E snapshot tests
38+
run: npm run e2e_test
39+
env:
3240
CI: true

__tests__/e2e.test.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
import * as puppeteer from "puppeteer";
2-
import * as selectors from "./selectors";
3-
import { ONE_SECOND, ONE_MINUTE, TWO_MINUTES, TEN_MINUTES } from "./time_constants";
4-
import 'expect-puppeteer';
5-
import 'puppeteer'
6-
import { toMatchImageSnapshot } from 'jest-image-snapshot'
7-
import { time } from "console";
8-
expect.extend({ toMatchImageSnapshot })
1+
const puppeteer = require("puppeteer");
2+
const selectors = require("./selectors");
3+
const { ONE_SECOND, ONE_MINUTE, TWO_MINUTES, TEN_MINUTES } = require("./time_constants");
4+
require('expect-puppeteer');
5+
require('puppeteer');
6+
const { toMatchImageSnapshot } = require('jest-image-snapshot');
7+
const { time } = require("console");
8+
expect.extend({ toMatchImageSnapshot });
99
const axios = require('axios').default;
1010
const fs = require('fs');
1111
const path = require('path');
1212
var scriptName = path.basename(__filename, '.js');
1313

1414

15-
const DEV_URL = 'https://metacell.github.io/sds-viewer/'
15+
const DEV_URL = process.env.DEV_URL || 'http://localhost:3000/'
1616
const DATASET_ID = '0a5a2827-2b39-4085-87ea-2b7fbbe27cc8'
1717

1818
//SNAPSHOT
1919
const SNAPSHOT_OPTIONS = {
2020
customSnapshotsDir: './__tests__/snapshots',
2121
comparisonMethod: 'ssim',
2222
failureThresholdType: 'percent',
23-
failureThreshold: 0.25
23+
failureThreshold: 0.3
2424
};
2525

2626

2727

28-
2928
jest.setTimeout(TEN_MINUTES);
3029

3130

__tests__/selectors.js

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,46 @@
11
//Selectors:
22

3-
export const EMPTY_DATASET_VIEWER_SELECTOR = '.MuiBox-empty';
4-
export const EMPTY_DATASET_LIST_SELECTOR = '.no-instance';
5-
export const LOAD_BUTTONS_SELECTOR = 'button[class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-disableElevation MuiButton-fullWidth"]';
6-
export const DATASET_LIST_SELECTOR = '.datasets_list';
7-
export const DATASET_ITEM_SELECTOR = '.dataset_item';
8-
export const DONE_BUTTON_SELECTOR = 'button[class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-disableElevation Mui-disabled MuiButton-fullWidth Mui-disabled"]';
9-
export const DATASET_COUNT_NUMBER_SELECTOR = 'p[class="MuiTypography-root MuiTypography-body1"]';
10-
export const SPARC_DATASET_LIST_SELECTOR = 'li[class="MuiListItem-root dataset_item MuiListItem-gutters"]';
11-
export const ENABLED_DONE_BUTTON_SELECTOR = 'button[class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-disableElevation MuiButton-fullWidth"]';
12-
export const LOADED_DATASET_SELECTOR = 'p[class="MuiTypography-root labelText MuiTypography-body2"]';
13-
export const GRAPH_SELECTOR = '.graph-view';
14-
export const OPEN_FOLDER_BUTTON_SELECTOR = 'span[class="MuiTypography-root labelCaption MuiTypography-caption MuiTypography-colorInherit"]';
15-
export const SUBFOLDERS_SELECTOR = 'ul[class="MuiCollapse-root MuiTreeItem-group MuiCollapse-entered"]'
16-
export const FELINE_DATASET_IMG_SELECTOR = 'img[alt="Feline brainstem neuron extracellular potential recordings"]';
17-
export const DATA_ID_SELECTOR = 'h6[class="MuiTypography-root breadcrumb_selected MuiTypography-subtitle2"]';
18-
export const URL_UPLOADER_SELECTOR = '#url-uploader';
19-
export const LOAD_DATA_POPUP_SELECTOR = 'div[class="MuiTabs-root rounded"]';
20-
export const LOAD_THROUGH_URL_TAB_SELECTOR = '#simple-tab-1';
21-
export const LOCAL_UPLOAD_TAB_SELECTOR = '#simple-tab-0';
22-
export const LOCAL_SYSTEM_UPLOAD_BUTTON_SELECTOR = '#simple-tabpanel-0';
3+
const EMPTY_DATASET_VIEWER_SELECTOR = '.MuiBox-empty';
4+
const EMPTY_DATASET_LIST_SELECTOR = '.no-instance';
5+
const LOAD_BUTTONS_SELECTOR = 'button[class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-disableElevation MuiButton-fullWidth"]';
6+
const DATASET_LIST_SELECTOR = '.datasets_list';
7+
const DATASET_ITEM_SELECTOR = '.dataset_item';
8+
const DONE_BUTTON_SELECTOR = 'button[class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-disableElevation Mui-disabled MuiButton-fullWidth Mui-disabled"]';
9+
const DATASET_COUNT_NUMBER_SELECTOR = 'p[class="MuiTypography-root MuiTypography-body1"]';
10+
const SPARC_DATASET_LIST_SELECTOR = 'li[class="MuiListItem-root dataset_item MuiListItem-gutters"]';
11+
const ENABLED_DONE_BUTTON_SELECTOR = 'button[class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-disableElevation MuiButton-fullWidth"]';
12+
const LOADED_DATASET_SELECTOR = 'p[class="MuiTypography-root labelText MuiTypography-body2"]';
13+
const GRAPH_SELECTOR = '.graph-view';
14+
const OPEN_FOLDER_BUTTON_SELECTOR = 'span[class="MuiTypography-root labelCaption MuiTypography-caption MuiTypography-colorInherit"]';
15+
const SUBFOLDERS_SELECTOR = 'ul[class="MuiCollapse-root MuiTreeItem-group MuiCollapse-entered"]'
16+
const FELINE_DATASET_IMG_SELECTOR = 'img[alt="Feline brainstem neuron extracellular potential recordings"]';
17+
const DATA_ID_SELECTOR = 'h6[class="MuiTypography-root breadcrumb_selected MuiTypography-subtitle2"]';
18+
const URL_UPLOADER_SELECTOR = '#url-uploader';
19+
const LOAD_DATA_POPUP_SELECTOR = 'div[class="MuiTabs-root rounded"]';
20+
const LOAD_THROUGH_URL_TAB_SELECTOR = '#simple-tab-1';
21+
const LOCAL_UPLOAD_TAB_SELECTOR = '#simple-tab-0';
22+
const LOCAL_SYSTEM_UPLOAD_BUTTON_SELECTOR = '#simple-tabpanel-0';
23+
24+
module.exports = {
25+
EMPTY_DATASET_VIEWER_SELECTOR,
26+
EMPTY_DATASET_LIST_SELECTOR,
27+
LOAD_BUTTONS_SELECTOR,
28+
DATASET_LIST_SELECTOR,
29+
DATASET_ITEM_SELECTOR,
30+
DONE_BUTTON_SELECTOR,
31+
DATASET_COUNT_NUMBER_SELECTOR,
32+
SPARC_DATASET_LIST_SELECTOR,
33+
ENABLED_DONE_BUTTON_SELECTOR,
34+
LOADED_DATASET_SELECTOR,
35+
GRAPH_SELECTOR,
36+
OPEN_FOLDER_BUTTON_SELECTOR,
37+
SUBFOLDERS_SELECTOR,
38+
FELINE_DATASET_IMG_SELECTOR,
39+
DATA_ID_SELECTOR,
40+
URL_UPLOADER_SELECTOR,
41+
LOAD_DATA_POPUP_SELECTOR,
42+
LOAD_THROUGH_URL_TAB_SELECTOR,
43+
LOCAL_UPLOAD_TAB_SELECTOR,
44+
LOCAL_SYSTEM_UPLOAD_BUTTON_SELECTOR
45+
};
2346

File renamed without changes.
File renamed without changes.

__tests__/time_constants.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
export const TWO_MINUTES = 60000 * 2;
2-
export const ONE_SECOND = 1000
3-
export const ONE_MINUTE = 60000;
4-
export const TEN_MINUTES = 600000
1+
const TWO_MINUTES = 60000 * 2;
2+
const ONE_SECOND = 1000;
3+
const ONE_MINUTE = 60000;
4+
const TEN_MINUTES = 600000;
5+
6+
module.exports = {
7+
TWO_MINUTES,
8+
ONE_SECOND,
9+
ONE_MINUTE,
10+
TEN_MINUTES
11+
};

jest-puppeteer.config.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
module.exports = {
2-
launch: {
3-
headless: true,
4-
// slowMo:20,
5-
defaultViewport: {
6-
width: 1000,
7-
height: 800
8-
},
9-
timeout: 120000
2+
launch: {
3+
headless: 'new',
4+
// slowMo:20,
5+
defaultViewport: {
6+
width: 1000,
7+
height: 800
108
},
11-
}
9+
timeout: 120000
10+
},
11+
testEnvironmentOptions: {}
12+
}

jest.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
module.exports = {
22
rootDir: "__tests__",
33
verbose: true,
4-
bail : false,
4+
bail: false,
55
preset: "jest-puppeteer",
6+
testEnvironment: "jest-environment-puppeteer",
7+
testEnvironmentOptions: {},
68
globals: {
79
"ts-jest": {
810
tsConfig: {
@@ -11,4 +13,4 @@ module.exports = {
1113
},
1214
},
1315
}
14-
};
16+
};

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,31 @@
2626
"axios": "^0.21.1",
2727
"fs": "^0.0.1-security",
2828
"gh-pages": "^3.2.3",
29-
"jest": "26.6.0",
30-
"jest-image-snapshot": "4.5.1",
31-
"jest-puppeteer": "^11.0.0",
29+
"jest": "^29.7.0",
30+
"jest-image-snapshot": "6.5.1",
31+
"jest-puppeteer": "^7.0.0",
3232
"material-ui-dropzone": "^3.5.0",
3333
"n3": "^1.13.0",
34-
"puppeteer": "^24.10.0",
34+
"puppeteer": "^19.11.1",
3535
"react": "^17.0.2",
3636
"react-beautiful-dnd": "^13.1.1",
3737
"react-dom": "^17.0.2",
3838
"react-hot-loader": "^4.13.0",
3939
"react-redux": "^7.2.4",
4040
"react-scripts": "^5.0.1",
4141
"three": "^0.171.0",
42-
"ts-jest": "^26.4.4",
42+
"ts-jest": "^29.1.0",
4343
"typescript": "^4.2.4",
44-
"uuid": "^8.3.2"
44+
"uuid": "^8.3.2",
45+
"expect-puppeteer": "^6.0.0"
4546
},
4647
"scripts": {
4748
"start": "craco start",
4849
"predeploy": "yarn build",
4950
"deploy": "gh-pages -d build",
5051
"build": "craco build",
5152
"test": "jest",
52-
"e2e_test": "./node_modules/.bin/jest e2e.test.js --no-sandbox"
53+
"e2e_test": "jest e2e --no-sandbox"
5354
},
5455
"eslintConfig": {
5556
"extends": "react-app"

0 commit comments

Comments
 (0)