Skip to content

Commit bbcff37

Browse files
committed
fix(restoreStateFile): set dataID based on primarySelection
Also fix restoring segment groups
1 parent 18b5c35 commit bbcff37

4 files changed

Lines changed: 45 additions & 21 deletions

File tree

src/io/import/processors/restoreStateFile.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,15 @@ const migrate501To600 = (inputManifest: any) => {
191191
migratedView.type = 'Oblique';
192192
}
193193

194-
// Set dataID based on whether the view has config with data
195-
// In 5.0.1, if a view has config entries, it means it's associated with that data
196-
if (migratedView.config && Object.keys(migratedView.config).length > 0) {
197-
// Use the first (and typically only) key from config as the dataID
198-
migratedView.dataID = Object.keys(migratedView.config)[0];
199-
} else {
200-
migratedView.dataID = null;
194+
const configKeys = Object.keys(migratedView.config || {});
195+
const primarySelection = manifest.primarySelection;
196+
197+
migratedView.dataID = null;
198+
if (configKeys.length > 0) {
199+
migratedView.dataID =
200+
primarySelection && configKeys.includes(primarySelection)
201+
? primarySelection
202+
: configKeys[0];
201203
}
202204

203205
manifest.viewByID[migratedView.id] = migratedView;

src/store/view-configs/layers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ function getPreset(id: string) {
2727
const layersStore = useLayersStore();
2828
const layer = layersStore.getLayer(id);
2929
if (!layer) {
30-
throw new Error(`Layer ${id} not found`);
30+
// Return default preset if layer not found (e.g., for segment groups)
31+
return LAYER_PRESET_DEFAULT;
3132
}
3233

3334
if (isDicomImage(layer.selection)) {

tests/specs/state-manifest.e2e.ts

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,23 @@ async function openVolViewPage(fileName: string) {
3030

3131
// Check that no placeholder overlays are visible (mdi-image-off icons)
3232
// The overlays are in divs that are shown/hidden based on imageID
33-
const visibleOverlayCount = await browser.execute(() => {
34-
const imageOffIcons = document.querySelectorAll('i.mdi-image-off');
35-
return Array.from(imageOffIcons).filter((icon) => {
36-
const parent = icon.closest('div.overlay');
37-
if (!parent) return false;
38-
const style = window.getComputedStyle(parent);
39-
return style.display !== 'none' && style.visibility !== 'hidden';
40-
}).length;
41-
});
42-
43-
expect(visibleOverlayCount).toEqual(0);
33+
await browser.waitUntil(
34+
async () => {
35+
const visibleOverlayCount = await browser.execute(() => {
36+
const imageOffIcons = document.querySelectorAll('i.mdi-image-off');
37+
return Array.from(imageOffIcons).filter((icon) => {
38+
const parent = icon.closest('div.overlay');
39+
if (!parent) return false;
40+
const style = window.getComputedStyle(parent);
41+
return style.display !== 'none' && style.visibility !== 'hidden';
42+
}).length;
43+
});
44+
return visibleOverlayCount === 0;
45+
},
46+
{
47+
timeoutMsg: 'Image placeholder overlays are still visible',
48+
}
49+
);
4450
}
4551

4652
describe('State file manifest.json code', () => {
@@ -54,10 +60,25 @@ describe('State file manifest.json code', () => {
5460
await openVolViewPage(fileName);
5561
});
5662

57-
it('has no errors loading manifest with axial layer layout', async () => {
63+
it('loads 5.0.1 manifest with axial layer layout', async () => {
5864
const manifestPath = path.join(FIXTURES, 'layer-axial.5-0-1.volview.json');
5965
const fileName = 'temp-layer-axial.volview.zip';
6066
await writeManifestToZip(manifestPath, fileName);
6167
await openVolViewPage(fileName);
68+
69+
// Switch to the Rendering tab
70+
const renderingTab = await $('button[data-testid="module-tab-Rendering"]');
71+
await renderingTab.click();
72+
73+
// Wait for and verify that the layer opacity slider is visible
74+
await browser.waitUntil(
75+
async () => {
76+
const layerSlider = await $('[data-testid="layer-opacity-slider"]');
77+
return layerSlider.isDisplayed();
78+
},
79+
{
80+
timeoutMsg: 'Layer opacity slider is not visible in the Rendering tab',
81+
}
82+
);
6283
});
6384
});

wdio.shared.conf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const WINDOW_SIZE = [1200, 800] as const;
77
export const TEST_PORT = 4567;
88
// for slow connections try:
99
// DOWNLOAD_TIMEOUT=60000 && npm run test:e2e:dev
10-
export const DOWNLOAD_TIMEOUT = Number(process.env.DOWNLOAD_TIMEOUT ?? 30000);
10+
export const DOWNLOAD_TIMEOUT = Number(process.env.DOWNLOAD_TIMEOUT ?? 60000);
1111

1212
const ROOT = projectRoot();
1313
const TMP = '.tmp/';

0 commit comments

Comments
 (0)