@geode/opengeodeweb-front 10.6.2 → 10.6.3-rc.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 (235) hide show
  1. package/.eslintrc.cjs +1 -1
  2. package/.oxlintrc.json +3 -22
  3. package/app/assets/geode_objects.js +26 -26
  4. package/app/components/Carousel.vue +62 -66
  5. package/app/components/CrsSelector.vue +48 -52
  6. package/app/components/DeleteDialog.vue +21 -37
  7. package/app/components/DragAndDrop.vue +35 -41
  8. package/app/components/ExtensionSelector.vue +50 -63
  9. package/app/components/FeedBack/ErrorBanner.vue +7 -10
  10. package/app/components/FeedBack/Snackers.vue +12 -14
  11. package/app/components/FetchingData.vue +1 -6
  12. package/app/components/FileSelector.vue +41 -47
  13. package/app/components/FileUploader.vue +62 -79
  14. package/app/components/GlassCard.vue +19 -19
  15. package/app/components/HybridRenderingView.vue +37 -38
  16. package/app/components/InfraConnected.vue +3 -3
  17. package/app/components/Inspector/InspectionButton.vue +27 -31
  18. package/app/components/Inspector/ResultPanel.vue +13 -24
  19. package/app/components/Launcher.vue +13 -13
  20. package/app/components/Loading.vue +63 -69
  21. package/app/components/MissingFilesSelector.vue +53 -73
  22. package/app/components/ObjectSelector.vue +81 -99
  23. package/app/components/PackagesVersions.vue +27 -30
  24. package/app/components/Recaptcha.vue +60 -71
  25. package/app/components/RemoteRenderingView.vue +102 -108
  26. package/app/components/Screenshot.vue +36 -42
  27. package/app/components/SearchBar.vue +5 -5
  28. package/app/components/Step.vue +37 -44
  29. package/app/components/Stepper.vue +29 -35
  30. package/app/components/VeaseViewToolbar.vue +69 -78
  31. package/app/components/ViewToolbar.vue +41 -45
  32. package/app/components/Viewer/BreadCrumb.vue +18 -30
  33. package/app/components/Viewer/ContextMenu.vue +176 -179
  34. package/app/components/Viewer/ContextMenuItem.vue +105 -117
  35. package/app/components/Viewer/EdgedCurve/PointsOptions.vue +6 -9
  36. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +82 -93
  37. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +84 -99
  38. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +83 -98
  39. package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +62 -73
  40. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +84 -108
  41. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +82 -105
  42. package/app/components/Viewer/Generic/Model/EdgesOptions.vue +19 -23
  43. package/app/components/Viewer/Generic/Model/PointsOptions.vue +26 -30
  44. package/app/components/Viewer/Grid/2D/CellsOptions.vue +5 -5
  45. package/app/components/Viewer/Grid/2D/EdgesOptions.vue +6 -9
  46. package/app/components/Viewer/Grid/2D/PointsOptions.vue +6 -9
  47. package/app/components/Viewer/Grid/3D/CellsOptions.vue +5 -5
  48. package/app/components/Viewer/Grid/3D/EdgesOptions.vue +6 -9
  49. package/app/components/Viewer/Grid/3D/FacetsOptions.vue +5 -5
  50. package/app/components/Viewer/Grid/3D/PointsOptions.vue +6 -9
  51. package/app/components/Viewer/HybridSolid/EdgesOptions.vue +6 -9
  52. package/app/components/Viewer/HybridSolid/PointsOptions.vue +6 -9
  53. package/app/components/Viewer/HybridSolid/PolygonsOptions.vue +6 -9
  54. package/app/components/Viewer/HybridSolid/PolyhedraOptions.vue +6 -9
  55. package/app/components/Viewer/Options/AttributeColorBar.vue +8 -8
  56. package/app/components/Viewer/Options/AttributeSelector.vue +73 -78
  57. package/app/components/Viewer/Options/ColorMapList.vue +115 -140
  58. package/app/components/Viewer/Options/ColorMapPicker.vue +128 -142
  59. package/app/components/Viewer/Options/ColorPicker.vue +9 -9
  60. package/app/components/Viewer/Options/ColoringTypeSelector.vue +77 -91
  61. package/app/components/Viewer/Options/TextureItem.vue +54 -58
  62. package/app/components/Viewer/Options/TexturesSelector.vue +22 -26
  63. package/app/components/Viewer/Options/VisibilitySwitch.vue +1 -1
  64. package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +61 -68
  65. package/app/components/Viewer/PolygonalSurface/EdgesOptions.vue +6 -9
  66. package/app/components/Viewer/PolygonalSurface/PointsOptions.vue +6 -9
  67. package/app/components/Viewer/PolygonalSurface/SpecificPolygonsOptions.vue +83 -103
  68. package/app/components/Viewer/Solid/EdgesOptions.vue +6 -9
  69. package/app/components/Viewer/Solid/PointsOptions.vue +6 -9
  70. package/app/components/Viewer/Solid/PolygonsOptions.vue +6 -9
  71. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +82 -105
  72. package/app/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue +5 -5
  73. package/app/components/Viewer/TetrahedralSolid/TrianglesOptions.vue +5 -5
  74. package/app/components/Viewer/Tree/ObjectTree.vue +80 -89
  75. package/app/components/Viewer/TreeComponent.vue +43 -49
  76. package/app/components/Viewer/TreeObject.vue +48 -50
  77. package/app/components/Viewer/TriangulatedSurface/EdgesOptions.vue +6 -9
  78. package/app/components/Viewer/TriangulatedSurface/PointsOptions.vue +5 -5
  79. package/app/components/Viewer/TriangulatedSurface/TrianglesOptions.vue +5 -5
  80. package/app/components/Wrapper.vue +8 -8
  81. package/app/components/ZScaling.vue +18 -27
  82. package/app/composables/project_manager.js +57 -67
  83. package/app/composables/run_function_when_microservices_connected.js +8 -8
  84. package/app/plugins/auto_store_register.js +11 -13
  85. package/app/stores/app.js +118 -138
  86. package/app/stores/data.js +52 -68
  87. package/app/stores/data_style.js +36 -36
  88. package/app/stores/feedback.js +17 -20
  89. package/app/stores/geode.js +54 -55
  90. package/app/stores/hybrid_viewer.js +164 -177
  91. package/app/stores/infra.js +45 -55
  92. package/app/stores/lambda.js +26 -26
  93. package/app/stores/menu.js +78 -85
  94. package/app/stores/treeview.js +57 -65
  95. package/app/stores/viewer.js +92 -104
  96. package/app/utils/colormap.js +3 -3
  97. package/app/utils/config.js +16 -22
  98. package/app/utils/default_styles.js +50 -62
  99. package/app/utils/extension.js +44 -44
  100. package/app/utils/file_import_workflow.js +50 -64
  101. package/app/utils/local/app_mode.js +2 -2
  102. package/app/utils/local/cleanup.js +66 -72
  103. package/app/utils/local/microservices.js +61 -71
  104. package/app/utils/local/path.js +16 -19
  105. package/app/utils/local/scripts.js +22 -22
  106. package/app/utils/recaptcha.js +6 -6
  107. package/app/utils/server.js +21 -24
  108. package/app/utils/status.js +2 -2
  109. package/app/utils/treeview.js +4 -4
  110. package/app/utils/validate_schema.js +7 -7
  111. package/commitlint.config.js +2 -2
  112. package/eslint.config.js +4 -4
  113. package/internal/database/database.js +38 -46
  114. package/internal/database/extended_database.js +9 -10
  115. package/internal/database/tables/data.js +2 -3
  116. package/internal/database/tables/model_components.js +1 -1
  117. package/internal/database/tables/model_components_relation.js +1 -1
  118. package/internal/stores/data_style/mesh/cells/cell.js +47 -63
  119. package/internal/stores/data_style/mesh/cells/color.js +11 -16
  120. package/internal/stores/data_style/mesh/cells/common.js +6 -6
  121. package/internal/stores/data_style/mesh/cells/index.js +37 -47
  122. package/internal/stores/data_style/mesh/cells/textures.js +11 -12
  123. package/internal/stores/data_style/mesh/cells/vertex.js +47 -58
  124. package/internal/stores/data_style/mesh/cells/visibility.js +11 -16
  125. package/internal/stores/data_style/mesh/edges/color.js +11 -16
  126. package/internal/stores/data_style/mesh/edges/common.js +6 -6
  127. package/internal/stores/data_style/mesh/edges/edge.js +47 -63
  128. package/internal/stores/data_style/mesh/edges/index.js +38 -52
  129. package/internal/stores/data_style/mesh/edges/vertex.js +47 -58
  130. package/internal/stores/data_style/mesh/edges/visibility.js +11 -16
  131. package/internal/stores/data_style/mesh/edges/width.js +11 -16
  132. package/internal/stores/data_style/mesh/index.js +34 -34
  133. package/internal/stores/data_style/mesh/points/color.js +11 -16
  134. package/internal/stores/data_style/mesh/points/common.js +6 -6
  135. package/internal/stores/data_style/mesh/points/index.js +35 -49
  136. package/internal/stores/data_style/mesh/points/size.js +11 -16
  137. package/internal/stores/data_style/mesh/points/vertex.js +47 -58
  138. package/internal/stores/data_style/mesh/points/visibility.js +11 -16
  139. package/internal/stores/data_style/mesh/polygons/color.js +11 -16
  140. package/internal/stores/data_style/mesh/polygons/common.js +6 -6
  141. package/internal/stores/data_style/mesh/polygons/index.js +36 -45
  142. package/internal/stores/data_style/mesh/polygons/polygon.js +45 -56
  143. package/internal/stores/data_style/mesh/polygons/textures.js +11 -16
  144. package/internal/stores/data_style/mesh/polygons/vertex.js +47 -58
  145. package/internal/stores/data_style/mesh/polygons/visibility.js +11 -16
  146. package/internal/stores/data_style/mesh/polyhedra/color.js +11 -16
  147. package/internal/stores/data_style/mesh/polyhedra/common.js +6 -6
  148. package/internal/stores/data_style/mesh/polyhedra/index.js +29 -42
  149. package/internal/stores/data_style/mesh/polyhedra/polyhedron.js +43 -47
  150. package/internal/stores/data_style/mesh/polyhedra/vertex.js +47 -58
  151. package/internal/stores/data_style/mesh/polyhedra/visibility.js +11 -17
  152. package/internal/stores/data_style/model/blocks/color.js +21 -24
  153. package/internal/stores/data_style/model/blocks/common.js +6 -6
  154. package/internal/stores/data_style/model/blocks/index.js +13 -17
  155. package/internal/stores/data_style/model/blocks/visibility.js +21 -24
  156. package/internal/stores/data_style/model/corners/color.js +21 -24
  157. package/internal/stores/data_style/model/corners/common.js +6 -6
  158. package/internal/stores/data_style/model/corners/index.js +14 -18
  159. package/internal/stores/data_style/model/corners/visibility.js +21 -25
  160. package/internal/stores/data_style/model/edges/common.js +4 -4
  161. package/internal/stores/data_style/model/edges/index.js +7 -7
  162. package/internal/stores/data_style/model/edges/visibility.js +11 -15
  163. package/internal/stores/data_style/model/index.js +84 -100
  164. package/internal/stores/data_style/model/lines/color.js +21 -24
  165. package/internal/stores/data_style/model/lines/common.js +6 -6
  166. package/internal/stores/data_style/model/lines/index.js +13 -17
  167. package/internal/stores/data_style/model/lines/visibility.js +21 -24
  168. package/internal/stores/data_style/model/points/common.js +4 -4
  169. package/internal/stores/data_style/model/points/index.js +9 -9
  170. package/internal/stores/data_style/model/points/size.js +11 -11
  171. package/internal/stores/data_style/model/points/visibility.js +11 -15
  172. package/internal/stores/data_style/model/surfaces/color.js +21 -24
  173. package/internal/stores/data_style/model/surfaces/common.js +6 -6
  174. package/internal/stores/data_style/model/surfaces/index.js +14 -22
  175. package/internal/stores/data_style/model/surfaces/visibility.js +18 -22
  176. package/internal/stores/data_style/state.js +11 -11
  177. package/internal/utils/api_fetch.js +24 -34
  178. package/internal/utils/upload_file.js +19 -24
  179. package/internal/utils/viewer_call.js +23 -36
  180. package/nuxt.config.js +7 -11
  181. package/package.json +3 -3
  182. package/scripts/generate_geode_objects.js +14 -16
  183. package/server/api/app/kill.post.js +4 -4
  184. package/server/api/app/project_folder_path.post.js +11 -11
  185. package/server/api/app/run_back.post.js +12 -12
  186. package/server/api/app/run_viewer.post.js +12 -12
  187. package/server/api/extensions/run.post.js +34 -41
  188. package/server/api/extensions/upload.put.js +48 -62
  189. package/tests/integration/setup.js +43 -53
  190. package/tests/integration/stores/data_style/mesh/cells.nuxt.test.js +90 -116
  191. package/tests/integration/stores/data_style/mesh/edges.nuxt.test.js +81 -107
  192. package/tests/integration/stores/data_style/mesh/index.nuxt.test.js +38 -41
  193. package/tests/integration/stores/data_style/mesh/points.nuxt.test.js +85 -101
  194. package/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js +89 -113
  195. package/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js +81 -105
  196. package/tests/integration/stores/data_style/model/blocks.nuxt.test.js +56 -73
  197. package/tests/integration/stores/data_style/model/corners.nuxt.test.js +59 -76
  198. package/tests/integration/stores/data_style/model/edges.nuxt.test.js +39 -42
  199. package/tests/integration/stores/data_style/model/index.nuxt.test.js +31 -34
  200. package/tests/integration/stores/data_style/model/lines.nuxt.test.js +60 -73
  201. package/tests/integration/stores/data_style/model/points.nuxt.test.js +52 -55
  202. package/tests/integration/stores/data_style/model/surfaces.nuxt.test.js +59 -80
  203. package/tests/integration/stores/viewer.nuxt.test.js +35 -38
  204. package/tests/setup_indexeddb.js +2 -2
  205. package/tests/unit/components/CrsSelector.nuxt.test.js +28 -28
  206. package/tests/unit/components/ExtensionSelector.nuxt.test.js +33 -35
  207. package/tests/unit/components/FeedBack/ErrorsBanner.nuxt.test.js +23 -23
  208. package/tests/unit/components/FeedBack/Snackers.nuxt.test.js +18 -18
  209. package/tests/unit/components/FileSelector.nuxt.test.js +57 -59
  210. package/tests/unit/components/FileUploader.nuxt.test.js +35 -39
  211. package/tests/unit/components/Inspector/InspectionButton.nuxt.test.js +28 -28
  212. package/tests/unit/components/Inspector/ResultPanel.nuxt.test.js +22 -27
  213. package/tests/unit/components/Launcher.nuxt.test.js +20 -22
  214. package/tests/unit/components/MissingFilesSelector.nuxt.test.js +37 -37
  215. package/tests/unit/components/ObjectSelector.nuxt.test.js +62 -62
  216. package/tests/unit/components/PackagesVersions.nuxt.test.js +16 -16
  217. package/tests/unit/components/Step.nuxt.test.js +18 -19
  218. package/tests/unit/components/Stepper.nuxt.test.js +18 -18
  219. package/tests/unit/composables/api_fetch.nuxt.test.js +34 -36
  220. package/tests/unit/composables/project_manager.nuxt.test.js +93 -112
  221. package/tests/unit/composables/run_function_when_microservices_connected.nuxt.test.js +36 -36
  222. package/tests/unit/composables/upload_file.nuxt.test.js +27 -29
  223. package/tests/unit/plugins/project_load.nuxt.test.js +31 -33
  224. package/tests/unit/stores/app.nuxt.test.js +90 -92
  225. package/tests/unit/stores/feedback.nuxt.test.js +47 -57
  226. package/tests/unit/stores/geode.nuxt.test.js +111 -115
  227. package/tests/unit/stores/infra.nuxt.test.js +148 -148
  228. package/tests/unit/stores/lambda.nuxt.test.js +72 -74
  229. package/tests/unit/stores/treeview.nuxt.test.js +19 -21
  230. package/tests/unit/stores/viewer.nuxt.test.js +109 -122
  231. package/tests/unit/utils/recaptcha.nuxt.test.js +25 -29
  232. package/tests/unit/utils/validate_schema.nuxt.test.js +17 -17
  233. package/tests/utils.js +11 -11
  234. package/tests/vitest.config.js +9 -9
  235. package/vuetify_config.js +2 -2
