Skip to content

Commit 1240cda

Browse files
committed
prepare testing bbox related actions
1 parent 408d02e commit 1240cda

File tree

2 files changed

+75
-60
lines changed

2 files changed

+75
-60
lines changed

frontend/javascripts/test/fixtures/dataset_server_object.ts

Lines changed: 60 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,63 @@
11
import { UnitLong } from "viewer/constants";
2-
import type { APIDataset } from "types/api_types";
2+
import type { APIColorLayer, APIDataset, APISegmentationLayer } from "types/api_types";
3+
4+
const sampleColorLayer: APIColorLayer = {
5+
name: "color",
6+
category: "color",
7+
boundingBox: {
8+
topLeft: [0, 0, 0],
9+
width: 10240,
10+
height: 10240,
11+
depth: 10240,
12+
},
13+
resolutions: [
14+
[1, 1, 1],
15+
[2, 2, 2],
16+
[32, 32, 32],
17+
[4, 4, 4],
18+
[8, 8, 8],
19+
[16, 16, 16],
20+
],
21+
elementClass: "uint8",
22+
additionalAxes: [],
23+
};
24+
25+
const sampleSegmentationLayer: APISegmentationLayer = {
26+
name: "segmentation",
27+
category: "segmentation",
28+
boundingBox: {
29+
topLeft: [0, 0, 0],
30+
width: 10240,
31+
height: 10240,
32+
depth: 10240,
33+
},
34+
resolutions: [
35+
[1, 1, 1],
36+
[2, 2, 2],
37+
[32, 32, 32],
38+
[4, 4, 4],
39+
[8, 8, 8],
40+
[16, 16, 16],
41+
],
42+
elementClass: "uint32",
43+
largestSegmentId: 1000000000,
44+
mappings: [
45+
"larger5um1",
46+
"axons",
47+
"astrocyte-ge-7",
48+
"astrocyte",
49+
"mitochondria",
50+
"astrocyte-full",
51+
],
52+
tracingId: undefined,
53+
additionalAxes: [],
54+
};
55+
56+
export const sampleTracingLayer: APISegmentationLayer = {
57+
...sampleSegmentationLayer,
58+
name: "tracingId",
59+
tracingId: "tracingId",
60+
};
361

462
const apiDataset: APIDataset = {
563
id: "66f3c82966010034942e9740",
@@ -9,58 +67,7 @@ const apiDataset: APIDataset = {
967
name: "ROI2017_wkw",
1068
team: "Connectomics department",
1169
},
12-
dataLayers: [
13-
{
14-
name: "color",
15-
category: "color",
16-
boundingBox: {
17-
topLeft: [0, 0, 0],
18-
width: 10240,
19-
height: 10240,
20-
depth: 10240,
21-
},
22-
resolutions: [
23-
[1, 1, 1],
24-
[2, 2, 2],
25-
[32, 32, 32],
26-
[4, 4, 4],
27-
[8, 8, 8],
28-
[16, 16, 16],
29-
],
30-
elementClass: "uint8",
31-
additionalAxes: [],
32-
},
33-
{
34-
name: "segmentation",
35-
category: "segmentation",
36-
boundingBox: {
37-
topLeft: [0, 0, 0],
38-
width: 10240,
39-
height: 10240,
40-
depth: 10240,
41-
},
42-
resolutions: [
43-
[1, 1, 1],
44-
[2, 2, 2],
45-
[32, 32, 32],
46-
[4, 4, 4],
47-
[8, 8, 8],
48-
[16, 16, 16],
49-
],
50-
elementClass: "uint32",
51-
largestSegmentId: 1000000000,
52-
mappings: [
53-
"larger5um1",
54-
"axons",
55-
"astrocyte-ge-7",
56-
"astrocyte",
57-
"mitochondria",
58-
"astrocyte-full",
59-
],
60-
tracingId: undefined,
61-
additionalAxes: [],
62-
},
63-
],
70+
dataLayers: [sampleColorLayer, sampleSegmentationLayer],
6471
scale: { factor: [11.239999771118164, 11.239999771118164, 28], unit: UnitLong.nm },
6572
},
6673
dataStore: {

frontend/javascripts/test/reducers/update_action_application/skeleton.spec.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import update from "immutability-helper";
22
import _ from "lodash";
3+
import { sampleTracingLayer } from "test/fixtures/dataset_server_object";
34
import { initialState as defaultState } from "test/fixtures/hybridtracing_object";
45
import { chainReduce } from "test/helpers/chainReducer";
56
import type { Vector3 } from "viewer/constants";
@@ -18,7 +19,7 @@ import type {
1819
ApplicableSkeletonUpdateAction,
1920
UpdateActionWithoutIsolationRequirement,
2021
} from "viewer/model/sagas/update_actions";
21-
import type { WebknossosState } from "viewer/store";
22+
import { combinedReducers, type WebknossosState } from "viewer/store";
2223
import { describe, expect, test, it, afterAll } from "vitest";
2324

2425
const initialState: WebknossosState = update(defaultState, {
@@ -33,14 +34,21 @@ const initialState: WebknossosState = update(defaultState, {
3334
},
3435
annotationType: { $set: "Explorational" },
3536
},
37+
dataset: {
38+
dataSource: {
39+
dataLayers: {
40+
$set: [sampleTracingLayer],
41+
},
42+
},
43+
},
3644
});
3745

3846
const position = [10, 10, 10] as Vector3;
3947
const rotation = [0.5, 0.5, 0.5] as Vector3;
4048
const viewport = 0;
4149
const mag = 0;
4250

43-
const applyActions = chainReduce(SkeletonTracingReducer);
51+
const applyActions = chainReduce(combinedReducers);
4452

4553
const actionNamesList: Record<ApplicableSkeletonUpdateAction["name"], true> = {
4654
updateTree: true,
@@ -67,12 +75,12 @@ describe("Update Action Application for SkeletonTracing", () => {
6775
/*
6876
* Hardcode these values if you want to focus on a specific test.
6977
*/
70-
const compactionModes = [false];
71-
const hardcodedBeforeVersionIndex: number | null = null; // 14;
72-
const hardcodedAfterVersionIndex: number | null = null; // 26;
78+
const compactionModes = [true, false];
79+
const hardcodedBeforeVersionIndex: number | null = null;
80+
const hardcodedAfterVersionIndex: number | null = null;
7381
// const compactionModes = [true];
74-
// const hardcodedBeforeVersionIndex: number | null = 9; // 14;
75-
// const hardcodedAfterVersionIndex: number | null = 26; // 26;
82+
// const hardcodedBeforeVersionIndex: number | null = 27; // 14;
83+
// const hardcodedAfterVersionIndex: number | null = 28; // 26;
7684

7785
const userActions: SkeletonTracingAction[] = [
7886
SkeletonTracingActions.deleteTreeAction(2), // delete second tree. one tree remains.

0 commit comments

Comments
 (0)