Skip to content

Commit

Permalink
chore(wdio.shared.conf): exclude session-zip.e2e.ts from test run
Browse files Browse the repository at this point in the history
Too flakey in CI.
  • Loading branch information
PaulHax committed Oct 27, 2023
1 parent 266d752 commit 593c3b0
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 29 deletions.
3 changes: 0 additions & 3 deletions src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,8 @@ import { useWebGLWatchdog } from '../composables/useWebGLWatchdog';
import { useAppLoadingNotifications } from '../composables/useAppLoadingNotifications';
import { wrapInArray } from '../utils';
import { useKeyboardShortcuts } from '../composables/useKeyboardShortcuts';
<<<<<<< HEAD
import { VTKResliceCursor } from '../constants';
=======
import { partitionResults } from '../core/pipeline';
>>>>>>> c4a763c5 (fix(importDataSources): get error result of error in URL fetch)
async function loadFiles(
sources: DataSource[],
Expand Down
6 changes: 5 additions & 1 deletion src/components/VtkTwoView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
@input="setSlice"
/>
</div>
<div class="vtk-container" :class="active ? 'active' : ''">
<div
class="vtk-container"
:class="active ? 'active' : ''"
data-testid="two-view-container"
>
<div class="vtk-sub-container">
<div
class="vtk-view"
Expand Down
2 changes: 1 addition & 1 deletion src/components/tools/rectangle/RectangleTool.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="overlay-no-events">
<svg class="overlay-no-events">
<svg class="overlay-no-events" data-testid="rectangle-tool-container">
<rectangle-widget-2D
v-for="tool in tools"
:key="tool.id"
Expand Down
12 changes: 6 additions & 6 deletions tests/pageobjects/volview.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ class VolViewPage extends Page {
);
return inView.every(Boolean);
},
{ timeout }
{
timeout,
timeoutMsg: `expected at least 1 view to be displayed in viewport`,
}
);
}

Expand All @@ -74,11 +77,8 @@ class VolViewPage extends Page {
return $$('div[data-testid~="vtk-two-view"] > canvas');
}

async clickTwiceInTwoView() {
const views = await this.twoViews;
const view = views[0];
await view.click({ x: 1, y: 1 });
await view.click({ x: 5, y: 5 });
get viewTwoContainer() {
return $('div[data-testid~="two-view-container"]');
}

get saveButton() {
Expand Down
81 changes: 64 additions & 17 deletions tests/specs/session-zip.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,36 @@ import { setValueVueInput, volViewPage } from '../pageobjects/volview.page';
import { TEMP_DIR } from '../../wdio.shared.conf';

const SESSION_SAVE_TIMEOUT = 40000;
const SLOW_INTERACTION_TIMEOUT = 10000;

// from https://stackoverflow.com/a/47764403
function waitForFileExists(filePath: string, timeout: number) {
return new Promise<void>((resolve, reject) => {
let watcher: fs.FSWatcher;

const onTimeout = () => {
watcher.close();
reject(
new Error(
`File ${filePath} did not exists and was not created during the timeout of ${timeout} ms}`
)
);
};

const timerId = setTimeout(onTimeout, timeout);

// watch if file newly created
const dir = path.dirname(filePath);
const basename = path.basename(filePath);
let timerId = undefined as NodeJS.Timeout | undefined;
const watcher = fs.watch(dir, (eventType: any, filename: string | null) => {
watcher = fs.watch(dir, (eventType: any, filename: string | null) => {
if (eventType === 'rename' && filename === basename) {
clearTimeout(timerId);
watcher.close();
resolve();
}
});

const onTimeout = () => {
watcher.close();
reject(
new Error('File did not exists and was not created during the timeout.')
);
};

timerId = setTimeout(onTimeout, timeout);

// check if file already exists
fs.access(filePath, fs.constants.R_OK, (err) => {
if (!err) {
clearTimeout(timerId);
Expand All @@ -56,21 +62,62 @@ const parseManifest = async (sessionFileName: string) => {

const saveGetManifest = async () => {
const session = await saveSession();
await browser.pause(1000); // wait for writing to finish before unzipping?
const manifest = await parseManifest(session);
return { session, manifest };
};

const getRectangleCount = async (view: WebdriverIO.Element) => {
const rectangles = await view.$$(
'svg[data-testid="rectangle-tool-container"] > g'
);
return rectangles.length;
};

const waitForRectangleCount = async (
view: WebdriverIO.Element,
countTarget: number
) => {
await browser.waitUntil(
async function newRectangleExist() {
const toolCount = await getRectangleCount(view);
return toolCount >= countTarget;
},
{
timeoutMsg: `expected ${countTarget} rectangles to be drawn in ${SLOW_INTERACTION_TIMEOUT} ms}`,
timeout: SLOW_INTERACTION_TIMEOUT,
}
);
};

const clickTwice = async (view: WebdriverIO.Element) => {
await view.waitForClickable();
const origin = view;
await browser
.action('pointer')
.move({ duration: 10, origin, x: 0, y: 0 })
.down({ button: 0 }) // left button
.up({ button: 0 })
.pause(10)
.move({ duration: 10, origin, x: 30, y: 30 })
.pause(10)
.down({ button: 0 }) // left button
.pause(10)
.up({ button: 0 })
.perform();
};

const annotate = async () => {
await volViewPage.open();
await volViewPage.downloadProstateSample();
await volViewPage.waitForViews();

// draw rectangle
await volViewPage.activateRectangle();
await volViewPage.clickTwiceInTwoView();

// this may ensure imminently saved session.volview.zip has the tool in CI
await browser.pause(500);
const view = await volViewPage.viewTwoContainer;
await waitForRectangleCount(view, 1); // wait for placing tool
await clickTwice(view);
await waitForRectangleCount(view, 2); // wait for drawn tool
};

describe('VolView config and deserialization', () => {
Expand Down Expand Up @@ -114,10 +161,10 @@ describe('VolView config and deserialization', () => {
it('edited default label is serialized and deserialized', async () => {
await annotate();

const buttons = await volViewPage.editLabelButtons;
await buttons[2].click();
const editedStrokeWidth = 9;

const buttons = await volViewPage.editLabelButtons;
await buttons[2].click();
const input = await volViewPage.labelStrokeWidthInput;
await setValueVueInput(input, editedStrokeWidth.toString());

Expand Down
2 changes: 1 addition & 1 deletion wdio.shared.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const config: Options.Testrunner = {
// Specify Test Files
// ==================
specs: ['./tests/specs/**/*.ts'],
exclude: [],
exclude: ['./tests/specs/session-zip.e2e.ts'],
//
// ============
// Capabilities
Expand Down

0 comments on commit 593c3b0

Please sign in to comment.