@@ -1,47 +1,45 @@
1
1
  // Third party imports
2
- import { beforeEach, describe, expect, test } from "vitest"
3
- import { registerEndpoint } from "@nuxt/test-utils/runtime"
4
- import schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json"
2
+ import { beforeEach, describe, expect, test } from "vitest";
3
+ import { registerEndpoint } from "@nuxt/test-utils/runtime";
4
+ import schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json";
5
5
 
6
6
  // Local imports
7
- import { setupActivePinia } from "@ogw_tests/utils"
8
- import { useFeedbackStore } from "@ogw_front/stores/feedback"
9
- import { useGeodeStore } from "@ogw_front/stores/geode"
7
+ import { setupActivePinia } from "@ogw_tests/utils";
8
+ import { useFeedbackStore } from "@ogw_front/stores/feedback";
9
+ import { useGeodeStore } from "@ogw_front/stores/geode";
10
10
 
11
- const ZERO = 0
12
- const schema = schemas.opengeodeweb_back.upload_file
11
+ const ZERO = 0;
12
+ const schema = schemas.opengeodeweb_back.upload_file;
13
13
 
14
14
  beforeEach(() => {
15
- setupActivePinia()
16
- const geodeStore = useGeodeStore()
17
- geodeStore.base_url = ""
18
- })
15
+ setupActivePinia();
16
+ const geodeStore = useGeodeStore();
17
+ geodeStore.base_url = "";
18
+ });
19
19
 
