@geode/opengeodeweb-front 9.12.2-rc.1 → 9.12.2-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/components/Viewer/TreeComponent.vue +28 -8
  2. package/internal_stores/data_style_state.js +6 -1
  3. package/internal_stores/mesh/edges.js +18 -8
  4. package/internal_stores/mesh/index.js +21 -20
  5. package/internal_stores/mesh/points.js +22 -9
  6. package/internal_stores/mesh/polygons.js +26 -8
  7. package/internal_stores/mesh/polyhedra.js +19 -8
  8. package/internal_stores/model/blocks.js +71 -31
  9. package/internal_stores/model/corners.js +69 -32
  10. package/internal_stores/model/edges.js +16 -10
  11. package/internal_stores/model/index.js +117 -77
  12. package/internal_stores/model/lines.js +53 -36
  13. package/internal_stores/model/points.js +23 -16
  14. package/internal_stores/model/surfaces.js +63 -29
  15. package/package.json +1 -1
  16. package/stores/data_base.js +18 -32
  17. package/stores/data_style.js +18 -30
  18. package/stores/hybrid_viewer.js +12 -6
  19. package/stores/treeview.js +2 -3
  20. package/tests/integration/data/uploads/test.og_brep +0 -0
  21. package/tests/integration/microservices/viewer/requirements.txt +1 -1
  22. package/tests/integration/setup.js +16 -31
  23. package/tests/integration/stores/data_style/mesh/edges.nuxt.test.js +27 -13
  24. package/tests/integration/stores/data_style/mesh/index.nuxt.test.js +66 -0
  25. package/tests/integration/stores/data_style/mesh/points.nuxt.test.js +47 -13
  26. package/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js +27 -13
  27. package/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js +26 -13
  28. package/tests/integration/stores/data_style/model/blocks.nuxt.test.js +92 -0
  29. package/tests/integration/stores/data_style/model/corners.nuxt.test.js +92 -0
  30. package/tests/integration/stores/data_style/model/edges.nuxt.test.js +57 -0
  31. package/tests/integration/stores/data_style/model/index.nuxt.test.js +57 -0
  32. package/tests/integration/stores/data_style/model/lines.nuxt.test.js +83 -0
  33. package/tests/integration/stores/data_style/model/points.nuxt.test.js +73 -0
  34. package/tests/integration/stores/data_style/model/surfaces.nuxt.test.js +96 -0
  35. package/tests/vitest.config.js +2 -1
  36. package/utils/default_styles.js +19 -7
  37. package/utils/file_import_workflow.js +82 -0
  38. package/tests/integration/utils.js +0 -35
@@ -1,5 +1,3 @@
1
- // Node.js imports
2
-
3
1
  // Third party imports
4
2
  import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"
5
3
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" with { type: "json" }
@@ -9,26 +7,30 @@ import Status from "~/utils/status"
9
7
  import * as composables from "~/composables/viewer_call"
10
8
  import { useDataStyleStore } from "~/stores/data_style"
11
9
  import { useViewerStore } from "~/stores/viewer"
12
- import { kill_back, kill_viewer } from "~/utils/local"
10
+ import { delete_folder_recursive, kill_back, kill_viewer } from "~/utils/local"
13
11
  import { setupIntegrationTests } from "../../../setup.js"
14
12
 
15
13
  // Local constants
16
14
  const mesh_points_schemas = viewer_schemas.opengeodeweb_viewer.mesh.points
17
- let id, back_port, viewer_port
18
15
  const file_name = "test.og_edc2d"
19
16
  const geode_object = "EdgedCurve2D"
20
- const object_type = "mesh"
17
+
18
+ let id, back_port, viewer_port, project_folder_path
21
19
 
22
20
  beforeEach(async () => {
23
- ;({ id, back_port, viewer_port } = await setupIntegrationTests(
24
- file_name,
25
- geode_object,
26
- object_type,
27
- ))
21
+ ;({ id, back_port, viewer_port, project_folder_path } =
22
+ await setupIntegrationTests(file_name, geode_object))
28
23
  }, 20000)
29
24
 
30
25
  afterEach(async () => {
26
+ console.log(
27
+ "afterEach mesh points kill",
28
+ back_port,
29
+ viewer_port,
30
+ project_folder_path,
31
+ )
31
32
  await Promise.all([kill_back(back_port), kill_viewer(viewer_port)])
33
+ delete_folder_recursive(project_folder_path)
32
34
  })
