Skip to content

Commit bf2d323

Browse files
committed
test(volume-rendering): check color reset keeps a chosen preset
1 parent 894003e commit bf2d323

3 files changed

Lines changed: 26 additions & 7 deletions

File tree

‎tests/specs/volume-coloring-reset.e2e.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import {
44
differingFraction,
55
floatVoxels,
66
nrrd,
7+
showColorPresets,
78
openWith3DLayout,
9+
selectedPreset,
810
writeNrrd,
911
} from './volumeTestUtils';
1012

@@ -84,7 +86,7 @@ describe('3D rendering color and opacity reset', () => {
8486
return Math.max(0, 1000 * (1 - Math.hypot(...offsets) / (SIZE / 2)));
8587
});
8688
await openWith3DLayout(
87-
writeNrrd(name, nrrd([], 'float', SIZE), voxels),
89+
writeNrrd(name, nrrd(['modality:=MR'], 'float', SIZE), voxels),
8890
name
8991
);
9092
await volViewPage.renderingModuleTab.waitForClickable();
@@ -97,6 +99,13 @@ describe('3D rendering color and opacity reset', () => {
9799
'Reset color and opacity'
98100
);
99101

102+
// Reset must keep a preset chosen over the MR default.
103+
await showColorPresets();
104+
await $('.thumbnail-container*=Grayscale').click();
105+
await expect(selectedPreset()).toHaveText('Grayscale');
106+
// The open preset grid pushes the opacity editor out of the capture area.
107+
await showColorPresets(false);
108+
100109
// A gaussian stays highlighted once clicked, so select it before the baseline.
101110
await dragOpacityCurve(0);
102111
await pressOn(ambientThumb(), 'ArrowRight');
@@ -134,5 +143,7 @@ describe('3D rendering color and opacity reset', () => {
134143
'Expected reset to restore the opacity curve and color bar'
135144
);
136145
await expect(ambientThumb()).toHaveAttribute('aria-valuenow', '0.3');
146+
await showColorPresets();
147+
await expect(selectedPreset()).toHaveText('Grayscale');
137148
}).timeout(180_000);
138149
});

‎tests/specs/volume-modality-presets.e2e.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import {
1212
differingFraction,
1313
floatVoxels,
1414
nrrd,
15+
showColorPresets,
1516
openWith3DLayout,
17+
selectedPreset,
1618
writeNrrd,
1719
} from './volumeTestUtils';
1820

@@ -61,12 +63,8 @@ async function expectSelectedPreset(label: string) {
6163
await volViewPage.renderingModuleTab.waitForClickable();
6264
await volViewPage.renderingModuleTab.click();
6365
await waitForModuleTransitions();
64-
const title = $('.v-expansion-panel-title*=Color Presets');
65-
await title.scrollIntoView({ block: 'center', behavior: 'instant' });
66-
if ((await title.getAttribute('aria-expanded')) !== 'true') {
67-
await title.click();
68-
}
69-
await expect($('.thumbnail-container.bg-blue')).toHaveText(label);
66+
await showColorPresets();
67+
await expect(selectedPreset()).toHaveText(label);
7068
}
7169

7270
describe('volume preset from declared modality', () => {

‎tests/specs/volumeTestUtils.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ export function writeNrrd(name: string, header: string, voxels: Buffer) {
4444
return `tmp/${name}/${name}.nrrd`;
4545
}
4646

47+
export async function showColorPresets(show = true) {
48+
const title = $('.v-expansion-panel-title*=Color Presets');
49+
await title.scrollIntoView({ block: 'center', behavior: 'instant' });
50+
if (((await title.getAttribute('aria-expanded')) === 'true') !== show) {
51+
await title.click();
52+
}
53+
}
54+
55+
export const selectedPreset = () => $('.thumbnail-container.bg-blue');
56+
4757
export async function openWith3DLayout(dataUrl: string, name: string) {
4858
const config = `${name}-layout.json`;
4959
await writeManifestToFile(LAYOUT, config);

0 commit comments

Comments
 (0)