20
20
  describe("upload_file test", () => {
21
21
  test("throw error", async () => {
22
- const geodeStore = useGeodeStore()
23
- const file = "toto"
22
+ const geodeStore = useGeodeStore();
23
+ const file = "toto";
24
24
 
25
- await expect(geodeStore.upload(file)).rejects.toThrow(
26
- "file must be a instance of File",
27
- )
28
- })
25
+ await expect(geodeStore.upload(file)).rejects.toThrow("file must be a instance of File");
26
+ });
29
27
 
30
28
  test("onResponse", async () => {
31
- const feedbackStore = useFeedbackStore()
32
- const geodeStore = useGeodeStore()
29
+ const feedbackStore = useFeedbackStore();
30
+ const geodeStore = useGeodeStore();
33
31
  registerEndpoint(schema.$id, {
34
32
  method: "PUT",
35
33
  handler: () => ({ test: "ok" }),
36
- })
37
- const file = new File(["fake_file"], "fake_file.txt")
38
- let response_value = ""
34
+ });
35
+ const file = new File(["fake_file"], "fake_file.txt");
36
+ let response_value = "";
39
37
  await geodeStore.upload(file, {
40
38
  response_function: (response) => {
41
- response_value = response._data.test
39
+ response_value = response._data.test;
42
40
  },
43
- })
44
- expect(feedbackStore.feedbacks).toHaveLength(ZERO)
45
- expect(response_value).toBe("ok")
46
- })
47
- })
41
+ });
42
+ expect(feedbackStore.feedbacks).toHaveLength(ZERO);
43
+ expect(response_value).toBe("ok");
44
+ });
45
+ });
@@ -1,23 +1,23 @@
1
- import { beforeEach, describe, expect, test, vi } from "vitest"
1
+ import { beforeEach, describe, expect, test, vi } from "vitest";
2
2
 