33
35
 
34
36
  describe("Mesh points", () => {
@@ -36,8 +38,19 @@ describe("Mesh points", () => {
36
38
  test("Visibility true", async () => {
37
39
  const dataStyleStore = useDataStyleStore()
38
40
  const viewerStore = useViewerStore()
39
- await dataStyleStore.setMeshPointsVisibility(id, true)
40
- expect(dataStyleStore.meshPointsVisibility(id)).toBe(true)
41
+ const visibility = true
42
+ const spy = vi.spyOn(composables, "viewer_call")
43
+ await dataStyleStore.setMeshPointsVisibility(id, visibility)
44
+ expect(spy).toHaveBeenCalledWith(
45
+ {
46
+ schema: mesh_points_schemas.visibility,
47
+ params: { id, visibility },
48
+ },
49
+ {
50
+ response_function: expect.any(Function),
51
+ },
52
+ )
53
+ expect(dataStyleStore.meshPointsVisibility(id)).toBe(visibility)
41
54
  expect(viewerStore.status).toBe(Status.CONNECTED)
42
55
  })
43
56
  })
@@ -57,7 +70,7 @@ describe("Mesh points", () => {
57
70
  })
58
71
  })
59
72
  describe("Points color", () => {
60
- test("test red", async () => {
73
+ test("Color red", async () => {
61
74
  const dataStyleStore = useDataStyleStore()
62
75
  const viewerStore = useViewerStore()
63
76
  const color = { r: 255, g: 0, b: 0 }
@@ -76,4 +89,25 @@ describe("Mesh points", () => {
76
89
  expect(viewerStore.status).toBe(Status.CONNECTED)
77
90
  })
78
91
  })
92
+
93
+ describe("Points size", () => {
94
+ test("Size 20", async () => {
95
+ const dataStyleStore = useDataStyleStore()
96
+ const viewerStore = useViewerStore()
97
+ const size = 20
98
+ const spy = vi.spyOn(composables, "viewer_call")
99
+ await dataStyleStore.setMeshPointsSize(id, size)
100
+ expect(spy).toHaveBeenCalledWith(
101
+ {
102
+ schema: mesh_points_schemas.size,
103
+ params: { id, size },
104
+ },
105
+ {
106
+ response_function: expect.any(Function),
107
+ },
108
+ )
109
+ expect(dataStyleStore.meshPointsSize(id)).toBe(size)
110
+ expect(viewerStore.status).toBe(Status.CONNECTED)
111
+ })
112
+ })
79
113
  })
@@ -1,5 +1,3 @@
1
- // Node.js imports
2
-
3
1
  // Third party imports
4
2
  import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"
5
3
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" with { type: "json" }
@@ -9,26 +7,31 @@ import Status from "~/utils/status"
9
7
  import * as composables from "~/composables/viewer_call"
10
8
  import { useDataStyleStore } from "~/stores/data_style"
11
9
  import { useViewerStore } from "~/stores/viewer"
12
- import { kill_back, kill_viewer } from "~/utils/local"
10
+ import { delete_folder_recursive, kill_back, kill_viewer } from "~/utils/local"
13
11
  import { setupIntegrationTests } from "../../../setup.js"
14
12
 
15
13
  // Local constants
16
14
  const mesh_polygons_schemas = viewer_schemas.opengeodeweb_viewer.mesh.polygons
17
- let id, back_port, viewer_port
18
15
  const file_name = "test.og_psf3d"
19
16
  const geode_object = "PolygonalSurface3D"
20
- const object_type = "mesh"
17
+
18
+ let id, back_port, viewer_port, project_folder_path
21
19
 
22
20
  beforeEach(async () => {
23
- ;({ id, back_port, viewer_port } = await setupIntegrationTests(
24
- file_name,
25
- geode_object,
26
- object_type,
27
- ))
21
+ ;({ id, back_port, viewer_port, project_folder_path } =
22
+ await setupIntegrationTests(file_name, geode_object))
28
23
  }, 20000)
29
24
 
30
25
  afterEach(async () => {
26
+ console.log(
27
+ "afterEach mesh polygons kill",
28
+ back_port,
29
+ viewer_port,
30
+ project_folder_path,
31
+ )
32
+
31
33
  await Promise.all([kill_back(back_port), kill_viewer(viewer_port)])
34
+ delete_folder_recursive(project_folder_path)
32
35
  })
33
36
 
34
37
  describe("Mesh polygons", () => {
@@ -36,8 +39,19 @@ describe("Mesh polygons", () => {
36
39
  test("Visibility true", async () => {
37
40
  const dataStyleStore = useDataStyleStore()
38
41
  const viewerStore = useViewerStore()
39
- await dataStyleStore.setMeshPolygonsVisibility(id, true)
40
- expect(dataStyleStore.meshPolygonsVisibility(id)).toBe(true)
42
+ const visibility = true
43
+ const spy = vi.spyOn(composables, "viewer_call")
44
+ await dataStyleStore.setMeshPolygonsVisibility(id, visibility)
45
+ expect(spy).toHaveBeenCalledWith(
46
+ {
47
+ schema: mesh_polygons_schemas.visibility,
48
+ params: { id, visibility },
49
+ },
50
+ {
51
+ response_function: expect.any(Function),
52
+ },
53
+ )
54
+ expect(dataStyleStore.meshPolygonsVisibility(id)).toBe(visibility)
41
55
  expect(viewerStore.status).toBe(Status.CONNECTED)
42
56
  })
43
57
  })
@@ -56,7 +70,7 @@ describe("Mesh polygons", () => {
56
70
  })
57
71
  })
58
72
  describe("Polygons color", () => {
59
- test("test red", async () => {
73
+ test("Color red", async () => {
60
74
  const dataStyleStore = useDataStyleStore()
61
75
  const viewerStore = useViewerStore()
62
76
  const color = { r: 255, g: 0, b: 0 }
@@ -1,5 +1,3 @@
1
- // Node.js imports
2
-
3
1
  // Third party imports
4
2
  import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"
5
3
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" with { type: "json" }
@@ -9,26 +7,30 @@ import Status from "~/utils/status"
9
7
  import * as composables from "~/composables/viewer_call"
10
8
  import { useDataStyleStore } from "~/stores/data_style"
11
9
  import { useViewerStore } from "~/stores/viewer"
12
- import { kill_back, kill_viewer } from "~/utils/local"
10
+ import { delete_folder_recursive, kill_back, kill_viewer } from "~/utils/local"
13
11
  import { setupIntegrationTests } from "../../../setup.js"
14
12
 
15
13
  // Local constants
16
14
  const mesh_polyhedra_schemas = viewer_schemas.opengeodeweb_viewer.mesh.polyhedra
17
- let id, back_port, viewer_port
18
15
  const file_name = "test.og_rgd3d"
19
16
  const geode_object = "RegularGrid3D"
20
- const object_type = "mesh"
17
+
18
+ let id, back_port, viewer_port, project_folder_path
21
19
 
22
20
  beforeEach(async () => {
23
- ;({ id, back_port, viewer_port } = await setupIntegrationTests(
24
- file_name,
25
- geode_object,
26
- object_type,
27
- ))
21
+ ;({ id, back_port, viewer_port, project_folder_path } =
22
+ await setupIntegrationTests(file_name, geode_object))
28
23
  }, 20000)
29
24
 
30
25
  afterEach(async () => {
26
+ console.log(
27
+ "afterEach mesh polyhedra kill",
28
+ back_port,
29
+ viewer_port,
30
+ project_folder_path,
31
+ )
31
32
  await Promise.all([kill_back(back_port), kill_viewer(viewer_port)])
33
+ delete_folder_recursive(project_folder_path)
32
34
  })
33
35
 
34
36
  describe("Mesh polyhedra", () => {
@@ -36,8 +38,19 @@ describe("Mesh polyhedra", () => {
36
38
  test("Visibility true", async () => {
37
39
  const dataStyleStore = useDataStyleStore()
38
40
  const viewerStore = useViewerStore()
39
- await dataStyleStore.setMeshPolyhedraVisibility(id, true)
40
- expect(dataStyleStore.meshPolyhedraVisibility(id)).toBe(true)
41
+ const visibility = true
42
+ const spy = vi.spyOn(composables, "viewer_call")
43
+ await dataStyleStore.setMeshPolyhedraVisibility(id, visibility)
44
+ expect(spy).toHaveBeenCalledWith(
45
+ {
46
+ schema: mesh_polyhedra_schemas.visibility,
47
+ params: { id, visibility },
48
+ },
49
+ {
50
+ response_function: expect.any(Function),
51
+ },
52
+ )
53
+ expect(dataStyleStore.meshPolyhedraVisibility(id)).toBe(visibility)
41
54
  expect(viewerStore.status).toBe(Status.CONNECTED)
42
55
  })
43
56
  })
@@ -56,7 +69,7 @@ describe("Mesh polyhedra", () => {
56
69
  })
57
70
  })
58
71
  describe("Polyhedra color", () => {
59
- test("test red", async () => {
72
+ test("Color red", async () => {
60
73
  const dataStyleStore = useDataStyleStore()
61
74
  const viewerStore = useViewerStore()
62
75
  const color = { r: 255, g: 0, b: 0 }
@@ -0,0 +1,92 @@
1
+ // Third party imports
2
+ import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"
3
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" with { type: "json" }
4
+
5
+ // Local imports
6
+ import Status from "~/utils/status"
7
+ import * as composables from "~/composables/viewer_call"
8
+ import { useDataStyleStore } from "~/stores/data_style"
9
+ import { useViewerStore } from "~/stores/viewer"
10
+ import { delete_folder_recursive, kill_back, kill_viewer } from "~/utils/local"
11
+ import { setupIntegrationTests } from "../../../setup.js"
12
+
13
+ // Local constants
14
+ const model_blocks_schemas = viewer_schemas.opengeodeweb_viewer.model.blocks
15
+ const file_name = "test.og_brep"
16
+ const geode_object = "BRep"
17
+
18
+ let id, back_port, viewer_port, project_folder_path
19
+
20
+ beforeEach(async () => {
21
+ ;({ id, back_port, viewer_port, project_folder_path } =
22
+ await setupIntegrationTests(file_name, geode_object))
23
+ }, 20000)
24
+
25
+ afterEach(async () => {
26
+ console.log(
27
+ "afterEach model blocks kill",
28
+ back_port,
29
+ viewer_port,
30
+ project_folder_path,
31
+ )
32
+ await Promise.all([kill_back(back_port), kill_viewer(viewer_port)])
33
+ delete_folder_recursive(project_folder_path)
34
+ })
35
+
36
+ describe("Model blocks", () => {
37
+ describe("Blocks visibility", () => {
38
+ test("Visibility false", async () => {
39
+ const dataStyleStore = useDataStyleStore()
40
+ const viewerStore = useViewerStore()
41
+ const dataBaseStore = useDataBaseStore()
42
+ const block_ids = dataBaseStore.getBlocksUuids(id)
43
+ const block_flat_indexes = dataBaseStore.getFlatIndexes(id, block_ids)
44
+ const visibility = false
45
+ const spy = vi.spyOn(composables, "viewer_call")
46
+ await dataStyleStore.setModelBlocksVisibility(id, block_ids, visibility)
47
+ expect(spy).toHaveBeenCalledWith(
48
+ {
49
+ schema: model_blocks_schemas.visibility,
50
+ params: { id, block_ids: block_flat_indexes, visibility },
51
+ },
52
+ {
53
+ response_function: expect.any(Function),
54
+ },
55
+ )
56
+ for (const block_id of block_ids) {
57
+ expect(dataStyleStore.modelBlockVisibility(id, block_id)).toBe(
58
+ visibility,
59
+ )
60
+ }
61
+ expect(viewerStore.status).toBe(Status.CONNECTED)
62
+ })
63
+ })
64
+
65
+ describe("Blocks color", () => {
66
+ test("Color red", async () => {
67
+ const dataStyleStore = useDataStyleStore()
68
+ const viewerStore = useViewerStore()
69
+ const dataBaseStore = useDataBaseStore()
70
+ const block_ids = dataBaseStore.getBlocksUuids(id)
71
+ const block_flat_indexes = dataBaseStore.getFlatIndexes(id, block_ids)
72
+ const color = { r: 255, g: 0, b: 0 }
73
+ const spy = vi.spyOn(composables, "viewer_call")
74
+ await dataStyleStore.setModelBlocksColor(id, block_ids, color)
75
+ expect(spy).toHaveBeenCalledWith(
76
+ {
77
+ schema: model_blocks_schemas.color,
78
+ params: { id, block_ids: block_flat_indexes, color },
79
+ },
80
+ {
81
+ response_function: expect.any(Function),
82
+ },
83
+ )
84
+ for (const block_id of block_ids) {
85
+ expect(dataStyleStore.modelBlockColor(id, block_id)).toStrictEqual(
86
+ color,
87
+ )
88
+ }
89
+ expect(viewerStore.status).toBe(Status.CONNECTED)
90
+ })
91
+ })
92
+ })
@@ -0,0 +1,92 @@
1
+ // Third party imports
2
+ import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"
3
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" with { type: "json" }
4
+
5
+ // Local imports
6
+ import Status from "~/utils/status"
7
+ import * as composables from "~/composables/viewer_call"
8
+ import { useDataStyleStore } from "~/stores/data_style"
9
+ import { useViewerStore } from "~/stores/viewer"
10
+ import { delete_folder_recursive, kill_back, kill_viewer } from "~/utils/local"
11
+ import { setupIntegrationTests } from "../../../setup.js"
12
+
13
+ // Local constants
14
+ const model_corners_schemas = viewer_schemas.opengeodeweb_viewer.model.corners
15
+ const file_name = "test.og_brep"
16
+ const geode_object = "BRep"
17
+
18
+ let id, back_port, viewer_port, project_folder_path
19
+
20
+ beforeEach(async () => {
21
+ ;({ id, back_port, viewer_port, project_folder_path } =
22
+ await setupIntegrationTests(file_name, geode_object))
23
+ }, 20000)
24
+
25
+ afterEach(async () => {
26
+ console.log(
27
+ "afterEach model corners kill",
28
+ back_port,
29
+ viewer_port,
30
+ project_folder_path,
31
+ )
32
+ await Promise.all([kill_back(back_port), kill_viewer(viewer_port)])
33
+ delete_folder_recursive(project_folder_path)
34
+ })
35
+
36
+ describe("Model corners", () => {
37
+ describe("Corners visibility", () => {
38
+ test("Visibility false", async () => {
39
+ const dataStyleStore = useDataStyleStore()
40
+ const viewerStore = useViewerStore()
41
+ const dataBaseStore = useDataBaseStore()
42
+ const corner_ids = dataBaseStore.getCornersUuids(id)
43
+ const corner_flat_indexes = dataBaseStore.getFlatIndexes(id, corner_ids)
44
+ const visibility = false
45
+ const spy = vi.spyOn(composables, "viewer_call")
46
+ await dataStyleStore.setModelCornersVisibility(id, corner_ids, visibility)
47
+ expect(spy).toHaveBeenCalledWith(
48
+ {
49
+ schema: model_corners_schemas.visibility,
50
+ params: { id, block_ids: corner_flat_indexes, visibility },
51
+ },
52
+ {
53
+ response_function: expect.any(Function),
54
+ },
55
+ )
56
+ for (const corner_id of corner_ids) {
57
+ expect(dataStyleStore.modelCornerVisibility(id, corner_id)).toBe(
58
+ visibility,
59
+ )
60
+ }
61
+ expect(viewerStore.status).toBe(Status.CONNECTED)
62
+ })
63
+ })
64
+
65
+ describe("Corner color", () => {
66
+ test("Color red", async () => {
67
+ const dataStyleStore = useDataStyleStore()
68
+ const viewerStore = useViewerStore()
69
+ const dataBaseStore = useDataBaseStore()
70
+ const corner_ids = dataBaseStore.getCornersUuids(id)
71
+ const corner_flat_indexes = dataBaseStore.getFlatIndexes(id, corner_ids)
72
+ const color = { r: 255, g: 0, b: 0 }
73
+ const spy = vi.spyOn(composables, "viewer_call")
74
+ await dataStyleStore.setModelCornersColor(id, corner_ids, color)
75
+ expect(spy).toHaveBeenCalledWith(
76
+ {
77
+ schema: model_corners_schemas.color,
78
+ params: { id, block_ids: corner_flat_indexes, color },
79
+ },
80
+ {
81
+ response_function: expect.any(Function),
82
+ },
83
+ )
84
+ for (const corner_id of corner_ids) {
85
+ expect(dataStyleStore.modelCornerColor(id, corner_id)).toStrictEqual(
86
+ color,
87
+ )
88
+ }
89
+ expect(viewerStore.status).toBe(Status.CONNECTED)
90
+ })
91
+ })
92
+ })
@@ -0,0 +1,57 @@
1
+ // Third party imports
2
+ import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"
3
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" with { type: "json" }
4
+
5
+ // Local imports
6
+ import Status from "~/utils/status"
7
+ import * as composables from "~/composables/viewer_call"
8
+ import { useDataStyleStore } from "~/stores/data_style"
9
+ import { useViewerStore } from "~/stores/viewer"
10
+ import { delete_folder_recursive, kill_back, kill_viewer } from "~/utils/local"
11
+ import { setupIntegrationTests } from "../../../setup.js"
12
+
13
+ // Local constants
14
+ const model_edges_schemas = viewer_schemas.opengeodeweb_viewer.model.edges
15
+ const file_name = "test.og_brep"
16
+ const geode_object = "BRep"
17
+
18
+ let id, back_port, viewer_port, project_folder_path
19
+
20
+ beforeEach(async () => {
21
+ ;({ id, back_port, viewer_port, project_folder_path } =
22
+ await setupIntegrationTests(file_name, geode_object))
23
+ }, 25000)
24
+
25
+ afterEach(async () => {
26
+ console.log(
27
+ "afterEach model edges kill",
28
+ back_port,
29
+ viewer_port,
30
+ project_folder_path,
31
+ )
32
+ await Promise.all([kill_back(back_port), kill_viewer(viewer_port)])
33
+ delete_folder_recursive(project_folder_path)
34
+ })
35
+
36
+ describe("Model edges", () => {
37
+ describe("Edges visibility", () => {
38
+ test("Visibility true", async () => {
39
+ const dataStyleStore = useDataStyleStore()
40
+ const viewerStore = useViewerStore()
41
+ const visibility = true
42
+ const spy = vi.spyOn(composables, "viewer_call")
43
+ await dataStyleStore.setModelEdgesVisibility(id, visibility)
44
+ expect(spy).toHaveBeenCalledWith(
45
+ {
46
+ schema: model_edges_schemas.visibility,
47
+ params: { id, visibility },
48
+ },
49
+ {
50
+ response_function: expect.any(Function),
51
+ },
52
+ )
53
+ expect(dataStyleStore.modelEdgesVisibility(id)).toBe(visibility)
54
+ expect(viewerStore.status).toBe(Status.CONNECTED)
55
+ })
56
+ })
57
+ })
@@ -0,0 +1,57 @@
1
+ // Third party imports
2
+ import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"
3
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" with { type: "json" }
4
+
5
+ // Local imports
6
+ import Status from "~/utils/status"
7
+ import * as composables from "~/composables/viewer_call"
8
+ import { useDataStyleStore } from "~/stores/data_style"
9
+ import { useViewerStore } from "~/stores/viewer"
10
+ import { delete_folder_recursive, kill_back, kill_viewer } from "~/utils/local"
11
+ import { setupIntegrationTests } from "../../../setup.js"
12
+
13
+ // Local constants
14
+ const model_schemas = viewer_schemas.opengeodeweb_viewer.model
15
+ const file_name = "test.og_brep"
16
+ const geode_object = "BRep"
17
+
18
+ let id, back_port, viewer_port, project_folder_path
19
+
20
+ beforeEach(async () => {
21
+ ;({ id, back_port, viewer_port, project_folder_path } =
22
+ await setupIntegrationTests(file_name, geode_object))
23
+ }, 20000)
24
+
25
+ afterEach(async () => {
26
+ console.log(
27
+ "afterEach model kill",
28
+ back_port,
29
+ viewer_port,
30
+ project_folder_path,
31
+ )
32
+ await Promise.all([kill_back(back_port), kill_viewer(viewer_port)])
33
+ delete_folder_recursive(project_folder_path)
34
+ })
35
+
36
+ describe("Model", () => {
37
+ describe("Model visibility", () => {
38
+ test("Visibility true", async () => {
39
+ const dataStyleStore = useDataStyleStore()
40
+ const viewerStore = useViewerStore()
41
+ const visibility = true
42
+ const spy = vi.spyOn(composables, "viewer_call")
43
+ await dataStyleStore.setModelVisibility(id, visibility)
44
+ expect(spy).toHaveBeenCalledWith(
45
+ {
46
+ schema: model_schemas.visibility,
47
+ params: { id, visibility },
48
+ },
49
+ {
50
+ response_function: expect.any(Function),
51
+ },
52
+ )
53
+ expect(dataStyleStore.modelVisibility(id)).toBe(visibility)
54
+ expect(viewerStore.status).toBe(Status.CONNECTED)
55
+ })
56
+ })
57
+ })
@@ -0,0 +1,83 @@
1
+ // Third party imports
2
+ import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"
3
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" with { type: "json" }
4
+
5
+ // Local imports
6
+ import Status from "~/utils/status"
7
+ import * as composables from "~/composables/viewer_call"
8
+ import { useDataStyleStore } from "~/stores/data_style"
9
+ import { useViewerStore } from "~/stores/viewer"
10
+ import { setupIntegrationTests } from "../../../setup.js"
11
+
12
+ // Local constants
13
+ const model_lines_schemas = viewer_schemas.opengeodeweb_viewer.model.lines
14
+ const file_name = "test.og_brep"
15
+ const geode_object = "BRep"
16
+
17
+ let id, back_port, viewer_port, project_folder_path
18
+
19
+ beforeEach(async () => {
20
+ ;({ id, back_port, viewer_port, project_folder_path } =
21
+ await setupIntegrationTests(file_name, geode_object))
22
+ }, 20000)
23
+
24
+ afterEach(async () => {
25
+ console.log("afterEach model lines kill", back_port, viewer_port)
26
+ await Promise.all([kill_back(back_port), kill_viewer(viewer_port)])
27
+ delete_folder_recursive(project_folder_path)
28
+ })
29
+
30
+ describe("Model lines", () => {
31
+ describe("Lines visibility", () => {
32
+ test("Visibility false", async () => {
33
+ console.log("FROM TEST MODEL LINES")
34
+ const dataStyleStore = useDataStyleStore()
35
+ const viewerStore = useViewerStore()
36
+ const dataBaseStore = useDataBaseStore()
37
+ const line_ids = dataBaseStore.getLinesUuids(id)
38
+ const lines_flat_indexes = dataBaseStore.getFlatIndexes(id, line_ids)
39
+ const visibility = false
40
+ const spy = vi.spyOn(composables, "viewer_call")
41
+ await dataStyleStore.setModelLinesVisibility(id, line_ids, visibility)
42
+ expect(spy).toHaveBeenCalledWith(
43
+ {
44
+ schema: model_lines_schemas.visibility,
45
+ params: { id, block_ids: lines_flat_indexes, visibility },
46
+ },
47
+ {
48
+ response_function: expect.any(Function),
49
+ },
50
+ )
51
+ for (const line_id of line_ids) {
52
+ expect(dataStyleStore.modelLineVisibility(id, line_id)).toBe(visibility)
53
+ }
54
+ expect(viewerStore.status).toBe(Status.CONNECTED)
55
+ })
56
+ })
57
+
58
+ describe("Lines color", () => {
59
+ test("Color red", async () => {
60
+ const dataStyleStore = useDataStyleStore()
61
+ const viewerStore = useViewerStore()
62
+ const dataBaseStore = useDataBaseStore()
63
+ const line_ids = dataBaseStore.getLinesUuids(id)
64
+ const lines_flat_indexes = dataBaseStore.getFlatIndexes(id, line_ids)
65
+ const color = { r: 255, g: 0, b: 0 }
66
+ const spy = vi.spyOn(composables, "viewer_call")
67
+ await dataStyleStore.setModelLinesColor(id, line_ids, color)
68
+ expect(spy).toHaveBeenCalledWith(
69
+ {
70
+ schema: model_lines_schemas.color,
71
+ params: { id, block_ids: lines_flat_indexes, color },
72
+ },
73
+ {
74
+ response_function: expect.any(Function),
75
+ },
76
+ )
77
+ for (const line_id of line_ids) {
78
+ expect(dataStyleStore.modelLineColor(id, line_id)).toStrictEqual(color)
79
+ }
80
+ expect(viewerStore.status).toBe(Status.CONNECTED)
81
+ })
82
+ })
83
+ })