@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,164 +1,162 @@
1
- import { setActivePinia } from "pinia"
2
- import { createTestingPinia } from "@pinia/testing"
3
- import { describe, test, expect, expectTypeOf, beforeEach, vi } from "vitest"
4
- import { registerEndpoint } from "@nuxt/test-utils/runtime"
1
+ // Third party imports
5
2
  import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json"
6
- import Status from "@ogw_front/utils/status"
3
+ import { registerEndpoint } from "@nuxt/test-utils/runtime"
4
+ import { describe, expect, expectTypeOf, test, vi } from "vitest"
5
+
6
+ // Local imports
7
7
  import { appMode } from "@ogw_front/utils/app_mode"
8
- import { useInfraStore } from "@ogw_front/stores/infra"
8
+ import { setupActivePinia } from "../../utils"
9
+ import Status from "@ogw_front/utils/status"
9
10
  import { useGeodeStore } from "@ogw_front/stores/geode"
11
+ import { useInfraStore } from "@ogw_front/stores/infra"
10
12
 
11
- beforeEach(async () => {
12
- const pinia = createTestingPinia({
13
- stubActions: false,
14
- createSpy: vi.fn,
15
- })
16
- setActivePinia(pinia)
13
+ // CONSTANTS
14
+ const PORT_443 = "443"
15
+ const PORT_12 = "12"
16
+ const PORT_5000 = "5000"
17
+ const CLOUD_ID = "123456"
18
+ const STATUS_500 = 500
19
+ const EXPECTED_ONE_REQUEST = 1
20
+ const EXPECTED_NO_REQUEST = 0
21
+
22
+ beforeEach(() => {
23
+ setupActivePinia()
17
24
  })
18
25
 
19
- describe("Geode store", () => {
20
- describe("state", () => {
21
- test("initial state", () => {
26
+ describe("geode store", () => {
27
+ test("state", () => {
28
+ const geodeStore = useGeodeStore()
29
+ expectTypeOf(geodeStore.default_local_port).toBeString()
30
+ expectTypeOf(geodeStore.request_counter).toBeNumber()
31
+ expectTypeOf(geodeStore.status).toBeString()
32
+ })
33
+
34
+ describe("protocol", () => {
35
+ test("app_mode CLOUD", () => {
36
+ const infraStore = useInfraStore()
37
+ const geodeStore = useGeodeStore()
38
+ infraStore.app_mode = appMode.CLOUD
39
+ expect(geodeStore.protocol).toBe("https")
40
+ })
41
+
42
+ test("app_mode BROWSER/DESKTOP", () => {
43
+ const infraStore = useInfraStore()
22
44
  const geodeStore = useGeodeStore()
23
- expectTypeOf(geodeStore.default_local_port).toBeString()
24
- expectTypeOf(geodeStore.request_counter).toBeNumber()
25
- expectTypeOf(geodeStore.status).toBeString()
45
+ infraStore.app_mode = appMode.BROWSER
46
+ expect(geodeStore.protocol).toBe("http")
47
+ infraStore.app_mode = appMode.DESKTOP
48
+ expect(geodeStore.protocol).toBe("http")
26
49
  })
27
50
  })
28
51
 
29
- describe("getters", () => {
30
- describe("protocol", () => {
31
- test("test app_mode CLOUD", () => {
32
- const infraStore = useInfraStore()
33
- const geodeStore = useGeodeStore()
34
- infraStore.app_mode = appMode.CLOUD
35
- expect(geodeStore.protocol).toBe("https")
36
- })
37
- test("test app_mode BROWSER", () => {
38
- const infraStore = useInfraStore()
39
- const geodeStore = useGeodeStore()
40
- infraStore.app_mode = appMode.BROWSER
41
- expect(geodeStore.protocol).toBe("http")
42
- })
43
- test("test app_mode DESKTOP", () => {
44
- const infraStore = useInfraStore()
45
- const geodeStore = useGeodeStore()
46
- infraStore.app_mode = appMode.DESKTOP
47
- expect(geodeStore.protocol).toBe("http")
48
- })
52
+ describe("port", () => {
53
+ test("app_mode CLOUD", () => {
54
+ const infraStore = useInfraStore()
55
+ const geodeStore = useGeodeStore()
56
+ infraStore.app_mode = appMode.CLOUD
57
+ expect(geodeStore.port).toBe(PORT_443)
49
58
  })
50
59
 
51
- describe("port", () => {
52
- test("test app_mode CLOUD", () => {
53
- const infraStore = useInfraStore()
54
- const geodeStore = useGeodeStore()
55
- infraStore.app_mode = appMode.CLOUD
56
- expect(geodeStore.port).toBe("443")
57
- })
58
- test("test app_mode BROWSER", () => {
59
- const infraStore = useInfraStore()
60
- const geodeStore = useGeodeStore()
61
- infraStore.app_mode = appMode.BROWSER
62
- expect(geodeStore.port).toBe(geodeStore.default_local_port)
63
- })
64
- test("test app_mode DESKTOP", () => {
65
- const infraStore = useInfraStore()
66
- const geodeStore = useGeodeStore()
67
- infraStore.app_mode = appMode.DESKTOP
68
- expect(geodeStore.port).toBe(geodeStore.default_local_port)
69
- })
60
+ test("app_mode BROWSER/DESKTOP", () => {
61
+ const infraStore = useInfraStore()
62
+ const geodeStore = useGeodeStore()
63
+ infraStore.app_mode = appMode.BROWSER
64
+ expect(geodeStore.port).toBe(geodeStore.default_local_port)
65
+ infraStore.app_mode = appMode.DESKTOP
66
+ expect(geodeStore.port).toBe(geodeStore.default_local_port)
67
+ })
70
68
 
71
- test("test override default_local_port", () => {
72
- const infraStore = useInfraStore()
73
- const geodeStore = useGeodeStore()
74
- infraStore.app_mode = appMode.DESKTOP
75
- geodeStore.default_local_port = "12"
76
- expect(geodeStore.port).toBe("12")
77
- })
69
+ test("override default_local_port", () => {
70
+ const infraStore = useInfraStore()
71
+ const geodeStore = useGeodeStore()
72
+ infraStore.app_mode = appMode.DESKTOP
73
+ geodeStore.default_local_port = PORT_12
74
+ expect(geodeStore.port).toBe(PORT_12)
78
75
  })
76
+ })
79
77
 
80
- describe("base_url", () => {
81
- test("test app_mode BROWSER", () => {
82
- const infraStore = useInfraStore()
83
- const geodeStore = useGeodeStore()
84
- infraStore.app_mode = appMode.BROWSER
85
- infraStore.domain_name = "localhost"
86
- expect(geodeStore.base_url).toBe("http://localhost:5000")
87
- })
88
- test("test app_mode CLOUD", () => {
89
- const infraStore = useInfraStore()
90
- const geodeStore = useGeodeStore()
91
- infraStore.app_mode = appMode.CLOUD
92
- infraStore.ID = "123456"
93
- infraStore.domain_name = "example.com"
94
- expect(geodeStore.base_url).toBe("https://example.com:443/123456/geode")
95
- })
96
- test("test app_mode CLOUD, ID empty", () => {
97
- const infraStore = useInfraStore()
98
- const geodeStore = useGeodeStore()
99
- infraStore.app_mode = appMode.CLOUD
100
- infraStore.ID = ""
101
- infraStore.domain_name = "example.com"
102
- expect(() => geodeStore.base_url).toThrowError(
103
- "ID must not be empty in cloud mode",
104
- )
105
- })
78
+ describe("base_url", () => {
79
+ test("app_mode BROWSER", () => {
80
+ const infraStore = useInfraStore()
81
+ const geodeStore = useGeodeStore()
82
+ infraStore.app_mode = appMode.BROWSER
83
+ infraStore.domain_name = "localhost"
84
+ expect(geodeStore.base_url).toBe(`http://localhost:${PORT_5000}`)
106
85
  })
107
86
 
108
- describe("is_busy", () => {
109
- test("test is_busy", () => {
110
- const geodeStore = useGeodeStore()
111
- geodeStore.request_counter = 1
112
- expect(geodeStore.is_busy).toBe(true)
113
- })
114
- test("test not is_busy", () => {
115
- const geodeStore = useGeodeStore()
116
- geodeStore.request_counter = 0
117
- expect(geodeStore.is_busy).toBe(false)
118
- })
87
+ test("app_mode CLOUD", () => {
88
+ const infraStore = useInfraStore()
89
+ const geodeStore = useGeodeStore()
90
+ infraStore.app_mode = appMode.CLOUD
91
+ infraStore.ID = CLOUD_ID
92
+ infraStore.domain_name = "example.com"
93
+ expect(geodeStore.base_url).toBe(
94
+ `https://example.com:${PORT_443}/${CLOUD_ID}/geode`,
95
+ )
96
+ })
97
+
98
+ test("app_mode CLOUD, ID empty", () => {
99
+ const infraStore = useInfraStore()
100
+ const geodeStore = useGeodeStore()
101
+ infraStore.app_mode = appMode.CLOUD
102
+ infraStore.ID = ""
103
+ infraStore.domain_name = "example.com"
104
+ expect(() => geodeStore.base_url).toThrow(
105
+ "ID must not be empty in cloud mode",
106
+ )
119
107
  })
120
108
  })
121
109
 
122
- describe("actions", () => {
123
- describe("ping", () => {
124
- const getFakeCall = vi.fn()
125
- registerEndpoint(back_schemas.opengeodeweb_back.ping.$id, getFakeCall)
126
-
127
- test("response", async () => {
128
- const geodeStore = useGeodeStore()
129
- geodeStore.base_url = ""
130
- getFakeCall.mockImplementation(() => ({}))
131
- await geodeStore.ping()
132
- expect(geodeStore.status).toBe(Status.CONNECTED)
133
- })
134
- test("response_error", async () => {
135
- const geodeStore = useGeodeStore()
136
- geodeStore.base_url = ""
137
- getFakeCall.mockImplementation(() => {
138
- throw createError({
139
- status: 500,
140
- })
141
- })
142
- await expect(geodeStore.ping()).rejects.toThrow()
143
- expect(geodeStore.status).toBe(Status.NOT_CONNECTED)
144
- })
110
+ describe("is_busy", () => {
111
+ test("is_busy", () => {
112
+ const geodeStore = useGeodeStore()
113
+ geodeStore.request_counter = EXPECTED_ONE_REQUEST
114
+ expect(geodeStore.is_busy).toBeTruthy()
145
115
  })
146
116
 
147
- describe("start_request", () => {
148
- test("test increment", async () => {
149
- const geodeStore = useGeodeStore()
150
- expect(geodeStore.request_counter).toBe(0)
151
- await geodeStore.start_request()
152
- expect(geodeStore.request_counter).toBe(1)
153
- })
117
+ test("not is_busy", () => {
118
+ const geodeStore = useGeodeStore()
119
+ geodeStore.request_counter = EXPECTED_NO_REQUEST
120
+ expect(geodeStore.is_busy).toBeFalsy()
154
121
  })
155
- describe("stop_request", () => {
156
- test("test decrement", async () => {
157
- const geodeStore = useGeodeStore()
158
- geodeStore.request_counter = 1
159
- await geodeStore.stop_request()
160
- expect(geodeStore.request_counter).toBe(0)
122
+ })
123
+ })
124
+
125
+ describe("geode store actions", () => {
126
+ const getFakeCall = vi.fn()
127
+
128
+ beforeEach(() => {
129
+ registerEndpoint(back_schemas.opengeodeweb_back.ping.$id, getFakeCall)
130
+ })
131
+
132
+ describe("ping", () => {
133
+ test("response", async () => {
134
+ const geodeStore = useGeodeStore()
135
+ geodeStore.base_url = ""
136
+ getFakeCall.mockImplementation(() => ({}))
137
+ await geodeStore.ping()
138
+ expect(geodeStore.status).toBe(Status.CONNECTED)
139
+ })
140
+
141
+ test("response_error", async () => {
142
+ const geodeStore = useGeodeStore()
143
+ geodeStore.base_url = ""
144
+ getFakeCall.mockImplementation(() => {
145
+ throw createError({ status: STATUS_500 })
161
146
  })
147
+ await expect(geodeStore.ping()).rejects.toThrow("500")
148
+ expect(geodeStore.status).toBe(Status.NOT_CONNECTED)
149
+ })
150
+ })
151
+
152
+ describe("request counter", () => {
153
+ test("increment/decrement", async () => {
154
+ const geodeStore = useGeodeStore()
155
+ expect(geodeStore.request_counter).toBe(EXPECTED_NO_REQUEST)
156
+ await geodeStore.start_request()
157
+ expect(geodeStore.request_counter).toBe(EXPECTED_ONE_REQUEST)
158
+ await geodeStore.stop_request()
159
+ expect(geodeStore.request_counter).toBe(EXPECTED_NO_REQUEST)
162
160
  })
163
161
  })
164
162
  })
@@ -1,22 +1,20 @@
1
- // Global imports
2
-
3
1
  // Third party imports
4
- import { registerEndpoint } from "@nuxt/test-utils/runtime"
5
- import { setActivePinia } from "pinia"
6
- import { createTestingPinia } from "@pinia/testing"
7
2
  import { beforeEach, describe, expect, expectTypeOf, test, vi } from "vitest"
3
+ import { registerEndpoint } from "@nuxt/test-utils/runtime"
4
+
8
5
  // Local imports
9
6
  import Status from "@ogw_front/utils/status"
10
7
  import { appMode } from "@ogw_front/utils/app_mode"
11
- import { useInfraStore } from "@ogw_front/stores/infra"
8
+ import { setupActivePinia } from "../../utils"
12
9
  import { useGeodeStore } from "@ogw_front/stores/geode"
13
- import { useViewerStore } from "@ogw_front/stores/viewer"
10
+ import { useInfraStore } from "@ogw_front/stores/infra"
14
11
  import { useLambdaStore } from "@ogw_front/stores/lambda"
12
+ import { useViewerStore } from "@ogw_front/stores/viewer"
15
13
 
16
14
  // Mock navigator.locks API
17
- const mockLockRequest = vi.fn().mockImplementation(async (name, callback) => {
18
- return callback({ name })
19
- })
15
+ const mockLockRequest = vi
16
+ .fn()
17
+ .mockImplementation(async (name, handler) => await handler({ name }))
20
18
 
21
19
  vi.stubGlobal("navigator", {
22
20
  ...navigator,
@@ -25,12 +23,8 @@ vi.stubGlobal("navigator", {
25
23
  },
26
24
  })
27
25
 
28
- beforeEach(async () => {
29
- const pinia = createTestingPinia({
30
- stubActions: false,
31
- createSpy: vi.fn,
32
- })
33
- setActivePinia(pinia)
26
+ beforeEach(() => {
27
+ setupActivePinia()
34
28
  })
35
29
 
36
30
  describe("Infra Store", () => {
@@ -71,7 +65,7 @@ describe("Infra Store", () => {
71
65
  describe("microservices_connected", () => {
72
66
  test("test no microservices registered", () => {
73
67
  const infraStore = useInfraStore()
74
- expect(infraStore.microservices_connected).toBe(true)
68
+ expect(infraStore.microservices_connected).toBeTruthy()
75
69
  })
76
70
  test("test geode false & viewer false", () => {
77
71
  const infraStore = useInfraStore()
@@ -91,7 +85,7 @@ describe("Infra Store", () => {
91
85
 
92
86
  geodeStore.$patch({ status: Status.NOT_CONNECTED })
93
87
  viewerStore.$patch({ status: Status.NOT_CONNECTED })
94
- expect(infraStore.microservices_connected).toBe(false)
88
+ expect(infraStore.microservices_connected).toBeFalsy()
95
89
  })
96
90
  test("test geode true & viewer false", () => {
97
91
  const infraStore = useInfraStore()
@@ -111,7 +105,7 @@ describe("Infra Store", () => {
111
105
 
112
106
  geodeStore.$patch({ status: Status.CONNECTED })
113
107
  viewerStore.$patch({ status: Status.NOT_CONNECTED })
114
- expect(infraStore.microservices_connected).toBe(false)
108
+ expect(infraStore.microservices_connected).toBeFalsy()
115
109
  })
116
110
  test("test geode false & viewer true", () => {
117
111
  const infraStore = useInfraStore()
@@ -131,7 +125,7 @@ describe("Infra Store", () => {
131
125
 
132
126
  geodeStore.$patch({ status: Status.NOT_CONNECTED })
133
127
  viewerStore.$patch({ status: Status.CONNECTED })
134
- expect(infraStore.microservices_connected).toBe(false)
128
+ expect(infraStore.microservices_connected).toBeFalsy()
135
129
  })
136
130
  test("test geode true & viewer true", () => {
137
131
  const infraStore = useInfraStore()
@@ -151,14 +145,14 @@ describe("Infra Store", () => {
151
145
 
152
146
  geodeStore.$patch({ status: Status.CONNECTED })
153
147
  viewerStore.$patch({ status: Status.CONNECTED })
154
- expect(infraStore.microservices_connected).toBe(true)
148
+ expect(infraStore.microservices_connected).toBeTruthy()
155
149
  })
156
150
  })
157
151
 
158
152
  describe("microservices_busy", () => {
159
153
  test("test no microservices registered", () => {
160
154
  const infraStore = useInfraStore()
161
- expect(infraStore.microservices_busy).toBe(false)
155
+ expect(infraStore.microservices_busy).toBeFalsy()
162
156
  })
163
157
  test("test geode false & viewer false", () => {
164
158
  const infraStore = useInfraStore()
@@ -178,7 +172,7 @@ describe("Infra Store", () => {
178
172
 
179
173
  geodeStore.$patch({ request_counter: 0 })
180
174
  viewerStore.$patch({ request_counter: 0 })
181
- expect(infraStore.microservices_busy).toBe(false)
175
+ expect(infraStore.microservices_busy).toBeFalsy()
182
176
  })
183
177
  test("test geode true & viewer false", () => {
184
178
  const infraStore = useInfraStore()
@@ -198,7 +192,7 @@ describe("Infra Store", () => {
198
192
 
199
193
  geodeStore.$patch({ request_counter: 1 })
200
194
  viewerStore.$patch({ request_counter: 0 })
201
- expect(infraStore.microservices_busy).toBe(true)
195
+ expect(infraStore.microservices_busy).toBeTruthy()
202
196
  })
203
197
  test("test geode false & viewer true", () => {
204
198
  const infraStore = useInfraStore()
@@ -218,7 +212,7 @@ describe("Infra Store", () => {
218
212
 
219
213
  geodeStore.$patch({ request_counter: 0 })
220
214
  viewerStore.$patch({ request_counter: 1 })
221
- expect(infraStore.microservices_busy).toBe(true)
215
+ expect(infraStore.microservices_busy).toBeTruthy()
222
216
  })
223
217
  test("test geode true & viewer true", () => {
224
218
  const infraStore = useInfraStore()
@@ -238,7 +232,7 @@ describe("Infra Store", () => {
238
232
 
239
233
  geodeStore.$patch({ request_counter: 1 })
240
234
  viewerStore.$patch({ request_counter: 1 })
241
- expect(infraStore.microservices_busy).toBe(true)
235
+ expect(infraStore.microservices_busy).toBeTruthy()
242
236
  })
243
237
  })
244
238
  })
@@ -1,25 +1,32 @@
1
- // Global imports
2
-
3
1
  // Third party imports
4
- import { registerEndpoint } from "@nuxt/test-utils/runtime"
5
- import { setActivePinia } from "pinia"
6
- import { createTestingPinia } from "@pinia/testing"
7
2
  import { beforeEach, describe, expect, expectTypeOf, test, vi } from "vitest"
3
+ import { registerEndpoint } from "@nuxt/test-utils/runtime"
8
4
 
5
+ // Local imports
6
+ import Status from "@ogw_front/utils/status"
7
+ import { setupActivePinia } from "../../utils"
9
8
  import { useFeedbackStore } from "@ogw_front/stores/feedback"
10
9
  import { useLambdaStore } from "@ogw_front/stores/lambda"
11
10
 
12
- // Local imports
13
- import Status from "@ogw_front/utils/status"
11
+ // CONSTANTS
12
+ const PORT_443 = "443"
13
+ const API_URL = "api.example.com"
14
+ const SITE_BRANCH = "/test"
15
+ const PROJECT = "/project"
16
+ const TEST_ID = "test-id-123456"
17
+ const STATUS_500 = 500
14
18
 
15
19
  beforeEach(async () => {
16
- const pinia = createTestingPinia({
17
- stubActions: false,
18
- createSpy: vi.fn,
19
- })
20
- setActivePinia(pinia)
20
+ setupActivePinia()
21
21
  })
22
22
 
23
+ function setupConfig() {
24
+ const config = useRuntimeConfig()
25
+ config.public.API_URL = API_URL
26
+ config.public.SITE_BRANCH = SITE_BRANCH
27
+ config.public.PROJECT = PROJECT
28
+ }
29
+
23
30
  describe("Lambda Store", () => {
24
31
  describe("state", () => {
25
32
  test("initial state", () => {
@@ -40,18 +47,16 @@ describe("Lambda Store", () => {
40
47
  describe("port", () => {
41
48
  test("test port is always 443", () => {
42
49
  const lambdaStore = useLambdaStore()
43
- expect(lambdaStore.port).toBe("443")
50
+ expect(lambdaStore.port).toBe(PORT_443)
44
51
  })
45
52
  })
46
53
 
47
54
  describe("base_url", () => {
48
55
  test("test base_url construction", () => {
56
+ setupConfig()
49
57
  const lambdaStore = useLambdaStore()
50
- useRuntimeConfig().public.API_URL = "api.example.com"
51
- useRuntimeConfig().public.SITE_BRANCH = "/test"
52
- useRuntimeConfig().public.PROJECT = "/project"
53
58
  expect(lambdaStore.base_url).toBe(
54
- "https://api.example.com:443/test/project/createbackend",
59
+ `https://${API_URL}:${PORT_443}${SITE_BRANCH}${PROJECT}/createbackend`,
55
60
  )
56
61
  })
57
62
  })
@@ -59,7 +64,7 @@ describe("Lambda Store", () => {
59
64
  describe("is_busy", () => {
60
65
  test("test is_busy is always false", () => {
61
66
  const lambdaStore = useLambdaStore()
62
- expect(lambdaStore.is_busy).toBe(false)
67
+ expect(lambdaStore.is_busy).toBeFalsy()
63
68
  })
64
69
  })
65
70
  })
@@ -69,13 +74,10 @@ describe("Lambda Store", () => {
69
74
  const postFakeCall = vi.fn()
70
75
 
71
76
  test("successful launch", async () => {
77
+ setupConfig()
72
78
  const lambdaStore = useLambdaStore()
73
79
  const feedbackStore = useFeedbackStore()
74
80
 
75
- useRuntimeConfig().public.API_URL = "api.example.com"
76
- useRuntimeConfig().public.SITE_BRANCH = "/test"
77
- useRuntimeConfig().public.PROJECT = "/project"
78
-
79
81
  lambdaStore.base_url = "test-base-url"
80
82
  registerEndpoint(lambdaStore.base_url, {
81
83
  method: "POST",
@@ -83,24 +85,21 @@ describe("Lambda Store", () => {
83
85
  })
84
86
 
85
87
  postFakeCall.mockImplementation(() => ({
86
- ID: "test-id-123456",
88
+ ID: TEST_ID,
87
89
  }))
88
90
 
89
91
  const id = await lambdaStore.launch()
90
92
 
91
93
  expect(lambdaStore.status).toBe(Status.CONNECTED)
92
- expect(id).toBe("test-id-123456")
93
- expect(feedbackStore.server_error).toBe(false)
94
+ expect(id).toBe(TEST_ID)
95
+ expect(feedbackStore.server_error).toBeFalsy()
94
96
  })
95
97
 
96
98
  test("failed launch - error response", async () => {
99
+ setupConfig()
97
100
  const lambdaStore = useLambdaStore()
98
101
  const feedbackStore = useFeedbackStore()
99
102
 
100
- useRuntimeConfig().public.API_URL = "api.example.com"
101
- useRuntimeConfig().public.SITE_BRANCH = "/test"
102
- useRuntimeConfig().public.PROJECT = "/project"
103
-
104
103
  registerEndpoint(lambdaStore.base_url, {
105
104
  method: "POST",
106
105
  handler: postFakeCall,
@@ -108,7 +107,7 @@ describe("Lambda Store", () => {
108
107
 
109
108
  postFakeCall.mockImplementation(() => {
110
109
  throw createError({
111
- status: 500,
110
+ status: STATUS_500,
112
111
  statusMessage: "Internal Server Error",
113
112
  })
114
113
  })
@@ -118,7 +117,7 @@ describe("Lambda Store", () => {
118
117
  )
119
118
 
120
119
  expect(lambdaStore.status).toBe(Status.NOT_CONNECTED)
121
- expect(feedbackStore.server_error).toBe(true)
120
+ expect(feedbackStore.server_error).toBeTruthy()
122
121
  })
123
122
  })
124
123