3
- import { useAppStore } from "@ogw_front/stores/app"
4
- import { useDataStore } from "@ogw_front/stores/data"
5
- import { useDataStyleStore } from "@ogw_front/stores/data_style"
6
- import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer"
7
- import { useTreeviewStore } from "@ogw_front/stores/treeview"
3
+ import { useAppStore } from "@ogw_front/stores/app";
4
+ import { useDataStore } from "@ogw_front/stores/data";
5
+ import { useDataStyleStore } from "@ogw_front/stores/data_style";
6
+ import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
7
+ import { useTreeviewStore } from "@ogw_front/stores/treeview";
8
8
 
9
- import { database } from "@ogw_internal/database/database.js"
10
- import { setupActivePinia } from "@ogw_tests/utils"
9
+ import { database } from "@ogw_internal/database/database.js";
10
+ import { setupActivePinia } from "@ogw_tests/utils";
11
11
 
12
- const PANEL_WIDTH = 320
13
- const Z_SCALE = 1.5
14
- const STORES_SLICE_START = 1
12
+ const PANEL_WIDTH = 320;
13
+ const Z_SCALE = 1.5;
14
+ const STORES_SLICE_START = 1;
15
15
 
16
16
  vi.mock(import("@ogw_internal/utils/viewer_call"), () => ({
17
17
  viewer_call: vi.fn(async () => {
18
- await Promise.resolve()
18
+ await Promise.resolve();
19
19
  }),
20
- }))
20
+ }));
21
21
  vi.mock(import("@ogw_front/stores/hybrid_viewer"), () => ({
22
22
  useHybridViewerStore: () => ({
23
23
  $id: "hybridViewer",
@@ -28,11 +28,11 @@ vi.mock(import("@ogw_front/stores/hybrid_viewer"), () => ({
28
28
  save: vi.fn(),
29
29
  load: vi.fn(),
30
30
  }),
31
- }))
31
+ }));
32
32
 
