@geode/opengeodeweb-front 10.3.0 → 10.3.1

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 (178) hide show
  1. package/.eslintrc.cjs +1 -0
  2. package/app/assets/geode_objects.js +1 -3
  3. package/app/components/Carousel.vue +7 -4
  4. package/app/components/CrsSelector.vue +5 -6
  5. package/app/components/DragAndDrop.vue +18 -8
  6. package/app/components/ExtensionSelector.vue +9 -17
  7. package/app/components/FeedBack/ErrorBanner.vue +1 -1
  8. package/app/components/FeedBack/Snackers.vue +4 -1
  9. package/app/components/FileSelector.vue +21 -10
  10. package/app/components/FileUploader.vue +15 -32
  11. package/app/components/HybridRenderingView.vue +5 -3
  12. package/app/components/Inspector/InspectionButton.vue +2 -2
  13. package/app/components/Inspector/ResultPanel.vue +4 -4
  14. package/app/components/Launcher.vue +1 -1
  15. package/app/components/Loading.vue +6 -6
  16. package/app/components/MissingFilesSelector.vue +23 -29
  17. package/app/components/ObjectSelector.vue +11 -10
  18. package/app/components/OptionCard.vue +1 -1
  19. package/app/components/PackagesVersions.vue +5 -3
  20. package/app/components/Recaptcha.vue +6 -4
  21. package/app/components/RemoteRenderingView.vue +4 -3
  22. package/app/components/Screenshot.vue +4 -4
  23. package/app/components/Step.vue +7 -7
  24. package/app/components/VeaseViewToolbar.vue +3 -3
  25. package/app/components/Viewer/BreadCrumb.vue +2 -4
  26. package/app/components/Viewer/ContextMenu.vue +77 -45
  27. package/app/components/Viewer/ContextMenuItem.vue +42 -33
  28. package/app/components/Viewer/EdgedCurve/PointsOptions.vue +3 -3
  29. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +5 -5
  30. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +6 -6
  31. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +5 -5
  32. package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +5 -5
  33. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +6 -7
  34. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +6 -6
  35. package/app/components/Viewer/Generic/Model/EdgesOptions.vue +3 -3
  36. package/app/components/Viewer/Generic/Model/PointsOptions.vue +4 -4
  37. package/app/components/Viewer/Grid/2D/CellsOptions.vue +3 -3
  38. package/app/components/Viewer/Grid/2D/EdgesOptions.vue +3 -3
  39. package/app/components/Viewer/Grid/2D/PointsOptions.vue +3 -3
  40. package/app/components/Viewer/Grid/3D/CellsOptions.vue +3 -3
  41. package/app/components/Viewer/Grid/3D/EdgesOptions.vue +3 -3
  42. package/app/components/Viewer/Grid/3D/FacetsOptions.vue +3 -3
  43. package/app/components/Viewer/Grid/3D/PointsOptions.vue +3 -3
  44. package/app/components/Viewer/HybridSolid/EdgesOptions.vue +3 -3
  45. package/app/components/Viewer/HybridSolid/PointsOptions.vue +3 -3
  46. package/app/components/Viewer/HybridSolid/PolygonsOptions.vue +3 -3
  47. package/app/components/Viewer/HybridSolid/PolyhedraOptions.vue +3 -3
  48. package/app/components/Viewer/Options/CellAttributeSelector.vue +23 -20
  49. package/app/components/Viewer/Options/ColorMapList.vue +75 -50
  50. package/app/components/Viewer/Options/ColorMapPicker.vue +38 -32
  51. package/app/components/Viewer/Options/ColorPicker.vue +3 -3
  52. package/app/components/Viewer/Options/ColoringTypeSelector.vue +29 -21
  53. package/app/components/Viewer/Options/EdgeAttributeSelector.vue +7 -7
  54. package/app/components/Viewer/Options/PolygonAttributeSelector.vue +7 -7
  55. package/app/components/Viewer/Options/PolyhedronAttributeSelector.vue +7 -7
  56. package/app/components/Viewer/Options/TextureItem.vue +5 -5
  57. package/app/components/Viewer/Options/TexturesSelector.vue +5 -5
  58. package/app/components/Viewer/Options/VertexAttributeSelector.vue +7 -7
  59. package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +5 -5
  60. package/app/components/Viewer/PolygonalSurface/EdgesOptions.vue +3 -3
  61. package/app/components/Viewer/PolygonalSurface/PointsOptions.vue +3 -3
  62. package/app/components/Viewer/PolygonalSurface/SpecificPolygonsOptions.vue +6 -6
  63. package/app/components/Viewer/Solid/EdgesOptions.vue +3 -3
  64. package/app/components/Viewer/Solid/PointsOptions.vue +3 -3
  65. package/app/components/Viewer/Solid/PolygonsOptions.vue +3 -3
  66. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +6 -6
  67. package/app/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue +3 -3
  68. package/app/components/Viewer/TetrahedralSolid/TrianglesOptions.vue +3 -3
  69. package/app/components/Viewer/Tree/ObjectTree.vue +7 -9
  70. package/app/components/Viewer/TreeComponent.vue +9 -13
  71. package/app/components/Viewer/TreeObject.vue +8 -9
  72. package/app/components/Viewer/TriangulatedSurface/EdgesOptions.vue +3 -3
  73. package/app/components/Viewer/TriangulatedSurface/PointsOptions.vue +3 -3
  74. package/app/components/Viewer/TriangulatedSurface/TrianglesOptions.vue +3 -3
  75. package/app/components/Wrapper.vue +1 -2
  76. package/app/components/ZScaling.vue +1 -1
  77. package/app/composables/project_manager.js +6 -6
  78. package/app/plugins/auto_store_register.js +1 -1
  79. package/app/stores/app.js +45 -41
  80. package/app/stores/data.js +52 -51
  81. package/app/stores/data_style.js +12 -11
  82. package/app/stores/feedback.js +5 -1
  83. package/app/stores/geode.js +16 -13
  84. package/app/stores/hybrid_viewer.js +72 -44
  85. package/app/stores/infra.js +18 -16
  86. package/app/stores/lambda.js +1 -9
  87. package/app/stores/menu.js +13 -13
  88. package/app/stores/treeview.js +15 -13
  89. package/app/stores/viewer.js +39 -33
  90. package/app/utils/app_mode.js +4 -3
  91. package/app/utils/default_styles.js +55 -47
  92. package/app/utils/file_import_workflow.js +4 -17
  93. package/app/utils/local.js +195 -184
  94. package/app/utils/upload_file.js +1 -2
  95. package/eslint.config.js +2 -2
  96. package/internal/database/database.js +17 -32
  97. package/internal/database/extended_database.js +25 -0
  98. package/internal/stores/data_style/mesh/cells/cell.js +3 -3
  99. package/internal/stores/data_style/mesh/cells/color.js +1 -1
  100. package/internal/stores/data_style/mesh/cells/index.js +7 -7
  101. package/internal/stores/data_style/mesh/cells/textures.js +1 -1
  102. package/internal/stores/data_style/mesh/cells/vertex.js +3 -3
  103. package/internal/stores/data_style/mesh/cells/visibility.js +1 -1
  104. package/internal/stores/data_style/mesh/edges/color.js +1 -1
  105. package/internal/stores/data_style/mesh/edges/edge.js +22 -22
  106. package/internal/stores/data_style/mesh/edges/index.js +7 -7
  107. package/internal/stores/data_style/mesh/edges/vertex.js +3 -3
  108. package/internal/stores/data_style/mesh/edges/visibility.js +1 -1
  109. package/internal/stores/data_style/mesh/edges/width.js +1 -1
  110. package/internal/stores/data_style/mesh/index.js +4 -5
  111. package/internal/stores/data_style/mesh/points/color.js +1 -1
  112. package/internal/stores/data_style/mesh/points/index.js +6 -6
  113. package/internal/stores/data_style/mesh/points/size.js +1 -1
  114. package/internal/stores/data_style/mesh/points/vertex.js +3 -3
  115. package/internal/stores/data_style/mesh/points/visibility.js +1 -1
  116. package/internal/stores/data_style/mesh/polygons/color.js +1 -1
  117. package/internal/stores/data_style/mesh/polygons/index.js +7 -7
  118. package/internal/stores/data_style/mesh/polygons/polygon.js +3 -3
  119. package/internal/stores/data_style/mesh/polygons/textures.js +1 -1
  120. package/internal/stores/data_style/mesh/polygons/vertex.js +3 -3
  121. package/internal/stores/data_style/mesh/polygons/visibility.js +1 -1
  122. package/internal/stores/data_style/mesh/polyhedra/color.js +1 -1
  123. package/internal/stores/data_style/mesh/polyhedra/index.js +6 -6
  124. package/internal/stores/data_style/mesh/polyhedra/polyhedron.js +3 -3
  125. package/internal/stores/data_style/mesh/polyhedra/vertex.js +3 -3
  126. package/internal/stores/data_style/mesh/polyhedra/visibility.js +1 -1
  127. package/internal/stores/data_style/model/edges.js +1 -1
  128. package/internal/stores/data_style/model/index.js +32 -22
  129. package/internal/utils/api_fetch.js +8 -5
  130. package/internal/utils/viewer_call.js +42 -46
  131. package/nuxt.config.js +3 -3
  132. package/package.json +1 -1
  133. package/scripts/generate_geode_objects.js +8 -7
  134. package/tests/integration/setup.js +28 -21
  135. package/tests/integration/stores/data_style/mesh/cells.nuxt.test.js +18 -10
  136. package/tests/integration/stores/data_style/mesh/edges.nuxt.test.js +18 -10
  137. package/tests/integration/stores/data_style/mesh/index.nuxt.test.js +9 -5
  138. package/tests/integration/stores/data_style/mesh/points.nuxt.test.js +17 -10
  139. package/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js +18 -10
  140. package/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js +18 -10
  141. package/tests/integration/stores/data_style/model/blocks.nuxt.test.js +10 -6
  142. package/tests/integration/stores/data_style/model/corners.nuxt.test.js +10 -6
  143. package/tests/integration/stores/data_style/model/edges.nuxt.test.js +9 -5
  144. package/tests/integration/stores/data_style/model/index.nuxt.test.js +9 -5
  145. package/tests/integration/stores/data_style/model/lines.nuxt.test.js +10 -6
  146. package/tests/integration/stores/data_style/model/points.nuxt.test.js +9 -5
  147. package/tests/integration/stores/data_style/model/surfaces.nuxt.test.js +10 -6
  148. package/tests/integration/stores/viewer.nuxt.test.js +55 -39
  149. package/tests/setup_indexeddb.js +1 -0
  150. package/tests/unit/components/CrsSelector.nuxt.test.js +18 -19
  151. package/tests/unit/components/ExtensionSelector.nuxt.test.js +24 -19
  152. package/tests/unit/components/FeedBack/ErrorsBanner.nuxt.test.js +23 -36
  153. package/tests/unit/components/FeedBack/Snackers.nuxt.test.js +20 -25
  154. package/tests/unit/components/FileSelector.nuxt.test.js +27 -27
  155. package/tests/unit/components/FileUploader.nuxt.test.js +18 -17
  156. package/tests/unit/components/Inspector/InspectionButton.nuxt.test.js +9 -16
  157. package/tests/unit/components/Inspector/ResultPanel.nuxt.test.js +8 -6
  158. package/tests/unit/components/Launcher.nuxt.test.js +12 -17
  159. package/tests/unit/components/MissingFilesSelector.nuxt.test.js +16 -19
  160. package/tests/unit/components/ObjectSelector.nuxt.test.js +30 -34
  161. package/tests/unit/components/PackagesVersions.nuxt.test.js +8 -11
  162. package/tests/unit/components/Step.nuxt.test.js +8 -7
  163. package/tests/unit/components/Stepper.nuxt.test.js +14 -12
  164. package/tests/unit/composables/ProjectManager.nuxt.test.js +142 -100
  165. package/tests/unit/composables/api_fetch.nuxt.test.js +12 -39
  166. package/tests/unit/composables/run_function_when_microservices_connected.nuxt.test.js +36 -61
  167. package/tests/unit/composables/upload_file.nuxt.test.js +21 -25
  168. package/tests/unit/plugins/project_load.nuxt.test.js +22 -21
  169. package/tests/unit/stores/App.nuxt.test.js +45 -43
  170. package/tests/unit/stores/Feedback.nuxt.test.js +16 -18
  171. package/tests/unit/stores/Geode.nuxt.test.js +135 -137
  172. package/tests/unit/stores/Infra.nuxt.test.js +20 -26
  173. package/tests/unit/stores/Lambda.nuxt.test.js +30 -31
  174. package/tests/unit/stores/Treeview.nuxt.test.js +53 -55
  175. package/tests/unit/stores/Viewer.nuxt.test.js +16 -23
  176. package/tests/unit/utils/validate_schema.nuxt.test.js +18 -18
  177. package/tests/utils.js +15 -2
  178. package/tests/vitest.config.js +6 -2
