Skip to content

Commit 41d8a09

Browse files
committed
chore: speed up e2e tests
1 parent e6ffdaf commit 41d8a09

File tree

5 files changed

+87
-48
lines changed

5 files changed

+87
-48
lines changed

.github/workflows/e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
name: E2E Testing on ${{ matrix.os }}
1111
runs-on: ${{ matrix.os }}
1212
env:
13-
DOWNLOAD_TIMEOUT: 220000
13+
DOWNLOAD_TIMEOUT: 60000
1414
VITE_SHOW_SAMPLE_DATA: true
1515
steps:
1616
- uses: actions/checkout@v4
Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,35 @@ import { volViewPage } from '../pageobjects/volview.page';
33
import { openUrls } from './utils';
44
import { PROSTATEX_DATASET, MRA_HEAD_NECK_DATASET } from './configTestUtils';
55

6-
describe('Add Layer button', () => {
6+
describe('Layers and Rendering', () => {
7+
it('should show 3D rendering controls regardless of active view', async () => {
8+
await openUrls([PROSTATEX_DATASET]);
9+
10+
await volViewPage.waitForViews();
11+
12+
const renderTab = volViewPage.renderingModuleTab;
13+
await renderTab.click();
14+
15+
const view3D = await volViewPage.getView3D();
16+
17+
const volumeRenderingSection =
18+
await volViewPage.getVolumeRenderingSection();
19+
await expect(volumeRenderingSection).toExist();
20+
await expect(volumeRenderingSection).toBeDisplayed();
21+
22+
const pwfCanvas = await $('div.pwf-editor canvas');
23+
await expect(pwfCanvas).toExist();
24+
25+
await view3D!.click();
26+
await expect(volumeRenderingSection).toBeDisplayed();
27+
28+
const view2D = await volViewPage.getView2D();
29+
await view2D!.click();
30+
31+
await expect(volumeRenderingSection).toBeDisplayed();
32+
await expect(pwfCanvas).toExist();
33+
});
34+
735
it('should create overlay with 2 DICOM images', async () => {
836
await openUrls([PROSTATEX_DATASET, MRA_HEAD_NECK_DATASET]);
937

tests/specs/rendering-controls-3d-view.e2e.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
import AppPage from '../pageobjects/volview.page';
22

3-
// handle pixel jitter in 3D view
4-
const THRESHOLD = 12; // percent
3+
const THRESHOLD = 12; // percent - handle pixel jitter in 3D view
4+
const RENDER_STABLE_TIMEOUT = 5000;
55

66
describe('VolView', () => {
77
it('should load and render a sample dataset', async () => {
88
await AppPage.open();
99
await AppPage.downloadProstateSample();
1010
await AppPage.waitForViews();
11-
await browser.pause(5000);
1211

1312
const layoutContainer = await $('.layout-container');
1413

15-
const result = await browser.checkElement(
16-
layoutContainer,
17-
'prostate_sample_views'
14+
await browser.waitUntil(
15+
async () => {
16+
const result = await browser.checkElement(
17+
layoutContainer,
18+
'prostate_sample_views'
19+
);
20+
return (result as number) < THRESHOLD;
21+
},
22+
{
23+
timeout: RENDER_STABLE_TIMEOUT,
24+
interval: 500,
25+
timeoutMsg: `Visual comparison exceeded ${THRESHOLD}% threshold after ${RENDER_STABLE_TIMEOUT}ms`,
26+
}
1827
);
19-
20-
await expect(result).toBeLessThan(THRESHOLD);
2128
});
2229
});

wdio.shared.conf.ts

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,33 @@ import * as fs from 'fs';
33
import type { Options, Capabilities } from '@wdio/types';
44
import { projectRoot } from './tests/e2eTestUtils';
55

6+
const TEST_DATASETS = [
7+
{
8+
url: 'https://data.kitware.com/api/v1/file/6566aa81c5a2b36857ad1783/download',
9+
name: 'CT000085.dcm',
10+
},
11+
{
12+
url: 'https://data.kitware.com/api/v1/file/68e9807dbf0f869935e36481/download',
13+
name: 'minimal.dcm',
14+
},
15+
{
16+
url: 'https://data.kitware.com/api/v1/file/655d42a094ef39bf0a4a8bb3/download',
17+
name: '1-001.dcm',
18+
},
19+
{
20+
url: 'https://data.kitware.com/api/v1/item/63527c7311dab8142820a338/download',
21+
name: 'prostate.zip',
22+
},
23+
{
24+
url: 'https://data.kitware.com/api/v1/item/6352a2b311dab8142820a33b/download',
25+
name: 'MRA-Head_and_Neck.zip',
26+
},
27+
{
28+
url: 'https://data.kitware.com/api/v1/item/635679c311dab8142820a4f4/download',
29+
name: 'fetus.zip',
30+
},
31+
];
32+
633
export const WINDOW_SIZE = [1200, 800] as const;
734
export const TEST_PORT = 4567;
835
// for slow connections try:
@@ -39,8 +66,8 @@ export const config: Options.Testrunner = {
3966
// ===================
4067
logLevel: 'warn',
4168
bail: 0,
42-
waitforTimeout: 30000,
43-
connectionRetryTimeout: 120000,
69+
waitforTimeout: 10000,
70+
connectionRetryTimeout: 30000,
4471
connectionRetryCount: 3,
4572
services: [
4673
[
@@ -72,15 +99,26 @@ export const config: Options.Testrunner = {
7299
reporters: ['spec', 'html-nice'],
73100
mochaOpts: {
74101
ui: 'bdd',
75-
timeout: 160 * 1000,
102+
timeout: 60000,
76103
},
77104

78105
//
79106
// Hooks
80107
//
81108

82-
onPrepare() {
109+
async onPrepare() {
83110
fs.mkdirSync(TEMP_DIR, { recursive: true });
111+
112+
const downloads = TEST_DATASETS.map(async ({ url, name }) => {
113+
const savePath = path.join(TEMP_DIR, name);
114+
if (fs.existsSync(savePath)) {
115+
return;
116+
}
117+
const response = await fetch(url);
118+
const data = await response.arrayBuffer();
119+
fs.writeFileSync(savePath, Buffer.from(data));
120+
});
121+
await Promise.all(downloads);
84122
},
85123

86124
async before(

0 commit comments

Comments
 (0)