33
33
  beforeEach(() => {
34
- setupActivePinia()
35
- })
34
+ setupActivePinia();
35
+ });
36
36
 
37
37
  describe("Project import", () => {
38
38
  test("app.importStores restores stores", async () => {
@@ -42,18 +42,16 @@ describe("Project import", () => {
42
42
  treeview: useTreeviewStore(),
43
43
  dataStyle: useDataStyleStore(),
44
44
  hybrid: useHybridViewerStore(),
45
- }
46
- const storesArray = Object.values(stores)
45
+ };
46
+ const storesArray = Object.values(stores);
47
47
  for (const store of storesArray.slice(STORES_SLICE_START)) {
48
- stores.app.registerStore(store)
48
+ stores.app.registerStore(store);
49
49
  }
50
50
 
51
- vi.spyOn(stores.dataBase, "importStores").mockImplementation(
52
- async (snapshot) => {
53
- const items = snapshot?.items || []
54
- await Promise.all(items.map((item) => database.data.put(item)))
55
- },
56
- )
51
+ vi.spyOn(stores.dataBase, "importStores").mockImplementation(async (snapshot) => {
52
+ const items = snapshot?.items || [];
53
+ await Promise.all(items.map((item) => database.data.put(item)));
54
+ });
57
55
 
58
56
  const snapshot = {
59
57
  data: {
@@ -81,13 +79,13 @@ describe("Project import", () => {
81
79
  },
82
80
  dataStyle: { styles: { abc123: { some: "style" } } },
83
81
  hybridViewer: { zScale: Z_SCALE },
84
- }
82
+ };
85
83
 
86
- await stores.app.importStores(snapshot)
84
+ await stores.app.importStores(snapshot);
87
85
 
88
- const item = await database.data.get("abc123")
89
- expect(item).toBeDefined()
90
- expect(item.id).toBe("abc123")
91
- expect(stores.dataStyle.styles.abc123).toBeDefined()
92
- })
93
- })
86
+ const item = await database.data.get("abc123");
87
+ expect(item).toBeDefined();
88
+ expect(item.id).toBe("abc123");
89
+ expect(stores.dataStyle.styles.abc123).toBeDefined();
90
+ });
91
+ });
@@ -1,71 +1,71 @@
1
- import { beforeEach, describe, expect, expectTypeOf, test, vi } from "vitest"
1
+ import { beforeEach, describe, expect, expectTypeOf, test, vi } from "vitest";
2
2
 
3
- import { useAppStore } from "@ogw_front/stores/app"
3
+ import { useAppStore } from "@ogw_front/stores/app";
4
4
 
5
- import { setupActivePinia } from "@ogw_tests/utils"
5
+ import { setupActivePinia } from "@ogw_tests/utils";
6
6
 
7
7
  // Constants
8
- const SINGLE_STORE_LENGTH = 1
9
- const MULTIPLE_STORES_LENGTH = 2
10
- const FIRST_INDEX = 0
11
- const SECOND_INDEX = 1
12
- const CALL_COUNT_ONCE = 1
8
+ const SINGLE_STORE_LENGTH = 1;
9
+ const MULTIPLE_STORES_LENGTH = 2;
10
+ const FIRST_INDEX = 0;
11
+ const SECOND_INDEX = 1;
12
+ const CALL_COUNT_ONCE = 1;
13
13
 