@@ -1,34 +1,34 @@
1
- import { describe, expect, test, vi } from "vitest"
2
- import { registerEndpoint, mountSuspended } from "@nuxt/test-utils/runtime"
3
- import { flushPromises } from "@vue/test-utils"
4
1
  import * as components from "vuetify/components"
5
- import { setActivePinia } from "pinia"
6
- import { createTestingPinia } from "@pinia/testing"
2
+ import { describe, expect, test } from "vitest"
3
+ import { mountSuspended, registerEndpoint } from "@nuxt/test-utils/runtime"
4
+ import { flushPromises } from "@vue/test-utils"
7
5
 
8
- import schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json"
6
+ import { setupActivePinia, vuetify } from "../../utils"
9
7
  import ObjectSelector from "@ogw_front/components/ObjectSelector"
8
+ import schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json"
10
9
  import { useGeodeStore } from "@ogw_front/stores/geode"
11
- import { vuetify } from "../../utils"
12
10
 
13
- const allowed_objects = schemas.opengeodeweb_back.allowed_objects
11
+ const EXPECTED_LENGTH = 1
12
+ const FIRST_INDEX = 0
13
+ const LOADABLE_SCORE = 1
14
+ const PRIORITY_1 = 1
15
+ const PRIORITY_2 = 2
14
16
 
