@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,58 +1,92 @@
1
+ // Third party imports
1
2
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
2
- const surfaces_schemas = viewer_schemas.opengeodeweb_viewer.model.surfaces
3
3
 
4
- export function useSurfacesStyle() {
5
- /** State **/
4
+ // Local constants
5
+ const model_surfaces_schemas = viewer_schemas.opengeodeweb_viewer.model.surfaces
6
+
7
+ export function useModelSurfacesStyle() {
6
8
  const dataStyleStore = useDataStyleStore()
7
9
  const dataBaseStore = useDataBaseStore()
8
10
 
9
- /** Getters **/
10
- function surfaceVisibility(id, surface_id) {
11
- return dataStyleStore.styles[id].surfaces[surface_id].visibility
11
+ function modelSurfaceStyle(id, surface_id) {
12
+ if (!dataStyleStore.getStyle(id).surfaces[surface_id]) {
13
+ dataStyleStore.getStyle(id).surfaces[surface_id] = {}
14
+ }
15
+ return dataStyleStore.getStyle(id).surfaces[surface_id]
12
16
  }
13
17
 
14
- /** Actions **/
15
- function setSurfaceVisibility(id, surface_ids, visibility) {
18
+ function modelSurfaceVisibility(id, surface_id) {
19
+ return modelSurfaceStyle(id, surface_id).visibility
20
+ }
21
+ function saveModelSurfaceVisibility(id, surface_id, visibility) {
22
+ modelSurfaceStyle(id, surface_id).visibility = visibility
23
+ }
24
+ function setModelSurfacesVisibility(id, surface_ids, visibility) {
16
25
  const surface_flat_indexes = dataBaseStore.getFlatIndexes(id, surface_ids)
17
26
  return viewer_call(
18
27
  {
19
- schema: surfaces_schemas.visibility,
28
+ schema: model_surfaces_schemas.visibility,
20
29
  params: { id, block_ids: surface_flat_indexes, visibility },
21
30
  },
22
31
  {
23
32
  response_function: () => {
24
33
  for (const surface_id of surface_ids) {
25
- if (!dataStyleStore.styles[id].surfaces[surface_id])
26
- dataStyleStore.styles[id].surfaces[surface_id] = {}
27
- dataStyleStore.styles[id].surfaces[surface_id].visibility =
28
- visibility
34
+ saveModelSurfaceVisibility(id, surface_id, visibility)
29
35
  }
30
- console.log("setSurfaceVisibility", surface_ids, visibility)
36
+ console.log(
37
+ setModelSurfacesVisibility.name,
38
+ { id },
39
+ { surface_ids },
40
+ modelSurfaceVisibility(id, surface_ids[0]),
41
+ )
31
42
  },
32
43
  },
33
44
  )
34
45
  }
46
+ function modelSurfaceColor(id, surface_id) {
47
+ return modelSurfaceStyle(id, surface_id).color
48
+ }
49
+ function saveModelSurfaceColor(id, surface_id, color) {
50
+ modelSurfaceStyle(id, surface_id).color = color
51
+ }
35
52
 
36
- function setSurfacesDefaultStyle(id) {
37
- const surface_ids = dataBaseStore.getSurfacesUuids(id)
38
- setSurfaceVisibility(
39
- id,
40
- surface_ids,
41
- dataStyleStore.styles[id].surfaces.visibility,
53
+ function setModelSurfacesColor(id, surface_ids, color) {
54
+ const surface_flat_indexes = dataBaseStore.getFlatIndexes(id, surface_ids)
55
+ return viewer_call(
56
+ {
57
+ schema: model_surfaces_schemas.color,
58
+ params: { id, block_ids: surface_flat_indexes, color },
59
+ },
60
+ {
61
+ response_function: () => {
62
+ for (const surface_id of surface_ids) {
63
+ saveModelSurfaceColor(id, surface_id, color)
64
+ }
65
+ console.log(
66
+ setModelSurfacesColor.name,
67
+ { id },
68
+ { surface_ids },
69
+ JSON.stringify(modelSurfaceColor(id, surface_ids[0])),
70
+ )
71
+ },
72
+ },
42
73
  )
43
74
  }
44
75
 
45
- function applySurfacesStyle(id) {
46
- const surfaces = dataStyleStore.styles[id].surfaces
47
- for (const [surface_id, style] of Object.entries(surfaces)) {
48
- setSurfaceVisibility(id, [surface_id], style.visibility)
49
- }
76
+ function applyModelSurfacesStyle(id) {
77
+ const style = dataStyleStore.getStyle(id).surfaces
78
+ const surface_ids = dataBaseStore.getSurfacesUuids(id)
79
+ return Promise.all([
80
+ setModelSurfacesVisibility(id, surface_ids, style.visibility),
81
+ setModelSurfacesColor(id, surface_ids, style.color),
82
+ ])
50
83
  }
51
84
 
52
85
  return {
53
- surfaceVisibility,
54
- setSurfacesDefaultStyle,
55
- setSurfaceVisibility,
56
- applySurfacesStyle,
86
+ modelSurfaceVisibility,
87
+ modelSurfaceColor,
88
+ setModelSurfacesVisibility,
89
+ setModelSurfacesColor,
90
+ applyModelSurfacesStyle,
57
91
  }
58
92
  }
package/package.json CHANGED
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "description": "OpenSource Vue/Nuxt/Pinia/Vuetify framework for web applications",
42
42
  "type": "module",
43
- "version": "9.12.2-rc.1",
43
+ "version": "9.12.2-rc.2",
44
44
  "main": "./nuxt.config.js",
45
45
  "dependencies": {
46
46
  "@geode/opengeodeweb-back": "next",
@@ -1,10 +1,12 @@
1
+ // Third party imports
1
2
  import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json"
2
3
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
4
 
4
- export const useDataBaseStore = defineStore("dataBase", () => {
5
- const treeview_store = useTreeviewStore()
6
- const hybridViewerStore = useHybridViewerStore()
5
+ // Local constants
6
+ const back_model_schemas = back_schemas.opengeodeweb_back.models
7
+ const viewer_generic_schemas = viewer_schemas.opengeodeweb_viewer.generic
7
8
 
9
+ export const useDataBaseStore = defineStore("dataBase", () => {
8
10
  const db = reactive({})
9
11
 
10
12
  function itemMetaDatas(id) {
@@ -41,7 +43,7 @@ export const useDataBaseStore = defineStore("dataBase", () => {
41
43
 
42
44
  async function registerObject(id) {
43
45
  return viewer_call({
44
- schema: viewer_schemas.opengeodeweb_viewer.generic.register,
46
+ schema: viewer_generic_schemas.register,
45
47
  params: { id },
46
48
  })
47
49
  }
@@ -58,50 +60,34 @@ export const useDataBaseStore = defineStore("dataBase", () => {
58
60
  },
59
61
  ) {
60
62
  db[id] = value
61
-
62
- if (value.object_type === "model") {
63
- await fetchMeshComponents(id)
64
- await fetchUuidToFlatIndexDict(id)
65
- }
66
- treeview_store.addItem(
67
- value.geode_object,
68
- value.displayed_name,
69
- id,
70
- value.object_type,
71
- )
72
-
73
- hybridViewerStore.addItem(id, value.vtk_js)
74
63
  }
75
64
 
76
65
  async function fetchMeshComponents(id) {
77
- await api_fetch(
66
+ return api_fetch(
78
67
  {
79
- schema: back_schemas.opengeodeweb_back.models.mesh_components,
68
+ schema: back_model_schemas.mesh_components,
80
69
  params: {
81
70
  id,
82
71
  },
83
72
  },
84
73
  {
85
74
  response_function: async (response) => {
86
- if (response._data?.uuid_dict) {
87
- db[id].mesh_components = response._data.uuid_dict
88
- }
75
+ db[id].mesh_components = response._data.uuid_dict
89
76
  },
90
77
  },
91
78
  )
92
79
  }
93
80
 
94
81
  async function fetchUuidToFlatIndexDict(id) {
95
- await api_fetch(
82
+ console.log("fetchUuidToFlatIndexDict", id)
83
+ return api_fetch(
96
84
  {
97
- schema: back_schemas.opengeodeweb_back.models.vtm_component_indices,
85
+ schema: back_model_schemas.vtm_component_indices,
98
86
  params: { id },
99
87
  },
100
88
  {
101
89
  response_function: async (response) => {
102
- if (response._data?.uuid_to_flat_index) {
103
- db[id]["uuid_to_flat_index"] = response._data.uuid_to_flat_index
104
- }
90
+ db[id]["uuid_to_flat_index"] = response._data.uuid_to_flat_index
105
91
  },
106
92
  },
107
93
  )
@@ -127,11 +113,11 @@ export const useDataBaseStore = defineStore("dataBase", () => {
127
113
 
128
114
  function getFlatIndexes(id, mesh_component_ids) {
129
115
  const { uuid_to_flat_index } = itemMetaDatas(id)
130
-
131
- const flat_indexes = mesh_component_ids.map(
132
- (mesh_component_id) => uuid_to_flat_index[mesh_component_id] || null,
133
- )
134
- return flat_indexes.filter((index) => index !== null)
116
+ const flat_indexes = []
117
+ for (const mesh_component_id of mesh_component_ids) {
118
+ flat_indexes.push(uuid_to_flat_index[mesh_component_id])
119
+ }
120
+ return flat_indexes
135
121
  }
136
122
 
137
123
  return {
@@ -3,58 +3,46 @@ import useMeshStyle from "../internal_stores/mesh/index.js"
3
3
  import useModelStyle from "../internal_stores/model/index.js"
4
4
 
5
5
  export const useDataStyleStore = defineStore("dataStyle", () => {
6
- /** States **/
7
6
  const dataStyleState = useDataStyleState()
8
7
  const meshStyleStore = useMeshStyle()
9
8
  const modelStyleStore = useModelStyle()
10
9
  const dataBaseStore = useDataBaseStore()
11
10
 
12
- /** Actions **/
13
- function addDataStyle(id, geode_object, object_type) {
11
+ function addDataStyle(id, geode_object) {
14
12
  dataStyleState.styles[id] = getDefaultStyle(geode_object)
15
- const promise_array = []
16
- if (object_type === "mesh") {
17
- promise_array.push(meshStyleStore.applyMeshDefaultStyle(id))
18
- } else if (object_type === "model") {
19
- promise_array.push(modelStyleStore.setMeshComponentsDefaultStyle(id))
20
- promise_array.push(modelStyleStore.applyModelDefaultStyle(id))
21
- } else {
22
- throw new Error("Unknown object type")
23
- }
24
- return Promise.all(promise_array)
25
13
  }
26
14
 
27
15
  function setVisibility(id, visibility) {
16
+ console.log(
17
+ "dataBaseStore.itemMetaDatas(id)",
18
+ dataBaseStore.itemMetaDatas(id),
19
+ )
28
20
  const object_type = dataBaseStore.itemMetaDatas(id).object_type
29
21
  if (object_type === "mesh") {
30
22
  return Promise.all([meshStyleStore.setMeshVisibility(id, visibility)])
31
23
  } else if (object_type === "model") {
32
24
  return Promise.all([modelStyleStore.setModelVisibility(id, visibility)])
33
25
  }
26
+ throw new Error("Unknown object_type")
34
27
  }
35
28
 
36
- function setModelEdgesVisibility(id, visibility) {
37
- modelStyleStore.setModelMeshComponentVisibility(
38
- id,
39
- "Edge",
40
- null,
41
- visibility,
42
- )
43
- }
44
-
45
- function modelEdgesVisibility(id) {
46
- return modelStyleStore.modelMeshComponentVisibility(id, "Edge", null)
29
+ function applyDefaultStyle(id) {
30
+ const { object_type } = dataBaseStore.itemMetaDatas(id)
31
+ if (object_type === "mesh") {
32
+ return meshStyleStore.applyMeshStyle(id)
33
+ } else if (object_type === "model") {
34
+ return modelStyleStore.applyModelStyle(id)
35
+ } else {
36
+ throw new Error("Unknown object_type: " + object_type)
37
+ }
47
38
  }
48
39
 
49
40
  return {
50
41
  ...dataStyleState,
51
- addDataStyle,
52
- setVisibility,
53
- setModelEdgesVisibility,
54
- modelEdgesVisibility,
55
42
  ...meshStyleStore,
56
43
  ...modelStyleStore,
44
+ addDataStyle,
45
+ applyDefaultStyle,
46
+ setVisibility,
57
47
  }
58
48
  })
59
-
60
- export default useDataStyleStore
@@ -8,7 +8,8 @@ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schem
8
8
  import Status from "@ogw_f/utils/status.js"
9
9
 
10
10
  export const useHybridViewerStore = defineStore("hybridViewer", () => {
11
- const viewer_store = useViewerStore()
11
+ const viewerStore = useViewerStore()
12
+ const dataBaseStore = useDataBaseStore()
12
13
  const db = reactive({})
13
14
  const status = ref(Status.NOT_CREATED)
14
15
  const camera_options = reactive({})
@@ -32,8 +33,8 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
32
33
  imageStyle.transition = "opacity 0.1s ease-in"
33
34
  imageStyle.zIndex = 1
34
35
 
35
- await viewer_store.ws_connect()
36
- viewStream = viewer_store.client.getImageStream().createViewStream("-1")
36
+ await viewerStore.ws_connect()
37
+ viewStream = viewerStore.client.getImageStream().createViewStream("-1")
37
38
  viewStream.onImageReady((e) => {
38
39
  if (is_moving.value) return
39
40
  const webGLRenderWindow =
@@ -46,11 +47,16 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
46
47
  status.value = Status.CREATED
47
48
  }
48
49
 
49
- async function addItem(id, value) {
50
+ async function addItem(id) {
51
+ if (!genericRenderWindow.value) {
52
+ return
53
+ }
54
+ const value = dataBaseStore.db[id]
55
+ console.log("hybridViewerStore.addItem", { value })
50
56
  const reader = vtkXMLPolyDataReader.newInstance()
51
57
  const textEncoder = new TextEncoder()
52
58
  await reader.parseAsArrayBuffer(
53
- textEncoder.encode(value.binary_light_viewable),
59
+ textEncoder.encode(value.vtk_js.binary_light_viewable),
54
60
  )
55
61
  const polydata = reader.getOutputData(0)
56
62
  const mapper = vtkMapper.newInstance()
@@ -166,7 +172,7 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
166
172
 
167
173
  async function resize(width, height) {
168
174
  if (
169
- viewer_store.status !== Status.CONNECTED ||
175
+ viewerStore.status !== Status.CONNECTED ||
170
176
  status.value !== Status.CREATED
171
177
  ) {
172
178
  return
@@ -1,7 +1,7 @@
1
1
  export const useTreeviewStore = defineStore("treeview", () => {
2
2
  const dataStyleStore = useDataStyleStore()
3
+ const dataBaseStore = useDataBaseStore()
3
4
 
4
- /** State **/
5
5
  const items = ref([])
6
6
  const selection = ref([])
7
7
  const components_selection = ref([])
@@ -11,9 +11,8 @@ export const useTreeviewStore = defineStore("treeview", () => {
11
11
  const isTreeCollection = ref(false)
12
12
  const selectedTree = ref(null)
13
13
 
14
- /** Functions **/
14
+ // /** Functions **/
15
15
  function addItem(geodeObject, displayed_name, id, object_type) {
16
- dataStyleStore.addDataStyle(id, geodeObject, object_type)
17
16
  const child = { title: displayed_name, id, object_type }
18
17
 
19
18
  for (let i = 0; i < items.value.length; i++) {
@@ -5,4 +5,4 @@
5
5
  # pip-compile --output-file=tests/integration/microservices/viewer/requirements.txt tests/integration/microservices/viewer/requirements.in
6
6
  #
7
7
 
8
- opengeodeweb-viewer==1.*,>=1.11.7
8
+ opengeodeweb-viewer==1.*,>=1.11.8rc1
@@ -7,16 +7,13 @@ import { WebSocket } from "ws"
7
7
  import { setActivePinia } from "pinia"
8
8
  import { createTestingPinia } from "@pinia/testing"
9
9
  import { afterAll, beforeAll, expect, vi } from "vitest"
10
- import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json"
11
10
 
12
11
  // Local imports
13
- import { useDataStyleStore } from "~/stores/data_style"
14
- import { useDataBaseStore } from "~/stores/data_base"
15
12
  import { useGeodeStore } from "~/stores/geode"
16
13
  import { useViewerStore } from "~/stores/viewer"
17
14
  import { useInfraStore } from "~/stores/infra"
18
- import { api_fetch } from "~/composables/api_fetch"
19
15
  import { appMode } from "~/utils/app_mode"
16
+ import { importFile } from "~/utils/file_import_workflow"
20
17
  import Status from "~/utils/status"
21
18
  import {
22
19
  executable_name,
@@ -24,23 +21,24 @@ import {
24
21
  run_back,
25
22
  run_viewer,
26
23
  } from "~/utils/local"
27
- import { getCurrentFolders, cleanupCreatedFolders } from "./utils.js"
28
24
 
29
- async function setupIntegrationTests(file_name, geode_object, object_type) {
25
+ // Local constants
26
+ const data_folder = path.join("tests", "integration", "data")
27
+
28
+ async function setupIntegrationTests(file_name, geode_object) {
30
29
  const pinia = createTestingPinia({
31
30
  stubActions: false,
32
31
  createSpy: vi.fn,
33
32
  })
34
33
  setActivePinia(pinia)
35
- const dataStyleStore = useDataStyleStore()
36
- const dataBaseStore = useDataBaseStore()
37
34
  const geodeStore = useGeodeStore()
38
- const viewerStore = useViewerStore()
35
+ const hybridViewerStore = useHybridViewerStore()
39
36
  const infraStore = useInfraStore()
37
+ const viewerStore = useViewerStore()
40
38
  infraStore.app_mode = appMode.BROWSER
41
39
 
42
40
  const microservices_path = path.join("tests", "integration", "microservices")
43
- const project_folder_path = path.join(__dirname, "data", uuidv4())
41
+ const project_folder_path = path.join(data_folder, uuidv4())
44
42
  const upload_folder_path = path.join(__dirname, "data", "uploads")
45
43
  const back_path = executable_path(path.join(microservices_path, "back"))
46
44
  const back_name = executable_name("opengeodeweb-back")
@@ -57,23 +55,19 @@ async function setupIntegrationTests(file_name, geode_object, object_type) {
57
55
  ])
58
56
  console.log("back_port", back_port)
59
57
  console.log("viewer_port", viewer_port)
58
+
60
59
  geodeStore.default_local_port = back_port
61
60
  viewerStore.default_local_port = viewer_port
61
+ console.log("after ports")
62
62
  await viewerStore.ws_connect()
63
+ // await hybridViewerStore.initHybridViewer()
64
+ console.log("after hybridViewerStore.initHybridViewer")
63
65
 
64
- const response = await api_fetch({
65
- schema: back_schemas.opengeodeweb_back.save_viewable_file,
66
- params: {
67
- input_geode_object: geode_object,
68
- filename: file_name,
69
- },
70
- })
71
-
72
- const id = response.data._value.id
73
- await dataBaseStore.registerObject(id)
74
- await dataStyleStore.addDataStyle(id, geode_object, object_type)
66
+ // await viewerStore.ws_connect()
67
+ const id = await importFile(file_name, geode_object)
75
68
  expect(viewerStore.status).toBe(Status.CONNECTED)
76
- return { id, back_port, viewer_port }
69
+ console.log("end of setupIntegrationTests")
70
+ return { id, back_port, viewer_port, project_folder_path }
77
71
  }
78
72
 
79
73
  const mockLockRequest = vi.fn().mockImplementation(async (name, callback) => {
@@ -87,21 +81,12 @@ vi.stubGlobal("navigator", {
87
81
  },
88
82
  })
89
83
 
90
- let foldersBeforeTests = new Set()
91
-
92
- const data_folder = path.join("tests", "integration", "data")
93
84
  beforeAll(() => {
94
85
  global.WebSocket = WebSocket
95
- foldersBeforeTests = getCurrentFolders(data_folder)
96
- console.log("foldersBeforeTests", foldersBeforeTests)
97
86
  })
98
87
 
99
88
  afterAll(() => {
100
- console.log("afterAll")
101
89
  delete global.WebSocket
102
- setTimeout(() => {
103
- cleanupCreatedFolders(data_folder, foldersBeforeTests)
104
- }, 2000)
105
90
  })
106
91
 
107
92
  export { setupIntegrationTests }
@@ -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,25 +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"
10
+ import { delete_folder_recursive, kill_back, kill_viewer } from "~/utils/local"
12
11
  import { setupIntegrationTests } from "../../../setup.js"
13
12
 
14
13
  // Local constants
15
14
  const mesh_edges_schemas = viewer_schemas.opengeodeweb_viewer.mesh.edges
16
- let id, back_port, viewer_port
17
15
  const file_name = "test.og_edc2d"
18
16
  const geode_object = "EdgedCurve2D"
19
- const object_type = "mesh"
17
+
18
+ let id, back_port, viewer_port, project_folder_path
20
19
 
21
20
  beforeEach(async () => {
22
- ;({ id, back_port, viewer_port } = await setupIntegrationTests(
23
- file_name,
24
- geode_object,
25
- object_type,
26
- ))
27
- }, 20000)
21
+ ;({ id, back_port, viewer_port, project_folder_path } =
22
+ await setupIntegrationTests(file_name, geode_object))
23
+ }, 25000)
28
24
 
29
25
  afterEach(async () => {
26
+ console.log(
27
+ "afterEach mesh edges kill",
28
+ back_port,
29
+ viewer_port,
30
+ project_folder_path,
31
+ )
30
32
  await Promise.all([kill_back(back_port), kill_viewer(viewer_port)])
33
+ delete_folder_recursive(project_folder_path)
31
34
  })
32
35
 
33
36
  describe("Mesh edges", () => {
@@ -35,8 +38,19 @@ describe("Mesh edges", () => {
35
38
  test("Visibility true", async () => {
36
39
  const dataStyleStore = useDataStyleStore()
37
40
  const viewerStore = useViewerStore()
38
- await dataStyleStore.setMeshEdgesVisibility(id, true)
39
- expect(dataStyleStore.meshEdgesVisibility(id)).toBe(true)
41
+ const visibility = true
42
+ const spy = vi.spyOn(composables, "viewer_call")
43
+ await dataStyleStore.setMeshEdgesVisibility(id, visibility)
44
+ expect(spy).toHaveBeenCalledWith(
45
+ {
46
+ schema: mesh_edges_schemas.visibility,
47
+ params: { id, visibility },
48
+ },
49
+ {
50
+ response_function: expect.any(Function),
51
+ },
52
+ )
53
+ expect(dataStyleStore.meshEdgesVisibility(id)).toBe(visibility)
40
54
  expect(viewerStore.status).toBe(Status.CONNECTED)
41
55
  })
42
56
  })
@@ -55,7 +69,7 @@ describe("Mesh edges", () => {
55
69
  })
56
70
  })
57
71
  describe("Edges color", () => {
58
- test("test red", async () => {
72
+ test("Color red", async () => {
59
73
  const dataStyleStore = useDataStyleStore()
60
74
  const viewerStore = useViewerStore()
61
75
  const color = { r: 255, g: 0, b: 0 }
@@ -0,0 +1,66 @@
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 mesh_schemas = viewer_schemas.opengeodeweb_viewer.mesh
15
+ const file_name = "test.og_rgd3d"
16
+ const geode_object = "RegularGrid3D"
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 mesh index 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("Mesh", () => {
37
+ describe("Mesh 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.setMeshVisibility(id, visibility)
44
+ expect(spy).toHaveBeenCalledWith(
45
+ {
46
+ schema: mesh_schemas.visibility,
47
+ params: { id, visibility },
48
+ },
49
+ {
50
+ response_function: expect.any(Function),
51
+ },
52
+ )
53
+ expect(dataStyleStore.meshVisibility(id)).toBe(visibility)
54
+ expect(viewerStore.status).toBe(Status.CONNECTED)
55
+ })
56
+ })
57
+
58
+ describe("Apply mesh default style", () => {
59
+ test("test", async () => {
60
+ const dataStyleStore = useDataStyleStore()
61
+ const viewerStore = useViewerStore()
62
+ await dataStyleStore.applyMeshStyle(id)
63
+ expect(viewerStore.status).toBe(Status.CONNECTED)
64
+ })
65
+ })
66
+ })