14
14
  beforeEach(() => {
15
- setupActivePinia()
16
- })
15
+ setupActivePinia();
16
+ });
17
17
  describe("app store", () => {
18
18
  describe("state", () => {
19
19
  test("initial state", () => {
20
- const appStore = useAppStore()
21
- expectTypeOf(appStore.stores).toBeArray()
22
- expectTypeOf(appStore.exportStores).toBeFunction()
23
- expectTypeOf(appStore.importStores).toBeFunction()
24
- expectTypeOf(appStore.registerStore).toBeFunction()
25
- })
26
- })
20
+ const appStore = useAppStore();
21
+ expectTypeOf(appStore.stores).toBeArray();
22
+ expectTypeOf(appStore.exportStores).toBeFunction();
23
+ expectTypeOf(appStore.importStores).toBeFunction();
24
+ expectTypeOf(appStore.registerStore).toBeFunction();
25
+ });
26
+ });
27
27
 
28
28
  describe("actions", () => {
29
29
  describe("registerStore", () => {
30
30
  test("register single store", () => {
31
- const appStore = useAppStore()
31
+ const appStore = useAppStore();
32
32
  const mock_store = {
33
33
  $id: "testStore",
34
34
  save: vi.fn().mockImplementation(() => ({ data: "test" })),
35
35
  load: vi.fn().mockImplementation(),
36
- }
36
+ };
37
37
 
38
- appStore.registerStore(mock_store)
38
+ appStore.registerStore(mock_store);
39
39
 
40
- expect(appStore.stores).toHaveLength(SINGLE_STORE_LENGTH)
41
- expect(appStore.stores[FIRST_INDEX]).toStrictEqual(mock_store)
42
- })
40
+ expect(appStore.stores).toHaveLength(SINGLE_STORE_LENGTH);
41
+ expect(appStore.stores[FIRST_INDEX]).toStrictEqual(mock_store);
42
+ });
43
43
 
44
44
  test("register multiple stores", () => {
45
- const appStore = useAppStore()
45
+ const appStore = useAppStore();
46
46
  const mock_store_1 = {
47
47
  $id: "userStore",
48
48
  save: vi.fn().mockImplementation(),
49
49
  load: vi.fn().mockImplementation(),
50
- }
50
+ };
51
51
  const mock_store_2 = {
52
52
  $id: "geodeStore",
53
53
  save: vi.fn().mockImplementation(),
54
54
  load: vi.fn().mockImplementation(),
55
- }
55
+ };
56
56
 
57
- appStore.registerStore(mock_store_1)
58
- appStore.registerStore(mock_store_2)
57
+ appStore.registerStore(mock_store_1);
58
+ appStore.registerStore(mock_store_2);
59
59
 
60
- expect(appStore.stores).toHaveLength(MULTIPLE_STORES_LENGTH)
61
- expect(appStore.stores[FIRST_INDEX].$id).toBe("userStore")
62
- expect(appStore.stores[SECOND_INDEX].$id).toBe("geodeStore")
63
- })
64
- })
60
+ expect(appStore.stores).toHaveLength(MULTIPLE_STORES_LENGTH);
61
+ expect(appStore.stores[FIRST_INDEX].$id).toBe("userStore");
62
+ expect(appStore.stores[SECOND_INDEX].$id).toBe("geodeStore");
63
+ });
64
+ });
65
65
 
66
66
  describe("export", () => {
67
67
  test("export stores with exportStores method", async () => {
68
- const appStore = useAppStore()
68
+ const appStore = useAppStore();
69
69
  const mock_store_1 = {
70
70
  $id: "userStore",
71
71
  exportStores: vi.fn().mockImplementation(() => ({
@@ -73,117 +73,115 @@ describe("app store", () => {
73
73
  email: "toto@titi.com",
74
74
  })),
75
75
  importStores: vi.fn().mockImplementation(),
76
- }
76
+ };
77
77
  const mock_store_2 = {
78
78
  $id: "geodeStore",
79
- exportStores: vi
80
- .fn()
81
- .mockImplementation(() => ({ items: [], total: 0 })),
79
+ exportStores: vi.fn().mockImplementation(() => ({ items: [], total: 0 })),
82
80
  importStores: vi.fn().mockImplementation(),
83
- }
81
+ };
84
82
 
85
- appStore.registerStore(mock_store_1)
86
- appStore.registerStore(mock_store_2)
83
+ appStore.registerStore(mock_store_1);
84
+ appStore.registerStore(mock_store_2);
87
85
 
88
- const snapshot = await appStore.exportStores()
86
+ const snapshot = await appStore.exportStores();
89
87
 
90
- expect(mock_store_1.exportStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE)
91
- expect(mock_store_2.exportStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE)
88
+ expect(mock_store_1.exportStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE);
89
+ expect(mock_store_2.exportStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE);
92
90
  expect(snapshot).toStrictEqual({
93
91
  userStore: { name: "toto", email: "toto@titi.com" },
94
92
  geodeStore: { items: [], total: 0 },
95
- })
96
- })
93
+ });
94
+ });
97
95
 
98
96
  test("skip stores without exportSave method", async () => {
99
- const appStore = useAppStore()
97
+ const appStore = useAppStore();
100
98
  const mock_store_1 = {
101
99
  $id: "withSave",
102
100
  exportStores: vi.fn().mockImplementation(() => ({ data: "test" })),
103
101
  importStores: vi.fn().mockImplementation(),
104
- }
102
+ };
105
103
  const mock_store_2 = {
106
104
  $id: "withoutSave",
107
105
  importStores: vi.fn().mockImplementation(),
108
- }
106
+ };
109
107
 
