@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,17 +1,16 @@
1
- import { describe, expect, test, beforeEach, vi } from "vitest"
2
- import { setActivePinia } from "pinia"
3
- import { createTestingPinia } from "@pinia/testing"
1
+ // Third party imports
2
+ import { beforeEach, describe, expect, test } from "vitest"
4
3
  import { registerEndpoint } from "@nuxt/test-utils/runtime"
5
4
 
6
- import { useGeodeStore } from "@ogw_front/stores/geode"
5
+ // Local imports
6
+ import { setupActivePinia } from "../../utils"
7
7
  import { useFeedbackStore } from "@ogw_front/stores/feedback"
8
+ import { useGeodeStore } from "@ogw_front/stores/geode"
9
+
10
+ const FIRST_INDEX = 0
8
11
 
9
12
  describe("geodeStore.request()", () => {
10
- const pinia = createTestingPinia({
11
- stubActions: false,
12
- createSpy: vi.fn,
13
- })
14
- setActivePinia(pinia)
13
+ setupActivePinia()
15
14
  const geodeStore = useGeodeStore()
16
15
  const feedbackStore = useFeedbackStore()
17
16
  geodeStore.base_url = ""
@@ -35,12 +34,6 @@ describe("geodeStore.request()", () => {
35
34
  geodeStore.base_url = ""
36
35
  })
37
36
 
38
- // test("valid schema and params", async () => {
39
- // const params = { test: "hello" }
40
- // const response = await api_fetch({ schema, params })
41
- // expect(response).toBeDefined()
42
- // })
43
-
44
37
  test("invalid schema", async () => {
45
38
  const schema = {
46
39
  $id: "/test",
@@ -55,14 +48,14 @@ describe("geodeStore.request()", () => {
55
48
  additionalProperties: false,
56
49
  }
57
50
  const params = { test: "hello" }
58
- expect(() => geodeStore.request(schema, params)).toThrowError(
51
+ expect(() => geodeStore.request(schema, params)).toThrow(
59
52
  "data/test must be number",
60
53
  )
61
54
  })
62
55
 
63
56
  test("invalid params", async () => {
64
57
  const params = {}
65
- expect(() => geodeStore.request(schema, params)).toThrowError(
58
+ expect(() => geodeStore.request(schema, params)).toThrow(
66
59
  "data must have required property 'test'",
67
60
  )
68
61
  })
@@ -76,30 +69,10 @@ describe("geodeStore.request()", () => {
76
69
  },
77
70
  }
78
71
  registerEndpoint(schema.$id, {
79
- method: schema.methods[0],
72
+ method: schema.methods[FIRST_INDEX],
80
73
  handler: () => ({ result: "success" }),
81
74
  })
82
75
  await geodeStore.request(schema, params, callbacks)
83
- expect(errorCalled).toBe(false)
76
+ expect(errorCalled).toBeFalsy()
84
77
  })
85
-
86
- // test("response handling", async () => {
87
- // const schema = {
88
- // $id: "/test",
89
- // type: "object",
90
- // methods: ["POST"],
91
- // properties: {
92
- // test: {
93
- // type: "string",
94
- // },
95
- // },
96
- // required: ["test"],
97
- // additionalProperties: false,
98
- // }
99
- // const params = { test: "hello" }
100
- // // const responseFunction = jest.fn()
101
- // const response = await api_fetch({ schema, params }, { response_function })
102
- // expect(responseFunction).toHaveBeenCalledTimes(1)
103
- // expect(response).toBeDefined()
104
- // })
105
78
  })
@@ -1,82 +1,57 @@
1
+ // Third party imports
2
+ import { flushPromises } from "@vue/test-utils"
1
3
  import { beforeEach, describe, expect, test, vi } from "vitest"
2
- import Status from "@ogw_front/utils/status"
3
-
4
- import { setActivePinia } from "pinia"
5
- import { createTestingPinia } from "@pinia/testing"
6
4
 
5
+ // Local imports
7
6
  import { run_function_when_microservices_connected } from "@ogw_front/composables/run_function_when_microservices_connected"
8
- import { useInfraStore } from "@ogw_front/stores/infra"
7
+ import { setupActivePinia } from "../../utils"
8
+ import Status from "@ogw_front/utils/status"
9
9
  import { useGeodeStore } from "@ogw_front/stores/geode"
10
+ import { useInfraStore } from "@ogw_front/stores/infra"
10
11
  import { useViewerStore } from "@ogw_front/stores/viewer"
11
12
 
12
- beforeEach(async () => {
13
- const pinia = createTestingPinia({
14
- stubActions: false,
15
- createSpy: vi.fn,
13
+ const dumb_obj = { dumb_method: () => true }
14
+ let infraStore
15
+ let geodeStore
16
+ let viewerStore
17
+
18
+ beforeEach(() => {
19
+ setupActivePinia()
20
+ infraStore = useInfraStore()
21
+ geodeStore = useGeodeStore()
22
+ viewerStore = useViewerStore()
23
+
24
+ // Register microservices in infra store
25
+ infraStore.register_microservice(geodeStore, {
26
+ request: vi.fn(),
27
+ connect: vi.fn(),
28
+ launch: vi.fn(),
16
29
  })
17
- setActivePinia(pinia)
18
- })
19
-
20
- describe("run_function_when_microservices_connected", () => {
21
- const dumb_obj = { dumb_method: () => true }
22
-
23
- beforeEach(async () => {
24
- const infraStore = useInfraStore()
25
- const geodeStore = useGeodeStore()
26
- const viewerStore = useViewerStore()
27
-
28
- // Register microservices in infra store
29
- infraStore.register_microservice(geodeStore, {
30
- request: vi.fn(),
31
- connect: vi.fn(),
32
- launch: vi.fn(),
33
- })
34
- infraStore.register_microservice(viewerStore, {
35
- request: vi.fn(),
36
- connect: vi.fn(),
37
- launch: vi.fn(),
38
- })
39
-
40
- await geodeStore.$patch({ status: Status.NOT_CONNECTED })
41
- await viewerStore.$patch({ status: Status.NOT_CONNECTED })
30
+ infraStore.register_microservice(viewerStore, {
31
+ request: vi.fn(),
32
+ connect: vi.fn(),
33
+ launch: vi.fn(),
42
34
  })
43
35
 
44
- test("microservices not connected", async () => {
45
- const geodeStore = useGeodeStore()
46
- const viewerStore = useViewerStore()
47
- const infraStore = useInfraStore()
48
- const spy = vi.spyOn(dumb_obj, "dumb_method")
49
- run_function_when_microservices_connected(dumb_obj.dumb_method)
50
- await geodeStore.$patch({ status: Status.NOT_CONNECTED })
51
- await viewerStore.$patch({ status: Status.NOT_CONNECTED })
52
- console.log("geodeStore", geodeStore.status)
53
- console.log("viewerStore", viewerStore.status)
36
+ geodeStore.$patch({ status: Status.NOT_CONNECTED })
37
+ viewerStore.$patch({ status: Status.NOT_CONNECTED })
38
+ })
54
39
 
55
- console.log("microservices_connected", infraStore.microservices_connected)
56
- expect(spy).not.toHaveBeenCalled()
57
- })
40
+ describe("when_microservices_connected_run_function", () => {
58
41
  test("microservices not connected", async () => {
59
- const geodeStore = useGeodeStore()
60
- const viewerStore = useViewerStore()
61
- const infraStore = useInfraStore()
62
42
  const spy = vi.spyOn(dumb_obj, "dumb_method")
63
43
  run_function_when_microservices_connected(dumb_obj.dumb_method)
64
- await geodeStore.$patch({ status: Status.NOT_CONNECTED })
65
- await viewerStore.$patch({ status: Status.NOT_CONNECTED })
66
- console.log("geodeStore", geodeStore.status)
67
- console.log("viewerStore", viewerStore.status)
68
-
69
- console.log("microservices_connected", infraStore.microservices_connected)
44
+ geodeStore.$patch({ status: Status.NOT_CONNECTED })
45
+ viewerStore.$patch({ status: Status.NOT_CONNECTED })
70
46
  expect(spy).not.toHaveBeenCalled()
71
47
  })
72
48
 
73
49
  test("microservices connected", async () => {
74
- const geodeStore = useGeodeStore()
75
- const viewerStore = useViewerStore()
76
50
  const spy = vi.spyOn(dumb_obj, "dumb_method")
77
51
  run_function_when_microservices_connected(dumb_obj.dumb_method)
78
- await geodeStore.$patch({ status: Status.CONNECTED })
79
- await viewerStore.$patch({ status: Status.CONNECTED })
80
- expect(spy).toHaveBeenCalled()
52
+ geodeStore.$patch({ status: Status.CONNECTED })
53
+ viewerStore.$patch({ status: Status.CONNECTED })
54
+ await flushPromises()
55
+ expect(spy).toHaveBeenCalledWith()
81
56
  })
82
57
  })
@@ -1,34 +1,30 @@
1
- import { describe, expect, test, beforeEach, vi } from "vitest"
2
- import { setActivePinia } from "pinia"
3
- import { createTestingPinia } from "@pinia/testing"
1
+ // Third party imports
2
+ import { beforeEach, describe, expect, test } from "vitest"
4
3
  import { registerEndpoint } from "@nuxt/test-utils/runtime"
5
- import upload_file from "@ogw_front/utils/upload_file"
6
4
  import schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json"
7
- import { useFeedbackStore } from "@ogw_front/stores/feedback"
8
5
 
6
+ // Local imports
7
+ import { setupActivePinia } from "../../utils"
8
+ import upload_file from "@ogw_front/utils/upload_file"
9
+ import { useFeedbackStore } from "@ogw_front/stores/feedback"
9
10
  import { useGeodeStore } from "@ogw_front/stores/geode"
11
+
12
+ const ZERO = 0
10
13
  const schema = schemas.opengeodeweb_back.upload_file
11
14
 
12
- beforeEach(async () => {
13
- const pinia = createTestingPinia({
14
- stubActions: false,
15
- createSpy: vi.fn,
16
- })
17
- setActivePinia(pinia)
15
+ beforeEach(() => {
16
+ setupActivePinia()
17
+ const geodeStore = useGeodeStore()
18
+ geodeStore.base_url = ""
18
19
  })
19
20
 
20
- describe("upload_file", () => {
21
- beforeEach(() => {
22
- const geodeStore = useGeodeStore()
23
- geodeStore.base_url = ""
24
- })
25
-
26
- test("Throw error", async () => {
27
- var file = "toto"
21
+ describe("upload_file test", () => {
22
+ test("throw error", async () => {
23
+ const file = "toto"
28
24
 
29
- expect(async () => {
30
- await upload_file({ route: schema.$id, file })
31
- }).rejects.toThrowError("file must be a instance of File")
25
+ await expect(upload_file({ route: schema.$id, file })).rejects.toThrow(
26
+ "file must be a instance of File",
27
+ )
32
28
  })
33
29
 
34
30
  test("onResponse", async () => {
@@ -37,8 +33,8 @@ describe("upload_file", () => {
37
33
  method: "PUT",
38
34
  handler: () => ({ test: "ok" }),
39
35
  })
40
- var file = new File(["fake_file"], "fake_file.txt")
41
- var response_value
36
+ const file = new File(["fake_file"], "fake_file.txt")
37
+ let response_value = ""
42
38
  await upload_file(
43
39
  { route: schema.$id, file },
44
40
  {
@@ -47,7 +43,7 @@ describe("upload_file", () => {
47
43
  },
48
44
  },
49
45
  )
50
- expect(feedbackStore.feedbacks.length).toBe(0)
46
+ expect(feedbackStore.feedbacks).toHaveLength(ZERO)
51
47
  expect(response_value).toBe("ok")
52
48
  })
53
49
  })
@@ -1,16 +1,22 @@
1
1
  import { beforeEach, describe, expect, test, vi } from "vitest"
2
- import { createTestingPinia } from "@pinia/testing"
3
- import { setActivePinia } from "pinia"
4
- import { database } from "../../../internal/database/database.js"
5
2
 
6
- import { useTreeviewStore } from "@ogw_front/stores/treeview"
7
3
  import { useAppStore } from "@ogw_front/stores/app"
4
+ import { useDataStore } from "@ogw_front/stores/data"
8
5
  import { useDataStyleStore } from "@ogw_front/stores/data_style"
9
6
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer"
10
- import { useDataStore } from "@ogw_front/stores/data"
7
+ import { useTreeviewStore } from "@ogw_front/stores/treeview"
8
+
9
+ import { database } from "../../../internal/database/database.js"
10
+ import { setupActivePinia } from "../../utils"
11
+
12
+ const PANEL_WIDTH = 320
13
+ const Z_SCALE = 1.5
14
+ const STORES_SLICE_START = 1
11
15
 
12
16
  vi.mock("../../../internal/utils/viewer_call", () => ({
13
- viewer_call: vi.fn(() => Promise.resolve()),
17
+ viewer_call: vi.fn(async () => {
18
+ await Promise.resolve()
19
+ }),
14
20
  }))
15
21
  vi.mock("../../../app/stores/hybrid_viewer", () => ({
16
22
  useHybridViewerStore: () => ({
@@ -25,12 +31,7 @@ vi.mock("../../../app/stores/hybrid_viewer", () => ({
25
31
  }))
26
32
 
27
33
  beforeEach(() => {
28
- setActivePinia(
29
- createTestingPinia({
30
- stubActions: false,
31
- createSpy: vi.fn,
32
- }),
33
- )
34
+ setupActivePinia()
34
35
  })
35
36
 
36
37
  describe("Project import", () => {
@@ -42,15 +43,15 @@ describe("Project import", () => {
42
43
  dataStyle: useDataStyleStore(),
43
44
  hybrid: useHybridViewerStore(),
44
45
  }
45
- Object.values(stores)
46
- .slice(1)
47
- .forEach((store) => stores.app.registerStore(store))
46
+ const storesArray = Object.values(stores)
47
+ for (const store of storesArray.slice(STORES_SLICE_START)) {
48
+ stores.app.registerStore(store)
49
+ }
48
50
 
49
51
  vi.spyOn(stores.dataBase, "importStores").mockImplementation(
50
52
  async (snapshot) => {
51
- for (const item of snapshot?.items || []) {
52
- await database.data.put(item)
53
- }
53
+ const items = snapshot?.items || []
54
+ await Promise.all(items.map((item) => database.data.put(item)))
54
55
  },
55
56
  )
56
57
 
@@ -73,13 +74,13 @@ describe("Project import", () => {
73
74
  selection: [],
74
75
  components_selection: [],
75
76
  isAdditionnalTreeDisplayed: false,
76
- panelWidth: 320,
77
+ panelWidth: PANEL_WIDTH,
77
78
  model_id: "",
78
79
  isTreeCollection: false,
79
- selectedTree: null,
80
+ selectedTree: undefined,
80
81
  },
81
82
  dataStyle: { styles: { abc123: { some: "style" } } },
82
- hybridViewer: { zScale: 1.5 },
83
+ hybridViewer: { zScale: Z_SCALE },
83
84
  }
84
85
 
85
86
  await stores.app.importStores(snapshot)
@@ -4,15 +4,19 @@ import { setActivePinia } from "pinia"
4
4
 
5
5
  import { useAppStore } from "@ogw_front/stores/app"
6
6
 
7
- beforeEach(async () => {
8
- const pinia = createTestingPinia({
9
- stubActions: false,
10
- createSpy: vi.fn,
11
- })
12
- setActivePinia(pinia)
13
- })
7
+ import { setupActivePinia } from "../../utils"
8
+
9
+ // Constants
10
+ const SINGLE_STORE_LENGTH = 1
11
+ const MULTIPLE_STORES_LENGTH = 2
12
+ const FIRST_INDEX = 0
13
+ const SECOND_INDEX = 1
14
+ const CALL_COUNT_ONCE = 1
14
15
 
15
- describe("App Store", () => {
16
+ beforeEach(() => {
17
+ setupActivePinia()
18
+ })
19
+ describe("app store", () => {
16
20
  describe("state", () => {
17
21
  test("initial state", () => {
18
22
  const appStore = useAppStore()
@@ -30,38 +34,38 @@ describe("App Store", () => {
30
34
  const mock_store = {
31
35
  $id: "testStore",
32
36
  save: vi.fn().mockImplementation(() => ({ data: "test" })),
33
- load: vi.fn().mockImplementation(() => {}),
37
+ load: vi.fn().mockImplementation(),
34
38
  }
35
39
 
36
40
  appStore.registerStore(mock_store)
37
41
 
38
- expect(appStore.stores.length).toBe(1)
39
- expect(appStore.stores[0]).toStrictEqual(mock_store)
42
+ expect(appStore.stores).toHaveLength(SINGLE_STORE_LENGTH)
43
+ expect(appStore.stores[FIRST_INDEX]).toStrictEqual(mock_store)
40
44
  })
41
45
 
42
46
  test("register multiple stores", () => {
43
47
  const appStore = useAppStore()
44
48
  const mock_store_1 = {
45
49
  $id: "userStore",
46
- save: vi.fn().mockImplementation(() => {}),
47
- load: vi.fn().mockImplementation(() => {}),
50
+ save: vi.fn().mockImplementation(),
51
+ load: vi.fn().mockImplementation(),
48
52
  }
49
53
  const mock_store_2 = {
50
54
  $id: "geodeStore",
51
- save: vi.fn().mockImplementation(() => {}),
52
- load: vi.fn().mockImplementation(() => {}),
55
+ save: vi.fn().mockImplementation(),
56
+ load: vi.fn().mockImplementation(),
53
57
  }
54
58
 
55
59
  appStore.registerStore(mock_store_1)
56
60
  appStore.registerStore(mock_store_2)
57
61
 
58
- expect(appStore.stores.length).toBe(2)
59
- expect(appStore.stores[0].$id).toBe("userStore")
60
- expect(appStore.stores[1].$id).toBe("geodeStore")
62
+ expect(appStore.stores).toHaveLength(MULTIPLE_STORES_LENGTH)
63
+ expect(appStore.stores[FIRST_INDEX].$id).toBe("userStore")
64
+ expect(appStore.stores[SECOND_INDEX].$id).toBe("geodeStore")
61
65
  })
62
66
  })
63
67
 
64
- describe("Export", () => {
68
+ describe("export", () => {
65
69
  test("export stores with exportStores method", async () => {
66
70
  const appStore = useAppStore()
67
71
  const mock_store_1 = {
@@ -70,14 +74,14 @@ describe("App Store", () => {
70
74
  name: "toto",
71
75
  email: "toto@titi.com",
72
76
  })),
73
- importStores: vi.fn().mockImplementation(() => {}),
77
+ importStores: vi.fn().mockImplementation(),
74
78
  }
75
79
  const mock_store_2 = {
76
80
  $id: "geodeStore",
77
81
  exportStores: vi
78
82
  .fn()
79
83
  .mockImplementation(() => ({ items: [], total: 0 })),
80
- importStores: vi.fn().mockImplementation(() => {}),
84
+ importStores: vi.fn().mockImplementation(),
81
85
  }
82
86
 
83
87
  appStore.registerStore(mock_store_1)
@@ -85,9 +89,9 @@ describe("App Store", () => {
85
89
 
86
90
  const snapshot = await appStore.exportStores()
87
91
 
88
- expect(mock_store_1.exportStores).toHaveBeenCalledTimes(1)
89
- expect(mock_store_2.exportStores).toHaveBeenCalledTimes(1)
90
- expect(snapshot).toEqual({
92
+ expect(mock_store_1.exportStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE)
93
+ expect(mock_store_2.exportStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE)
94
+ expect(snapshot).toStrictEqual({
91
95
  userStore: { name: "toto", email: "toto@titi.com" },
92
96
  geodeStore: { items: [], total: 0 },
93
97
  })
@@ -98,11 +102,11 @@ describe("App Store", () => {
98
102
  const mock_store_1 = {
99
103
  $id: "withSave",
100
104
  exportStores: vi.fn().mockImplementation(() => ({ data: "test" })),
101
- importStores: vi.fn().mockImplementation(() => {}),
105
+ importStores: vi.fn().mockImplementation(),
102
106
  }
103
107
  const mock_store_2 = {
104
108
  $id: "withoutSave",
105
- importStores: vi.fn().mockImplementation(() => {}),
109
+ importStores: vi.fn().mockImplementation(),
106
110
  }
107
111
 
108
112
  appStore.registerStore(mock_store_1)
@@ -110,7 +114,7 @@ describe("App Store", () => {
110
114
 
111
115
  const snapshot = await appStore.exportStores()
112
116
 
113
- expect(mock_store_1.exportStores).toHaveBeenCalledTimes(1)
117
+ expect(mock_store_1.exportStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE)
114
118
  expect(snapshot).toEqual({
115
119
  withSave: { data: "test" },
116
120
  })
@@ -120,12 +124,12 @@ describe("App Store", () => {
120
124
  test("return empty snapshot when no stores registered", async () => {
121
125
  const appStore = useAppStore()
122
126
  const snapshot = await appStore.exportStores()
123
- expect(snapshot).toEqual({})
127
+ expect(snapshot).toStrictEqual({})
124
128
  })
125
129
  })
126
130
 
127
131
  describe("load", () => {
128
- test("App Store > actions > importStores > import stores with importStores method", async () => {
132
+ test("import stores with importStores method", async () => {
129
133
  const appStore = useAppStore()
130
134
  const userStore = {
131
135
  $id: "userStore",
@@ -142,20 +146,20 @@ describe("App Store", () => {
142
146
  geodeStore: { other: "data" },
143
147
  }
144
148
  await appStore.importStores(snapshot)
145
- expect(userStore.importStores).toHaveBeenCalledTimes(1)
146
- expect(geodeStore.importStores).toHaveBeenCalledTimes(1)
149
+ expect(userStore.importStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE)
150
+ expect(geodeStore.importStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE)
147
151
  })
148
152
 
149
- test("skip stores without importStores method", () => {
153
+ test("skip stores without importStores method", async () => {
150
154
  const appStore = useAppStore()
151
155
  const mock_store_1 = {
152
156
  $id: "withImport",
153
- save: vi.fn().mockImplementation(() => {}),
154
- importStores: vi.fn().mockImplementation(() => {}),
157
+ save: vi.fn().mockImplementation(),
158
+ importStores: vi.fn().mockImplementation(),
155
159
  }
156
160
  const mock_store_2 = {
157
161
  $id: "withoutImport",
158
- save: vi.fn().mockImplementation(() => {}),
162
+ save: vi.fn().mockImplementation(),
159
163
  }
160
164
  appStore.registerStore(mock_store_1)
161
165
  appStore.registerStore(mock_store_2)
@@ -163,22 +167,20 @@ describe("App Store", () => {
163
167
  withImport: { data: "test" },
164
168
  withoutImport: { data: "ignored" },
165
169
  }
166
- appStore.importStores(snapshot)
167
- expect(mock_store_1.importStores).toHaveBeenCalledTimes(1)
170
+ await appStore.importStores(snapshot)
171
+ expect(mock_store_1.importStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE)
168
172
  expect(mock_store_2.importStores).toBeUndefined()
169
173
  })
170
174
 
171
- test("warn when store not found in snapshot", () => {
175
+ test("warn when store not found in snapshot", async () => {
172
176
  const appStore = useAppStore()
173
- const console_warn_spy = vi
174
- .spyOn(console, "warn")
175
- .mockImplementation(() => {})
177
+ const console_warn_spy = vi.spyOn(console, "warn").mockImplementation()
176
178
  const mock_store = {
177
179
  $id: "testStore",
178
- importStores: vi.fn().mockImplementation(() => {}),
180
+ importStores: vi.fn().mockImplementation(),
179
181
  }
180
182
  appStore.registerStore(mock_store)
181
- appStore.importStores({})
183
+ await appStore.importStores({})
182
184
  expect(console_warn_spy).toHaveBeenCalledWith(
183
185
  expect.stringContaining("Stores not found in snapshot: testStore"),
184
186
  )
@@ -1,14 +1,12 @@
1
- import { setActivePinia } from "pinia"
2
- import { createTestingPinia } from "@pinia/testing"
1
+ // Third party imports
2
+ import { beforeEach, describe, expect, expectTypeOf, test } from "vitest"
3
+
4
+ // Local imports
5
+ import { setupActivePinia } from "../../utils"
3
6
  import { useFeedbackStore } from "@ogw_front/stores/feedback"
4
- import { beforeEach, describe, expect, expectTypeOf, test, vi } from "vitest"
5
7
 
6
- beforeEach(async () => {
7
- const pinia = createTestingPinia({
8
- stubActions: false,
9
- createSpy: vi.fn,
10
- })
11
- setActivePinia(pinia)
8
+ beforeEach(() => {
9
+ setupActivePinia()
12
10
  })
13
11
 
14
12
  describe("Feedback Store", () => {
@@ -19,6 +17,7 @@ describe("Feedback Store", () => {
19
17
  expectTypeOf(feedbackStore.server_error).toBeBoolean()
20
18
  })
21
19
  })
20
+
22
21
  describe("actions", () => {
23
22
  describe("add_error", () => {
24
23
  test("test add_error", () => {
@@ -29,12 +28,10 @@ describe("Feedback Store", () => {
29
28
  "test message",
30
29
  "test description",
31
30
  )
32
- expect(feedbackStore.feedbacks.length).toBe(1)
31
+ expect(feedbackStore.feedbacks).toHaveLength(1)
33
32
  expect(feedbackStore.feedbacks[0].type).toBe("error")
34
33
  })
35
- })
36
34
 
37
- describe("add_error", () => {
38
35
  test("test feedbacks_timeout", () => {
39
36
  const feedbackStore = useFeedbackStore()
40
37
  feedbackStore.feedbacks_timeout_miliseconds = 500
@@ -44,9 +41,9 @@ describe("Feedback Store", () => {
44
41
  "test message",
45
42
  "test description",
46
43
  )
47
- expect(feedbackStore.feedbacks.length).toBe(1)
44
+ expect(feedbackStore.feedbacks).toHaveLength(1)
48
45
  setTimeout(() => {
49
- expect(feedbackStore.feedbacks.length).toBe(0)
46
+ expect(feedbackStore.feedbacks).toHaveLength(0)
50
47
  }, 1000)
51
48
  })
52
49
  })
@@ -56,19 +53,20 @@ describe("Feedback Store", () => {
56
53
  const feedbackStore = useFeedbackStore()
57
54
  feedbackStore.feedbacks_timeout_miliseconds = 500
58
55
  feedbackStore.add_success("test description")
59
- expect(feedbackStore.feedbacks.length).toBe(1)
56
+ expect(feedbackStore.feedbacks).toHaveLength(1)
60
57
  expect(feedbackStore.feedbacks[0].type).toBe("success")
61
58
 
62
59
  setTimeout(() => {
63
- expect(feedbackStore.feedbacks.length).toBe(0)
60
+ expect(feedbackStore.feedbacks).toHaveLength(0)
64
61
  }, 1000)
65
62
  })
66
63
  })
64
+
67
65
  describe("delete_feedback", () => {
68
66
  test("test", () => {
69
67
  const feedbackStore = useFeedbackStore()
70
68
  feedbackStore.delete_feedback(0)
71
- expect(feedbackStore.feedbacks.length).toBe(0)
69
+ expect(feedbackStore.feedbacks).toHaveLength(0)
72
70
  })
73
71
  })
74
72
 
@@ -77,7 +75,7 @@ describe("Feedback Store", () => {
77
75
  const feedbackStore = useFeedbackStore()
78
76
  feedbackStore.$patch({ server_error: true })
79
77
  feedbackStore.delete_server_error()
80
- expect(feedbackStore.server_error).toBe(false)
78
+ expect(feedbackStore.server_error).toBeFalsy()
81
79
  })
82
80
  })
83
81
  })