@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.
- package/.eslintrc.cjs +1 -0
- package/app/assets/geode_objects.js +1 -3
- package/app/components/Carousel.vue +7 -4
- package/app/components/CrsSelector.vue +5 -6
- package/app/components/DragAndDrop.vue +18 -8
- package/app/components/ExtensionSelector.vue +9 -17
- package/app/components/FeedBack/ErrorBanner.vue +1 -1
- package/app/components/FeedBack/Snackers.vue +4 -1
- package/app/components/FileSelector.vue +21 -10
- package/app/components/FileUploader.vue +15 -32
- package/app/components/HybridRenderingView.vue +5 -3
- package/app/components/Inspector/InspectionButton.vue +2 -2
- package/app/components/Inspector/ResultPanel.vue +4 -4
- package/app/components/Launcher.vue +1 -1
- package/app/components/Loading.vue +6 -6
- package/app/components/MissingFilesSelector.vue +23 -29
- package/app/components/ObjectSelector.vue +11 -10
- package/app/components/OptionCard.vue +1 -1
- package/app/components/PackagesVersions.vue +5 -3
- package/app/components/Recaptcha.vue +6 -4
- package/app/components/RemoteRenderingView.vue +4 -3
- package/app/components/Screenshot.vue +4 -4
- package/app/components/Step.vue +7 -7
- package/app/components/VeaseViewToolbar.vue +3 -3
- package/app/components/Viewer/BreadCrumb.vue +2 -4
- package/app/components/Viewer/ContextMenu.vue +77 -45
- package/app/components/Viewer/ContextMenuItem.vue +42 -33
- package/app/components/Viewer/EdgedCurve/PointsOptions.vue +3 -3
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +5 -5
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +6 -6
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +5 -5
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +5 -5
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +6 -7
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +6 -6
- package/app/components/Viewer/Generic/Model/EdgesOptions.vue +3 -3
- package/app/components/Viewer/Generic/Model/PointsOptions.vue +4 -4
- package/app/components/Viewer/Grid/2D/CellsOptions.vue +3 -3
- package/app/components/Viewer/Grid/2D/EdgesOptions.vue +3 -3
- package/app/components/Viewer/Grid/2D/PointsOptions.vue +3 -3
- package/app/components/Viewer/Grid/3D/CellsOptions.vue +3 -3
- package/app/components/Viewer/Grid/3D/EdgesOptions.vue +3 -3
- package/app/components/Viewer/Grid/3D/FacetsOptions.vue +3 -3
- package/app/components/Viewer/Grid/3D/PointsOptions.vue +3 -3
- package/app/components/Viewer/HybridSolid/EdgesOptions.vue +3 -3
- package/app/components/Viewer/HybridSolid/PointsOptions.vue +3 -3
- package/app/components/Viewer/HybridSolid/PolygonsOptions.vue +3 -3
- package/app/components/Viewer/HybridSolid/PolyhedraOptions.vue +3 -3
- package/app/components/Viewer/Options/CellAttributeSelector.vue +23 -20
- package/app/components/Viewer/Options/ColorMapList.vue +75 -50
- package/app/components/Viewer/Options/ColorMapPicker.vue +38 -32
- package/app/components/Viewer/Options/ColorPicker.vue +3 -3
- package/app/components/Viewer/Options/ColoringTypeSelector.vue +29 -21
- package/app/components/Viewer/Options/EdgeAttributeSelector.vue +7 -7
- package/app/components/Viewer/Options/PolygonAttributeSelector.vue +7 -7
- package/app/components/Viewer/Options/PolyhedronAttributeSelector.vue +7 -7
- package/app/components/Viewer/Options/TextureItem.vue +5 -5
- package/app/components/Viewer/Options/TexturesSelector.vue +5 -5
- package/app/components/Viewer/Options/VertexAttributeSelector.vue +7 -7
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +5 -5
- package/app/components/Viewer/PolygonalSurface/EdgesOptions.vue +3 -3
- package/app/components/Viewer/PolygonalSurface/PointsOptions.vue +3 -3
- package/app/components/Viewer/PolygonalSurface/SpecificPolygonsOptions.vue +6 -6
- package/app/components/Viewer/Solid/EdgesOptions.vue +3 -3
- package/app/components/Viewer/Solid/PointsOptions.vue +3 -3
- package/app/components/Viewer/Solid/PolygonsOptions.vue +3 -3
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +6 -6
- package/app/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue +3 -3
- package/app/components/Viewer/TetrahedralSolid/TrianglesOptions.vue +3 -3
- package/app/components/Viewer/Tree/ObjectTree.vue +7 -9
- package/app/components/Viewer/TreeComponent.vue +9 -13
- package/app/components/Viewer/TreeObject.vue +8 -9
- package/app/components/Viewer/TriangulatedSurface/EdgesOptions.vue +3 -3
- package/app/components/Viewer/TriangulatedSurface/PointsOptions.vue +3 -3
- package/app/components/Viewer/TriangulatedSurface/TrianglesOptions.vue +3 -3
- package/app/components/Wrapper.vue +1 -2
- package/app/components/ZScaling.vue +1 -1
- package/app/composables/project_manager.js +6 -6
- package/app/plugins/auto_store_register.js +1 -1
- package/app/stores/app.js +45 -41
- package/app/stores/data.js +52 -51
- package/app/stores/data_style.js +12 -11
- package/app/stores/feedback.js +5 -1
- package/app/stores/geode.js +16 -13
- package/app/stores/hybrid_viewer.js +72 -44
- package/app/stores/infra.js +18 -16
- package/app/stores/lambda.js +1 -9
- package/app/stores/menu.js +13 -13
- package/app/stores/treeview.js +15 -13
- package/app/stores/viewer.js +39 -33
- package/app/utils/app_mode.js +4 -3
- package/app/utils/default_styles.js +55 -47
- package/app/utils/file_import_workflow.js +4 -17
- package/app/utils/local.js +195 -184
- package/app/utils/upload_file.js +1 -2
- package/eslint.config.js +2 -2
- package/internal/database/database.js +17 -32
- package/internal/database/extended_database.js +25 -0
- package/internal/stores/data_style/mesh/cells/cell.js +3 -3
- package/internal/stores/data_style/mesh/cells/color.js +1 -1
- package/internal/stores/data_style/mesh/cells/index.js +7 -7
- package/internal/stores/data_style/mesh/cells/textures.js +1 -1
- package/internal/stores/data_style/mesh/cells/vertex.js +3 -3
- package/internal/stores/data_style/mesh/cells/visibility.js +1 -1
- package/internal/stores/data_style/mesh/edges/color.js +1 -1
- package/internal/stores/data_style/mesh/edges/edge.js +22 -22
- package/internal/stores/data_style/mesh/edges/index.js +7 -7
- package/internal/stores/data_style/mesh/edges/vertex.js +3 -3
- package/internal/stores/data_style/mesh/edges/visibility.js +1 -1
- package/internal/stores/data_style/mesh/edges/width.js +1 -1
- package/internal/stores/data_style/mesh/index.js +4 -5
- package/internal/stores/data_style/mesh/points/color.js +1 -1
- package/internal/stores/data_style/mesh/points/index.js +6 -6
- package/internal/stores/data_style/mesh/points/size.js +1 -1
- package/internal/stores/data_style/mesh/points/vertex.js +3 -3
- package/internal/stores/data_style/mesh/points/visibility.js +1 -1
- package/internal/stores/data_style/mesh/polygons/color.js +1 -1
- package/internal/stores/data_style/mesh/polygons/index.js +7 -7
- package/internal/stores/data_style/mesh/polygons/polygon.js +3 -3
- package/internal/stores/data_style/mesh/polygons/textures.js +1 -1
- package/internal/stores/data_style/mesh/polygons/vertex.js +3 -3
- package/internal/stores/data_style/mesh/polygons/visibility.js +1 -1
- package/internal/stores/data_style/mesh/polyhedra/color.js +1 -1
- package/internal/stores/data_style/mesh/polyhedra/index.js +6 -6
- package/internal/stores/data_style/mesh/polyhedra/polyhedron.js +3 -3
- package/internal/stores/data_style/mesh/polyhedra/vertex.js +3 -3
- package/internal/stores/data_style/mesh/polyhedra/visibility.js +1 -1
- package/internal/stores/data_style/model/edges.js +1 -1
- package/internal/stores/data_style/model/index.js +32 -22
- package/internal/utils/api_fetch.js +8 -5
- package/internal/utils/viewer_call.js +42 -46
- package/nuxt.config.js +3 -3
- package/package.json +1 -1
- package/scripts/generate_geode_objects.js +8 -7
- package/tests/integration/setup.js +28 -21
- package/tests/integration/stores/data_style/mesh/cells.nuxt.test.js +18 -10
- package/tests/integration/stores/data_style/mesh/edges.nuxt.test.js +18 -10
- package/tests/integration/stores/data_style/mesh/index.nuxt.test.js +9 -5
- package/tests/integration/stores/data_style/mesh/points.nuxt.test.js +17 -10
- package/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js +18 -10
- package/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js +18 -10
- package/tests/integration/stores/data_style/model/blocks.nuxt.test.js +10 -6
- package/tests/integration/stores/data_style/model/corners.nuxt.test.js +10 -6
- package/tests/integration/stores/data_style/model/edges.nuxt.test.js +9 -5
- package/tests/integration/stores/data_style/model/index.nuxt.test.js +9 -5
- package/tests/integration/stores/data_style/model/lines.nuxt.test.js +10 -6
- package/tests/integration/stores/data_style/model/points.nuxt.test.js +9 -5
- package/tests/integration/stores/data_style/model/surfaces.nuxt.test.js +10 -6
- package/tests/integration/stores/viewer.nuxt.test.js +55 -39
- package/tests/setup_indexeddb.js +1 -0
- package/tests/unit/components/CrsSelector.nuxt.test.js +18 -19
- package/tests/unit/components/ExtensionSelector.nuxt.test.js +24 -19
- package/tests/unit/components/FeedBack/ErrorsBanner.nuxt.test.js +23 -36
- package/tests/unit/components/FeedBack/Snackers.nuxt.test.js +20 -25
- package/tests/unit/components/FileSelector.nuxt.test.js +27 -27
- package/tests/unit/components/FileUploader.nuxt.test.js +18 -17
- package/tests/unit/components/Inspector/InspectionButton.nuxt.test.js +9 -16
- package/tests/unit/components/Inspector/ResultPanel.nuxt.test.js +8 -6
- package/tests/unit/components/Launcher.nuxt.test.js +12 -17
- package/tests/unit/components/MissingFilesSelector.nuxt.test.js +16 -19
- package/tests/unit/components/ObjectSelector.nuxt.test.js +30 -34
- package/tests/unit/components/PackagesVersions.nuxt.test.js +8 -11
- package/tests/unit/components/Step.nuxt.test.js +8 -7
- package/tests/unit/components/Stepper.nuxt.test.js +14 -12
- package/tests/unit/composables/ProjectManager.nuxt.test.js +142 -100
- package/tests/unit/composables/api_fetch.nuxt.test.js +12 -39
- package/tests/unit/composables/run_function_when_microservices_connected.nuxt.test.js +36 -61
- package/tests/unit/composables/upload_file.nuxt.test.js +21 -25
- package/tests/unit/plugins/project_load.nuxt.test.js +22 -21
- package/tests/unit/stores/App.nuxt.test.js +45 -43
- package/tests/unit/stores/Feedback.nuxt.test.js +16 -18
- package/tests/unit/stores/Geode.nuxt.test.js +135 -137
- package/tests/unit/stores/Infra.nuxt.test.js +20 -26
- package/tests/unit/stores/Lambda.nuxt.test.js +30 -31
- package/tests/unit/stores/Treeview.nuxt.test.js +53 -55
- package/tests/unit/stores/Viewer.nuxt.test.js +16 -23
- package/tests/unit/utils/validate_schema.nuxt.test.js +18 -18
- package/tests/utils.js +15 -2
- package/tests/vitest.config.js +6 -2
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
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)).
|
|
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)).
|
|
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[
|
|
72
|
+
method: schema.methods[FIRST_INDEX],
|
|
80
73
|
handler: () => ({ result: "success" }),
|
|
81
74
|
})
|
|
82
75
|
await geodeStore.request(schema, params, callbacks)
|
|
83
|
-
expect(errorCalled).
|
|
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 {
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
|
|
65
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
2
|
-
import {
|
|
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(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
22
|
-
const
|
|
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(
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
41
|
-
|
|
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
|
|
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 {
|
|
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(() =>
|
|
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
|
-
|
|
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
|
-
|
|
47
|
-
|
|
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
|
-
|
|
52
|
-
|
|
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:
|
|
77
|
+
panelWidth: PANEL_WIDTH,
|
|
77
78
|
model_id: "",
|
|
78
79
|
isTreeCollection: false,
|
|
79
|
-
selectedTree:
|
|
80
|
+
selectedTree: undefined,
|
|
80
81
|
},
|
|
81
82
|
dataStyle: { styles: { abc123: { some: "style" } } },
|
|
82
|
-
hybridViewer: { zScale:
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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
|
|
39
|
-
expect(appStore.stores[
|
|
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
|
|
59
|
-
expect(appStore.stores[
|
|
60
|
-
expect(appStore.stores[
|
|
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("
|
|
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(
|
|
89
|
-
expect(mock_store_2.exportStores).toHaveBeenCalledTimes(
|
|
90
|
-
expect(snapshot).
|
|
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(
|
|
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).
|
|
127
|
+
expect(snapshot).toStrictEqual({})
|
|
124
128
|
})
|
|
125
129
|
})
|
|
126
130
|
|
|
127
131
|
describe("load", () => {
|
|
128
|
-
test("
|
|
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(
|
|
146
|
-
expect(geodeStore.importStores).toHaveBeenCalledTimes(
|
|
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(
|
|
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
|
-
|
|
2
|
-
import {
|
|
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(
|
|
7
|
-
|
|
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
|
|
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
|
|
44
|
+
expect(feedbackStore.feedbacks).toHaveLength(1)
|
|
48
45
|
setTimeout(() => {
|
|
49
|
-
expect(feedbackStore.feedbacks
|
|
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
|
|
56
|
+
expect(feedbackStore.feedbacks).toHaveLength(1)
|
|
60
57
|
expect(feedbackStore.feedbacks[0].type).toBe("success")
|
|
61
58
|
|
|
62
59
|
setTimeout(() => {
|
|
63
|
-
expect(feedbackStore.feedbacks
|
|
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
|
|
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).
|
|
78
|
+
expect(feedbackStore.server_error).toBeFalsy()
|
|
81
79
|
})
|
|
82
80
|
})
|
|
83
81
|
})
|