110
- appStore.registerStore(mock_store_1)
111
- appStore.registerStore(mock_store_2)
108
+ appStore.registerStore(mock_store_1);
109
+ appStore.registerStore(mock_store_2);
112
110
 
113
- const snapshot = await appStore.exportStores()
111
+ const snapshot = await appStore.exportStores();
114
112
 
115
- expect(mock_store_1.exportStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE)
113
+ expect(mock_store_1.exportStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE);
116
114
  expect(snapshot).toEqual({
117
115
  withSave: { data: "test" },
118
- })
119
- expect(snapshot.withoutSave).toBeUndefined()
120
- })
116
+ });
117
+ expect(snapshot.withoutSave).toBeUndefined();
118
+ });
121
119
 
122
120
  test("return empty snapshot when no stores registered", async () => {
123
- const appStore = useAppStore()
124
- const snapshot = await appStore.exportStores()
125
- expect(snapshot).toStrictEqual({})
126
- })
127
- })
121
+ const appStore = useAppStore();
122
+ const snapshot = await appStore.exportStores();
123
+ expect(snapshot).toStrictEqual({});
124
+ });
125
+ });
128
126
 
129
127
  describe("load", () => {
130
128
  test("import stores with importStores method", async () => {
131
- const appStore = useAppStore()
129
+ const appStore = useAppStore();
132
130
  const userStore = {
133
131
  $id: "userStore",
134
132
  importStores: vi.fn().mockResolvedValue(),
135
- }
133
+ };
136
134
  const geodeStore = {
137
135
  $id: "geodeStore",
138
136
  importStores: vi.fn().mockResolvedValue(),
139
- }
140
- appStore.registerStore(userStore)
141
- appStore.registerStore(geodeStore)
137
+ };
138
+ appStore.registerStore(userStore);
139
+ appStore.registerStore(geodeStore);
142
140
  const snapshot = {
143
141
  userStore: { some: "data" },
144
142
  geodeStore: { other: "data" },
145
- }
146
- await appStore.importStores(snapshot)
147
- expect(userStore.importStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE)
148
- expect(geodeStore.importStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE)
149
- })
143
+ };
144
+ await appStore.importStores(snapshot);
145
+ expect(userStore.importStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE);
146
+ expect(geodeStore.importStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE);
147
+ });
150
148
 
151
149
  test("skip stores without importStores method", async () => {
152
- const appStore = useAppStore()
150
+ const appStore = useAppStore();
153
151
  const mock_store_1 = {
154
152
  $id: "withImport",
155
153
  save: vi.fn().mockImplementation(),
156
154
  importStores: vi.fn().mockImplementation(),
157
- }
155
+ };
158
156
  const mock_store_2 = {
159
157
  $id: "withoutImport",
160
158
  save: vi.fn().mockImplementation(),
161
- }
162
- appStore.registerStore(mock_store_1)
163
- appStore.registerStore(mock_store_2)
159
+ };
160
+ appStore.registerStore(mock_store_1);
161
+ appStore.registerStore(mock_store_2);
164
162
  const snapshot = {
165
163
  withImport: { data: "test" },
166
164
  withoutImport: { data: "ignored" },
167
- }
168
- await appStore.importStores(snapshot)
169
- expect(mock_store_1.importStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE)
170
- expect(mock_store_2.importStores).toBeUndefined()
171
- })
165
+ };
166
+ await appStore.importStores(snapshot);
167
+ expect(mock_store_1.importStores).toHaveBeenCalledTimes(CALL_COUNT_ONCE);
168
+ expect(mock_store_2.importStores).toBeUndefined();
169
+ });
172
170
 
173
171
  test("warn when store not found in snapshot", async () => {
174
- const appStore = useAppStore()
175
- const console_warn_spy = vi.spyOn(console, "warn").mockImplementation()
172
+ const appStore = useAppStore();
173
+ const console_warn_spy = vi.spyOn(console, "warn").mockImplementation();
176
174
  const mock_store = {
177
175
  $id: "testStore",
178
176
  importStores: vi.fn().mockImplementation(),
179
- }
180
- appStore.registerStore(mock_store)
181
- await appStore.importStores({})
177
+ };
178
+ appStore.registerStore(mock_store);
179
+ await appStore.importStores({});
182
180
  expect(console_warn_spy).toHaveBeenCalledWith(
183
181
  expect.stringContaining("Stores not found in snapshot: testStore"),
184
- )
185
- console_warn_spy.mockRestore()
186
- })
187
- })
188
- })
189
- })
182
+ );
183
+ console_warn_spy.mockRestore();
184
+ });
185
+ });
186
+ });
187
+ });
@@ -1,85 +1,75 @@
1
1
  // Third party imports
2
- import { beforeEach, describe, expect, expectTypeOf, test } from "vitest"
2
+ import { beforeEach, describe, expect, expectTypeOf, test } from "vitest";
3
3
 
4
4
  // Local imports
5
- import { setupActivePinia } from "@ogw_tests/utils"
6
- import { useFeedbackStore } from "@ogw_front/stores/feedback"
5
+ import { setupActivePinia } from "@ogw_tests/utils";
6
+ import { useFeedbackStore } from "@ogw_front/stores/feedback";
7
7
 
