-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathsession-state-lifecycle.e2e.ts
More file actions
125 lines (101 loc) · 3.99 KB
/
session-state-lifecycle.e2e.ts
File metadata and controls
125 lines (101 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import * as path from 'path';
import * as fs from 'fs';
import JSZip from 'jszip';
import { MINIMAL_501_SESSION } from './configTestUtils';
import { downloadFile, waitForFileExists } from './utils';
import { setValueVueInput, volViewPage } from '../pageobjects/volview.page';
import { TEMP_DIR } from '../../wdio.shared.conf';
const SESSION_SAVE_TIMEOUT = 40000;
const saveSession = async () => {
const sessionFileName = await volViewPage.saveSession();
const downloadedPath = path.join(TEMP_DIR, sessionFileName);
await waitForFileExists(downloadedPath, SESSION_SAVE_TIMEOUT);
return sessionFileName;
};
const parseManifest = async (sessionFileName: string) => {
const session = fs.readFileSync(path.join(TEMP_DIR, sessionFileName));
const zip = await JSZip.loadAsync(session);
const manifestFile = await zip.files['manifest.json'].async('string');
return JSON.parse(manifestFile);
};
const saveAndParseManifest = async () => {
const session = await saveSession();
let manifest: Record<string, unknown> = {};
await browser.waitUntil(async () => {
try {
manifest = await parseManifest(session);
return manifest.version !== undefined;
} catch {
return false;
}
});
return { session, manifest };
};
const loadSession = async () => {
await downloadFile(MINIMAL_501_SESSION.url, MINIMAL_501_SESSION.name);
const urlParams = `?urls=[tmp/${MINIMAL_501_SESSION.name}]`;
await volViewPage.open(urlParams);
await volViewPage.waitForViews();
};
describe('Session state lifecycle', () => {
it('migrates 5.0.1 session with rectangle, polygons, and labelmap', async () => {
await loadSession();
const notifications = await volViewPage.getNotificationsCount();
expect(notifications).toEqual(0);
const annotationsTab = await $(
'button[data-testid="module-tab-Annotations"]'
);
await annotationsTab.click();
const measurementsTab = await $('button.v-tab*=Measurements');
await measurementsTab.waitForClickable();
await measurementsTab.click();
await browser.waitUntil(async () => {
const rectangleEntries = await $$(
'.v-list-item i.mdi-vector-square.tool-icon'
);
return (await rectangleEntries.length) >= 1;
});
await browser.waitUntil(async () => {
const polygonEntries = await $$(
'.v-list-item i.mdi-pentagon-outline.tool-icon'
);
return (await polygonEntries.length) >= 1;
});
const segmentGroupsTab = await $('button.v-tab*=Segment Groups');
await segmentGroupsTab.waitForClickable();
await segmentGroupsTab.click();
await browser.waitUntil(async () => {
const segmentGroups = await $$('.segment-group-list .v-list-item');
return (await segmentGroups.length) >= 1;
});
});
it('edited label strokeWidth persists through save/load cycle', async () => {
await loadSession();
const editedStrokeWidth = 9;
// Activate rectangle tool to show RectangleControls with LabelControls
await volViewPage.activateRectangle();
const annotationsTab = await $(
'button[data-testid="module-tab-Annotations"]'
);
await annotationsTab.click();
await browser.waitUntil(async () => {
const buttons = await volViewPage.editLabelButtons;
return (await buttons.length) >= 1;
});
const buttons = await volViewPage.editLabelButtons;
await buttons[0].click();
const input = await volViewPage.labelStrokeWidthInput;
await setValueVueInput(input, editedStrokeWidth.toString());
const done = await volViewPage.editLabelModalDoneButton;
await done.click();
const { session } = await saveAndParseManifest();
const sessionZip = `?urls=[tmp/${session}]`;
await volViewPage.open(sessionZip);
await volViewPage.waitForViews();
const { manifest: reloadedManifest } = await saveAndParseManifest();
const tools = reloadedManifest.tools as {
rectangles: { tools: Array<{ strokeWidth: number }> };
};
expect(tools.rectangles.tools[0].strokeWidth).toEqual(editedStrokeWidth);
});
});