15
- describe("ObjectSelector", async () => {
16
- const pinia = createTestingPinia({
17
- stubActions: false,
18
- createSpy: vi.fn,
19
- })
20
- setActivePinia(pinia)
17
+ const { allowed_objects } = schemas.opengeodeweb_back
18
+
19
+ describe(ObjectSelector, () => {
20
+ const pinia = setupActivePinia()
21
21
  const geodeStore = useGeodeStore()
22
22
  geodeStore.base_url = ""
23
23
 
24
24
  test(`test loadable with one class`, async () => {
25
- var response = {
25
+ const response = {
26
26
  allowed_objects: {},
27
27
  }
28
28
  const geode_object_1 = "BRep"
29
29
  response["allowed_objects"][geode_object_1] = { is_loadable: true }
30
30
  registerEndpoint(allowed_objects.$id, {
31
- method: allowed_objects.methods[0],
31
+ method: allowed_objects.methods[FIRST_INDEX],
32
32
  handler: () => response,
33
33
  })
34
34
  const wrapper = await mountSuspended(ObjectSelector, {
@@ -41,15 +41,15 @@ describe("ObjectSelector", async () => {
41
41
  const v_img = v_card.findComponent(components.VImg)
42
42
  expect(v_img.vm.src).toContain(`${geode_object_1}.svg`)
43
43
  expect(wrapper.emitted()).toHaveProperty("update_values")
44
- expect(wrapper.emitted().update_values).toHaveLength(1)
45
- expect(wrapper.emitted().update_values[0][0]).toEqual({
44
+ expect(wrapper.emitted().update_values).toHaveLength(EXPECTED_LENGTH)
45
+ expect(wrapper.emitted().update_values[FIRST_INDEX][FIRST_INDEX]).toEqual({
46
46
  geode_object_type: geode_object_1,
47
47
  })
48
48
  wrapper.unmount()
49
49
  })
50
50
 
51
51
  test(`test loabable with multiple classes`, async () => {
52
- var response = {
52
+ const response = {
53
53
  allowed_objects: {},
54
54
  }
55
55
  const geode_object_1 = "BRep"
@@ -57,7 +57,7 @@ describe("ObjectSelector", async () => {
57
57
  response["allowed_objects"][geode_object_1] = { is_loadable: true }
58
58
  response["allowed_objects"][geode_object_2] = { is_loadable: true }
59
59
  registerEndpoint(allowed_objects.$id, {
60
- method: allowed_objects.methods[0],
60
+ method: allowed_objects.methods[FIRST_INDEX],
61
61
  handler: () => response,
62
62
  })
63
63
  const wrapper = await mountSuspended(ObjectSelector, {
@@ -73,31 +73,27 @@ describe("ObjectSelector", async () => {
73
73
  await v_card.trigger("click")
74
74
  await flushPromises()
75
75
  expect(wrapper.emitted()).toHaveProperty("update_values")
76
- console.log(
77
- "wrapper.emitted().update_values",
78
- wrapper.emitted().update_values,
79
- )
80
- expect(wrapper.emitted().update_values).toHaveLength(1)
81
- expect(wrapper.emitted().update_values[0][0]).toEqual({
76
+ expect(wrapper.emitted().update_values).toHaveLength(EXPECTED_LENGTH)
77
+ expect(wrapper.emitted().update_values[FIRST_INDEX][FIRST_INDEX]).toEqual({
82
78
  geode_object_type: geode_object_1,
83
79
  })
84
80
  wrapper.unmount()
85
81
  })
86
82
 
87
83
  test(`test object_priority when is_loadable scores equal`, async () => {
88
- var response = { allowed_objects: {} }
84
+ const response = { allowed_objects: {} }
89
85
  const geode_object_1 = "BRep"
90
86
  const geode_object_2 = "EdgedCurve3D"
91
87
  response["allowed_objects"][geode_object_1] = {
92
- is_loadable: 1.0,
93
- object_priority: 2,
88
+ is_loadable: LOADABLE_SCORE,
89
+ object_priority: PRIORITY_2,
94
90
  }
95
91
  response["allowed_objects"][geode_object_2] = {
96
- is_loadable: 1.0,
97
- object_priority: 1,
92
+ is_loadable: LOADABLE_SCORE,
93
+ object_priority: PRIORITY_1,
98
94
  }
99
95
  registerEndpoint(allowed_objects.$id, {
100
- method: allowed_objects.methods[0],
96
+ method: allowed_objects.methods[FIRST_INDEX],
101
97
  handler: () => response,
102
98
  })
103
99
  const wrapper = await mountSuspended(ObjectSelector, {
@@ -109,8 +105,8 @@ describe("ObjectSelector", async () => {
109
105
 
110
106
  await flushPromises()
111
107
  expect(wrapper.emitted()).toHaveProperty("update_values")
112
- expect(wrapper.emitted().update_values).toHaveLength(1)
113
- expect(wrapper.emitted().update_values[0][0]).toEqual({
108
+ expect(wrapper.emitted().update_values).toHaveLength(EXPECTED_LENGTH)
109
+ expect(wrapper.emitted().update_values[FIRST_INDEX][FIRST_INDEX]).toEqual({
114
110
  geode_object_type: geode_object_1,
115
111
  })
116
112
  wrapper.unmount()
@@ -1,18 +1,15 @@
1
- import { describe, expect, test, vi } from "vitest"
1
+ import { describe, expect, test } from "vitest"
2
2
  import { mountSuspended, registerEndpoint } from "@nuxt/test-utils/runtime"
3
- import { setActivePinia } from "pinia"
4
- import { createTestingPinia } from "@pinia/testing"
5
3
 
4
+ import { setupActivePinia, vuetify } from "../../utils"
6
5
  import PackagesVersions from "@ogw_front/components/PackagesVersions"
7
6
  import { useGeodeStore } from "@ogw_front/stores/geode"
8
- import { vuetify } from "../../utils"
9
7
 
10
- describe("PackagesVersions", async () => {
8
+ const FIRST_INDEX = 0
9
+
10
+ describe(PackagesVersions, async () => {
11
11
  test(`Mount`, async () => {
12
- const pinia = createTestingPinia({
13
- createSpy: vi.fn,
14
- })
15
- setActivePinia(pinia)
12
+ const pinia = setupActivePinia()
16
13
  const geodeStore = useGeodeStore()
17
14
  geodeStore.base_url = ""
18
15
 
@@ -24,7 +21,7 @@ describe("PackagesVersions", async () => {
24
21
  additionalProperties: false,
25
22
  }
26
23
  registerEndpoint(schema.$id, {
27
- method: schema.methods[0],
24
+ method: schema.methods[FIRST_INDEX],
28
25
  handler: () => ({
29
26
  versions: [
30
27
  {
@@ -40,6 +37,6 @@ describe("PackagesVersions", async () => {
40
37
  },
41
38
  props: { schema },
42
39
  })
43
- expect(wrapper.exists()).toBe(true)
40
+ expect(wrapper.exists()).toBeTruthy()
44
41
  })
45
42
  })
@@ -1,13 +1,16 @@
1
+ import { computed, reactive, ref, shallowRef } from "vue"
1
2
  import { describe, expect, test } from "vitest"
3
+ import ResizeObserver from "resize-observer-polyfill"
2
4
  import { mount } from "@vue/test-utils"
3
- import Step from "@ogw_front/components/Step"
5
+
4
6
  import ObjectSelector from "@ogw_front/components/ObjectSelector"
7
+ import Step from "@ogw_front/components/Step"
5
8
 
6
9
  import { vuetify } from "../../utils"
7
10
 
8
- global.ResizeObserver = require("resize-observer-polyfill")
11
+ globalThis.ResizeObserver = ResizeObserver
9
12
 
10
- describe("Step", async () => {
13
+ describe(Step, () => {
11
14
  test(`BRep`, async () => {
12
15
  const geode_object_type = ref("BRep")
13
16
  const files = ref([])
@@ -20,9 +23,7 @@ describe("Step", async () => {
20
23
  component: {
21
24
  component_name: shallowRef(ObjectSelector),
22
25
  component_options: {
23
- filenames: computed(() => {
24
- return files.value.map((file) => file.name)
25
- }),
26
+ filenames: computed(() => files.value.map((file) => file.name)),
26
27
  key: "",
27
28
  },
28
29
  },
@@ -43,6 +44,6 @@ describe("Step", async () => {
43
44
  },
44
45
  props: { step_index: 0 },
45
46
  })
46
- expect(wrapper.exists()).toBe(true)
47
+ expect(wrapper.exists()).toBeTruthy()
47
48
  })
48
49
  })
@@ -1,19 +1,24 @@
1
+ // Third party imports
2
+ import { computed, reactive, ref, shallowRef } from "vue"
1
3
  import { describe, expect, test } from "vitest"
2
- import { mountSuspended } from "@vue/test-utils"
4
+ import ResizeObserver from "resize-observer-polyfill"
5
+ import { mountSuspended } from "@nuxt/test-utils/runtime"
3
6
 
4
- import Stepper from "@ogw_front/components/Stepper"
7
+ // Local imports
5
8
  import ObjectSelector from "@ogw_front/components/ObjectSelector"
6
- import { mountSuspended } from "@nuxt/test-utils/runtime"
9
+ import Stepper from "@ogw_front/components/Stepper"
7
10
  import { vuetify } from "../../utils"
8
11
 
9
- global.ResizeObserver = require("resize-observer-polyfill")
12
+ const FIRST_INDEX = 0
13
+
14
+ globalThis.ResizeObserver = ResizeObserver
10
15
 
11
- describe("Stepper", async () => {
16
+ describe(Stepper, () => {
12
17
  test(`Mount`, async () => {
13
18
  const geode_object_type = ref("BRep")
14
19
  const files = ref([])
15
20
  const stepper_tree = reactive({
16
- current_step_index: ref(0),
21
+ current_step_index: ref(FIRST_INDEX),
17
22
  geode_object_type,
18
23
  steps: [
19
24
  {
@@ -21,18 +26,15 @@ describe("Stepper", async () => {
21
26
  component: {
22
27
  component_name: shallowRef(ObjectSelector),
23
28
  component_options: {
24
- filenames: computed(() => {
25
- return files.value.map((file) => file.name)
26
- }),
29
+ filenames: computed(() => files.value.map((file) => file.name)),
27
30
  key: "",
28
31
  },
29
32
  },
30
33
  chips: computed(() => {
31
34
  if (geode_object_type.value === "") {
32
35
  return []
33
- } else {
34
- return [geode_object_type.value]
35
36
  }
37
+ return [geode_object_type.value]
36
38
  }),
37
39
  },
38
40
  ],
@@ -43,6 +45,6 @@ describe("Stepper", async () => {
43
45
  provide: { stepper_tree },
44
46
  },
45
47
  })
46
- expect(wrapper.exists()).toBe(true)
48
+ expect(wrapper.exists()).toBeTruthy()
47
49
  })
48
50
  })
@@ -1,10 +1,32 @@
1
+ // Third party imports
1
2
  import { beforeEach, describe, expect, test, vi } from "vitest"
2
- import { setActivePinia } from "pinia"
3
- import { createTestingPinia } from "@pinia/testing"
4
3
 
5
4
  // Local imports
6
- import { useProjectManager } from "@ogw_front/composables/project_manager"
7
5
  import { appMode } from "@ogw_front/utils/app_mode"
6
+ import { setupActivePinia } from "../../utils"
7
+ import { useProjectManager } from "@ogw_front/composables/project_manager"
8
+
9
+ // Constants
10
+ const PANEL_WIDTH = 300
11
+ const Z_SCALE = 1.5
12
+ const FOCAL_POINT1 = 1
13
+ const FOCAL_POINT2 = 2
14
+ const FOCAL_POINT3 = 3
15
+ const FOCAL_POINT = [FOCAL_POINT1, FOCAL_POINT2, FOCAL_POINT3]
16
+ const VIEW_UP1 = 0
17
+ const VIEW_UP2 = 1
18
+ const VIEW_UP3 = 0
19
+ const VIEW_UP = [VIEW_UP1, VIEW_UP2, VIEW_UP3]
20
+ const POSITION1 = 10
21
+ const POSITION2 = 11
22
+ const POSITION3 = 12
23
+ const POSITION = [POSITION1, POSITION2, POSITION3]
24
+ const VIEW_ANGLE = 30
25
+ const CLIPPING_RANGE1 = 0.1
26
+ const CLIPPING_RANGE2 = 1000
27
+ const CLIPPING_RANGE = [CLIPPING_RANGE1, CLIPPING_RANGE2]
28
+ const POINT_SIZE = 2
29
+ const VIEWER_CALL_COUNT = 2
8
30
 
9
31
  // Snapshot
10
32
  const snapshotMock = {
@@ -23,10 +45,10 @@ const snapshotMock = {
23
45
  },
24
46
  treeview: {
25
47
  isAdditionnalTreeDisplayed: false,
26
- panelWidth: 320,
48
+ panelWidth: PANEL_WIDTH,
27
49
  model_id: "",
28
50
  isTreeCollection: false,
29
- selectedTree: null,
51
+ selectedTree: undefined,
30
52
  selectionIds: [],
31
53
  },
32
54
  dataStyle: {
@@ -37,21 +59,21 @@ const snapshotMock = {
37
59
  coloring: {
38
60
  active: "color",
39
61
  color: { r: 255, g: 255, b: 255 },
40
- vertex: null,
62
+ vertex: undefined,
41
63
  },
42
- size: 2,
64
+ size: POINT_SIZE,
43
65
  },
44
66
  },
45
67
  },
46
68
  },
47
69
  hybridViewer: {
48
- zScale: 1.5,
70
+ zScale: Z_SCALE,
49
71
  camera_options: {
50
- focal_point: [1, 2, 3],
51
- view_up: [0, 1, 0],
52
- position: [10, 11, 12],
53
- view_angle: 30,
54
- clipping_range: [0.1, 1000],
72
+ focal_point: FOCAL_POINT,
73
+ view_up: VIEW_UP,
74
+ position: POSITION,
75
+ view_angle: VIEW_ANGLE,
76
+ clipping_range: CLIPPING_RANGE,
55
77
  },
56
78
  },
57
79
  }
@@ -67,56 +89,54 @@ const infraStoreMock = {
67
89
  ID: "1234",
68
90
  }
69
91
  const viewerStoreMock = {
70
- ws_connect: vi.fn(() => Promise.resolve()),
92
+ ws_connect: vi.fn().mockResolvedValue(),
71
93
  base_url: vi.fn(() => ""),
72
- request: vi.fn(() => Promise.resolve()),
94
+ request: vi.fn().mockResolvedValue(),
73
95
  }
74
96
  const treeviewStoreMock = {
75
97
  clear: vi.fn(),
76
- importStores: vi.fn(() => Promise.resolve()),
98
+ importStores: vi.fn().mockResolvedValue(),
77
99
  finalizeImportSelection: vi.fn(),
78
- addItem: vi.fn(() => Promise.resolve()),
100
+ addItem: vi.fn().mockResolvedValue(),
79
101
  }
80
102
  const dataStoreMock = {
81
103
  clear: vi.fn(),
82
- registerObject: vi.fn(() => Promise.resolve()),
83
- addItem: vi.fn(() => Promise.resolve()),
104
+ registerObject: vi.fn().mockResolvedValue(),
105
+ addItem: vi.fn().mockResolvedValue(),
84
106
  }
85
107
  const dataStyleStoreMock = {
86
- importStores: vi.fn(() => Promise.resolve()),
87
- applyAllStylesFromState: vi.fn(() => Promise.resolve()),
88
- addDataStyle: vi.fn(() => Promise.resolve()),
89
- applyDefaultStyle: vi.fn(() => Promise.resolve()),
108
+ importStores: vi.fn().mockResolvedValue(),
109
+ applyAllStylesFromState: vi.fn().mockResolvedValue(),
110
+ addDataStyle: vi.fn().mockResolvedValue(),
111
+ applyDefaultStyle: vi.fn().mockResolvedValue(),
90
112
  }
113
+
114
+ const viewer_call_mock_fn = vi.fn().mockResolvedValue()
115
+
91
116
  const hybridViewerStoreMock = {
92
117
  clear: vi.fn(),
93
- initHybridViewer: vi.fn(() => Promise.resolve()),
94
- importStores: vi.fn(async (snapshot) => {
95
- if (snapshot?.zScale != null) {
118
+ initHybridViewer: vi.fn().mockResolvedValue(),
119
+ importStores: vi.fn((snapshot) => {
120
+ if (snapshot?.zScale !== undefined) {
96
121
  hybridViewerStoreMock.setZScaling(snapshot.zScale)
97
122
  }
98
123
  if (snapshot?.camera_options) {
99
- const { viewer_call } =
100
- await import("../../../internal/utils/viewer_call")
101
- viewer_call({
124
+ viewer_call_mock_fn({
102
125
  schema: { $id: "opengeodeweb_viewer.viewer.update_camera" },
103
126
  params: { camera_options: snapshot.camera_options },
104
127
  })
105
128
  hybridViewerStoreMock.remoteRender()
106
129
  }
107
130
  }),
108
- addItem: vi.fn(() => Promise.resolve()),
131
+ addItem: vi.fn().mockResolvedValue(),
109
132
  remoteRender: vi.fn(),
110
133
  setZScaling: vi.fn(),
111
134
  }
112
135
 
113
- // Mocks
114
- vi.stubGlobal(
115
- "$fetch",
116
- vi.fn(async () => ({ snapshot: snapshotMock })),
117
- )
136
+ // MOCKS
137
+ vi.stubGlobal("$fetch", vi.fn().mockResolvedValue({ snapshot: snapshotMock }))
118
138
  vi.mock("../../../internal/utils/viewer_call", () => ({
119
- viewer_call: vi.fn(() => Promise.resolve()),
139
+ viewer_call: viewer_call_mock_fn,
120
140
  }))
121
141
 
122
142
  vi.mock("@ogw_front/composables/api_fetch", () => ({
@@ -124,10 +144,12 @@ vi.mock("@ogw_front/composables/api_fetch", () => ({
124
144
  const response = {
125
145
  _data: new Blob(["zipcontent"], { type: "application/zip" }),
126
146
  headers: {
127
- get: (k) => (k === "new-file-name" ? "project_123.vease" : null),
147
+ get: (k) => (k === "new-file-name" ? "project_123.vease" : undefined),
128
148
  },
129
149
  }
130
- if (options.response_function) await options.response_function(response)
150
+ if (options.response_function) {
151
+ await options.response_function(response)
152
+ }
131
153
  return response
132
154
  }),
133
155
  }))
@@ -163,9 +185,9 @@ vi.stubGlobal("useAppStore", () => ({
163
185
  exportStores: vi.fn(() => ({ projectName: "mockedProject" })),
164
186
  }))
165
187
 
166
- const mockLockRequest = vi.fn().mockImplementation(async (name, callback) => {
167
- return callback({ name })
168
- })
188
+ const mockLockRequest = vi
189
+ .fn()
190
+ .mockImplementation(async (name, task) => await task({ name }))
169
191
 
170
192
  vi.stubGlobal("navigator", {
171
193
  ...navigator,
@@ -174,37 +196,85 @@ vi.stubGlobal("navigator", {
174
196
  },
175
197
  })
176
198
 
177
- describe("ProjectManager composable (compact)", () => {
178
- beforeEach(async () => {
179
- const pinia = createTestingPinia({ stubActions: false, createSpy: vi.fn })
180
- setActivePinia(pinia)
199
+ function verifyViewerCalls() {
200
+ expect(viewerStoreMock.ws_connect).toHaveBeenCalledWith()
201
+ expect(viewer_call_mock_fn).toHaveBeenCalledTimes(VIEWER_CALL_COUNT)
202
+ }
181
203
 
182
- // reset spies
183
- for (const store of [
184
- viewerStoreMock,
185
- treeviewStoreMock,
186
- dataStoreMock,
187
- dataStyleStoreMock,
188
- hybridViewerStoreMock,
189
- ]) {
190
- Object.values(store).forEach(
191
- (v) => typeof v === "function" && v.mockClear && v.mockClear(),
192
- )
204
+ function verifyStoreImports() {
205
+ expect(treeviewStoreMock.importStores).toHaveBeenCalledWith(
206
+ snapshotMock.treeview,
207
+ )
208
+ expect(hybridViewerStoreMock.initHybridViewer).toHaveBeenCalledWith()
209
+ expect(hybridViewerStoreMock.importStores).toHaveBeenCalledWith(
210
+ snapshotMock.hybridViewer,
211
+ )
212
+ expect(hybridViewerStoreMock.setZScaling).toHaveBeenCalledWith(Z_SCALE)
213
+ }
214
+
215
+ function verifyDataManagement() {
216
+ expect(dataStyleStoreMock.importStores).toHaveBeenCalledWith(
217
+ snapshotMock.dataStyle,
218
+ )
219
+ expect(dataStyleStoreMock.applyAllStylesFromState).toHaveBeenCalledWith()
220
+ expect(dataStoreMock.registerObject).toHaveBeenCalledWith("abc123")
221
+ expect(dataStoreMock.addItem).toHaveBeenCalledWith(
222
+ "abc123",
223
+ expect.anything(),
224
+ )
225
+ expect(treeviewStoreMock.addItem).toHaveBeenCalledWith(
226
+ "PointSet2D",
227
+ "My Data",
228
+ "abc123",
229
+ "mesh",
230
+ )
231
+ }
232
+
233
+ function verifyRemaining() {
234
+ expect(hybridViewerStoreMock.addItem).toHaveBeenCalledWith("abc123")
235
+ expect(dataStyleStoreMock.addDataStyle).toHaveBeenCalledWith(
236
+ "abc123",
237
+ "PointSet2D",
238
+ )
239
+ expect(dataStyleStoreMock.applyDefaultStyle).toHaveBeenCalledWith("abc123")
240
+ expect(hybridViewerStoreMock.remoteRender).toHaveBeenCalledWith()
241
+ }
242
+
243
+ beforeEach(() => {
244
+ setupActivePinia()
245
+ // reset spies
246
+ const storesList = [
247
+ viewerStoreMock,
248
+ treeviewStoreMock,
249
+ dataStoreMock,
250
+ dataStyleStoreMock,
251
+ hybridViewerStoreMock,
252
+ ]
253
+ for (const store of storesList) {
254
+ const values = Object.values(store)
255
+ for (const value of values) {
256
+ if (typeof value === "function" && value.mockClear) {
257
+ value.mockClear()
258
+ }
193
259
  }
194
- const { viewer_call } = await import("../../../internal/utils/viewer_call")
195
- viewer_call.mockClear()
196
- })
260
+ }
261
+ viewer_call_mock_fn.mockClear()
262
+ })
197
263
 
264
+ describe("projectManager composable (compact)", () => {
198
265
  test("exportProject", async () => {
199
266
  const { exportProject } = useProjectManager()
200
267
  const { default: fileDownload } = await import("js-file-download")
201
268
 
202
269
  await exportProject()
203
270
 
204
- expect(fileDownload).toHaveBeenCalled()
271
+ expect(fileDownload).toHaveBeenCalledWith(
272
+ { snapshot: snapshotMock },
273
+ "project.vease",
274
+ )
205
275
  })
206
276
 
207
- test("importProjectFile with snapshot", async () => {
277
+ test("importProjectFile with snapshot - Viewer and Stores", async () => {
208
278
  const { importProjectFile } = useProjectManager()
209
279
  const file = new Blob(['{"dataBase":{"db":{}}}'], {
210
280
  type: "application/json",
@@ -212,47 +282,19 @@ describe("ProjectManager composable (compact)", () => {
212
282
 
213
283
  await importProjectFile(file)
214
284
 
215
- const { viewer_call } = await import("../../../internal/utils/viewer_call")
216
-
217
- expect(viewerStoreMock.ws_connect).toHaveBeenCalled()
218
- expect(viewer_call).toHaveBeenCalledTimes(2)
219
-
220
- expect(treeviewStoreMock.importStores).toHaveBeenCalledWith(
221
- snapshotMock.treeview,
222
- )
223
- expect(hybridViewerStoreMock.initHybridViewer).toHaveBeenCalled()
224
- expect(hybridViewerStoreMock.importStores).toHaveBeenCalledWith(
225
- snapshotMock.hybridViewer,
226
- )
227
- expect(hybridViewerStoreMock.setZScaling).toHaveBeenCalledWith(1.5)
285
+ verifyViewerCalls()
286
+ verifyStoreImports()
287
+ })
228
288
 
229
- expect(dataStyleStoreMock.importStores).toHaveBeenCalledWith(
230
- snapshotMock.dataStyle,
231
- )
232
- expect(dataStyleStoreMock.applyAllStylesFromState).toHaveBeenCalled()
289
+ test("importProjectFile with snapshot - Data and Rendering", async () => {
290
+ const { importProjectFile } = useProjectManager()
291
+ const file = new Blob(['{"dataBase":{"db":{}}}'], {
292
+ type: "application/json",
293
+ })
233
294
 
234
- expect(dataStoreMock.registerObject).toHaveBeenCalledWith("abc123")
235
- expect(dataStoreMock.addItem).toHaveBeenCalledWith(
236
- "abc123",
237
- expect.objectContaining({
238
- viewer_type: "mesh",
239
- geode_object_type: "PointSet2D",
240
- name: "My Data",
241
- }),
242
- )
243
- expect(treeviewStoreMock.addItem).toHaveBeenCalledWith(
244
- "PointSet2D",
245
- "My Data",
246
- "abc123",
247
- "mesh",
248
- )
249
- expect(hybridViewerStoreMock.addItem).toHaveBeenCalledWith("abc123")
250
- expect(dataStyleStoreMock.addDataStyle).toHaveBeenCalledWith(
251
- "abc123",
252
- "PointSet2D",
253
- )
254
- expect(dataStyleStoreMock.applyDefaultStyle).toHaveBeenCalledWith("abc123")
295
+ await importProjectFile(file)
255
296
 
256
- expect(hybridViewerStoreMock.remoteRender).toHaveBeenCalled()
297
+ verifyDataManagement()
298
+ verifyRemaining()
257
299
  })
258
300
  })