8
- const ERROR_500 = 500
9
- const MILISECONDS_TIMEOUT = 1000
8
+ const ERROR_500 = 500;
9
+ const MILISECONDS_TIMEOUT = 1000;
10
10
 
11
11
  beforeEach(() => {
12
- setupActivePinia()
13
- })
12
+ setupActivePinia();
13
+ });
14
14
 
15
15
  describe("Feedback Store", () => {
16
16
  describe("state", () => {
17
17
  test("initial state", () => {
18
- const feedbackStore = useFeedbackStore()
19
- expectTypeOf(feedbackStore.feedbacks).toEqualTypeOf([])
20
- expectTypeOf(feedbackStore.server_error).toBeBoolean()
21
- })
22
- })
18
+ const feedbackStore = useFeedbackStore();
19
+ expectTypeOf(feedbackStore.feedbacks).toEqualTypeOf([]);
20
+ expectTypeOf(feedbackStore.server_error).toBeBoolean();
21
+ });
22
+ });
23
23
 
24
24
  describe("actions", () => {
25
25
  describe("add_error", () => {
26
26
  test("test add_error", () => {
27
- const feedbackStore = useFeedbackStore()
28
- feedbackStore.add_error(
29
- ERROR_500,
30
- "/test",
31
- "test message",
32
- "test description",
33
- )
34
- expect(feedbackStore.feedbacks).toHaveLength(1)
35
- expect(feedbackStore.feedbacks[0].type).toBe("error")
36
- })
27
+ const feedbackStore = useFeedbackStore();
28
+ feedbackStore.add_error(ERROR_500, "/test", "test message", "test description");
29
+ expect(feedbackStore.feedbacks).toHaveLength(1);
30
+ expect(feedbackStore.feedbacks[0].type).toBe("error");
31
+ });
37
32
 
38
33
  test("test feedbacks_timeout", () => {
39
- const feedbackStore = useFeedbackStore()
40
- feedbackStore.feedbacks_timeout_miliseconds = 500
41
- feedbackStore.add_error(
42
- ERROR_500,
43
- "/test",
44
- "test message",
45
- "test description",
46
- )
47
- expect(feedbackStore.feedbacks).toHaveLength(1)
34
+ const feedbackStore = useFeedbackStore();
35
+ feedbackStore.feedbacks_timeout_miliseconds = 500;
36
+ feedbackStore.add_error(ERROR_500, "/test", "test message", "test description");
37
+ expect(feedbackStore.feedbacks).toHaveLength(1);
48
38
  setTimeout(() => {
49
- expect(feedbackStore.feedbacks).toHaveLength(0)
50
- }, MILISECONDS_TIMEOUT)
51
- })
52
- })
39
+ expect(feedbackStore.feedbacks).toHaveLength(0);
40
+ }, MILISECONDS_TIMEOUT);
41
+ });
42
+ });
53
43
 
54
44
  describe("add_success", () => {
55
45
  test("test add_success", () => {
56
- const feedbackStore = useFeedbackStore()
57
- feedbackStore.feedbacks_timeout_miliseconds = 500
58
- feedbackStore.add_success("test description")
59
- expect(feedbackStore.feedbacks).toHaveLength(1)
60
- expect(feedbackStore.feedbacks[0].type).toBe("success")
46
+ const feedbackStore = useFeedbackStore();
47
+ feedbackStore.feedbacks_timeout_miliseconds = 500;
48
+ feedbackStore.add_success("test description");
49
+ expect(feedbackStore.feedbacks).toHaveLength(1);
50
+ expect(feedbackStore.feedbacks[0].type).toBe("success");
61
51
 
62
52
  setTimeout(() => {
63
- expect(feedbackStore.feedbacks).toHaveLength(0)
64
- }, MILISECONDS_TIMEOUT)
65
- })
66
- })
53
+ expect(feedbackStore.feedbacks).toHaveLength(0);
54
+ }, MILISECONDS_TIMEOUT);
55
+ });
56
+ });
67
57
 
68
58
  describe("delete_feedback", () => {
69
59
  test("test", () => {
70
- const feedbackStore = useFeedbackStore()
71
- feedbackStore.delete_feedback(0)
72
- expect(feedbackStore.feedbacks).toHaveLength(0)
73
- })
74
- })
60
+ const feedbackStore = useFeedbackStore();
61
+ feedbackStore.delete_feedback(0);
62
+ expect(feedbackStore.feedbacks).toHaveLength(0);
63
+ });
64
+ });
75
65
 
76
66
  describe("delete_server_error", () => {
77
67
  test("test", () => {
78
- const feedbackStore = useFeedbackStore()
79
- feedbackStore.$patch({ server_error: true })
80
- feedbackStore.delete_server_error()
81
- expect(feedbackStore.server_error).toBeFalsy()
82
- })
83
- })
84
- })
85
- })
68
+ const feedbackStore = useFeedbackStore();
69
+ feedbackStore.$patch({ server_error: true });
70
+ feedbackStore.delete_server_error();
71
+ expect(feedbackStore.server_error).toBeFalsy();
72
+ });
73
+ });
74
+ });
75
+ });