@geode/opengeodeweb-front 9.11.0-rc.8 → 9.11.0-rc.9
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/.github/workflows/test.yml +23 -0
- package/components/FeedBack/ErrorBanner.vue +1 -1
- package/components/FeedBack/Snackers.vue +1 -1
- package/components/HybridRenderingView.vue +38 -12
- package/components/Launcher.vue +1 -1
- package/components/PackagesVersions.vue +1 -1
- package/components/Recaptcha.vue +1 -1
- package/components/RemoteRenderingView.vue +1 -1
- package/components/Viewer/BreadCrumb.vue +1 -1
- package/components/Viewer/Tree/ObjectTree.vue +1 -1
- package/components/Viewer/TreeObject.vue +1 -1
- package/components/Wrapper.vue +1 -1
- package/composables/api_fetch.js +2 -2
- package/composables/run_function_when_microservices_connected.js +1 -1
- package/composables/upload_file.js +2 -2
- package/composables/viewer_call.js +38 -38
- package/internal_stores/mesh/edges.js +49 -52
- package/internal_stores/mesh/index.js +20 -14
- package/internal_stores/mesh/points.js +9 -7
- package/internal_stores/mesh/polygons.js +9 -7
- package/internal_stores/mesh/polyhedra.js +8 -6
- package/internal_stores/model/blocks.js +1 -1
- package/internal_stores/model/corners.js +1 -1
- package/internal_stores/model/edges.js +1 -8
- package/internal_stores/model/index.js +1 -1
- package/internal_stores/model/lines.js +2 -2
- package/internal_stores/model/points.js +2 -2
- package/internal_stores/model/surfaces.js +1 -1
- package/package.json +13 -6
- package/stores/data_base.js +9 -1
- package/stores/data_style.js +7 -6
- package/stores/feedback.js +1 -1
- package/stores/geode.js +5 -5
- package/stores/hybrid_viewer.js +1 -1
- package/stores/infra.js +10 -10
- package/stores/treeview.js +1 -1
- package/stores/viewer.js +5 -6
- package/tests/integration/data/fake_id/edged_curve.vtp +20 -0
- package/tests/integration/microservices/back/requirements.in +1 -0
- package/tests/integration/microservices/back/requirements.txt +75 -0
- package/tests/integration/microservices/viewer/requirements.in +1 -0
- package/tests/integration/microservices/viewer/requirements.txt +87 -0
- package/tests/integration/stores/DataStyle/mesh/Edges.nuxt.test.js +138 -0
- package/{test → tests/unit}/components/CrsSelector.nuxt.test.js +6 -3
- package/{test → tests/unit}/components/ExtensionSelector.nuxt.test.js +6 -3
- package/{test → tests/unit}/components/FeedBack/ErrorsBanner.nuxt.test.js +10 -3
- package/{test → tests/unit}/components/FeedBack/Snackers.nuxt.test.js +24 -21
- package/{test → tests/unit}/components/FileSelector.nuxt.test.js +5 -2
- package/{test → tests/unit}/components/FileUploader.nuxt.test.js +6 -3
- package/{test → tests/unit}/components/Inspector/InspectionButton.nuxt.test.js +6 -3
- package/{test → tests/unit}/components/Launcher.nuxt.test.js +9 -2
- package/{test → tests/unit}/components/MissingFilesSelector.nuxt.test.js +6 -3
- package/{test → tests/unit}/components/ObjectSelector.nuxt.test.js +6 -3
- package/{test → tests/unit}/components/PackagesVersions.nuxt.test.js +5 -3
- package/{test → tests/unit}/components/Stepper.nuxt.test.js +1 -0
- package/{test → tests/unit}/components/Wrapper.nuxt.test.js +1 -1
- package/{test → tests/unit}/composables/api_fetch.nuxt.test.js +3 -2
- package/{test/composables/run_function_when_microservices_connected.test.js → tests/unit/composables/run_function_when_microservices_connected.nuxt.test.js} +18 -5
- package/{test → tests/unit}/composables/upload_file.nuxt.test.js +7 -8
- package/{test → tests/unit}/stores/Feedback.nuxt.test.js +12 -8
- package/{test → tests/unit}/stores/Geode.nuxt.test.js +33 -10
- package/{test → tests/unit}/stores/Infra.nuxt.test.js +58 -25
- package/{test → tests/unit}/stores/Viewer.nuxt.test.js +101 -20
- package/{test → tests/unit}/utils/validate_schema.nuxt.test.js +3 -0
- package/tests/vitest.config.js +33 -0
- package/utils/default_styles.js +246 -0
- package/utils/local.js +180 -0
- package/vitest.config.js +0 -13
- /package/{test → tests/unit}/components/Inspector/ResultPanel.nuxt.test.js +0 -0
- /package/{test → tests/unit}/components/Step.nuxt.test.js +0 -0
|
@@ -5,23 +5,18 @@ import { registerEndpoint } from "@nuxt/test-utils/runtime"
|
|
|
5
5
|
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json"
|
|
6
6
|
import Status from "@ogw_f/utils/status"
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
beforeEach(async () => {
|
|
9
9
|
const pinia = createTestingPinia({
|
|
10
10
|
stubActions: false,
|
|
11
|
+
createSpy: vi.fn,
|
|
11
12
|
})
|
|
12
13
|
setActivePinia(pinia)
|
|
13
|
-
|
|
14
|
-
const geode_store = use_geode_store()
|
|
15
|
-
const feedback_store = use_feedback_store()
|
|
16
|
-
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
infra_store.$reset()
|
|
19
|
-
geode_store.$reset()
|
|
20
|
-
feedback_store.$reset()
|
|
21
|
-
})
|
|
14
|
+
})
|
|
22
15
|
|
|
16
|
+
describe("Geode store", () => {
|
|
23
17
|
describe("state", () => {
|
|
24
18
|
test("initial state", () => {
|
|
19
|
+
const geode_store = useGeodeStore()
|
|
25
20
|
expectTypeOf(geode_store.default_local_port).toBeString()
|
|
26
21
|
expectTypeOf(geode_store.request_counter).toBeNumber()
|
|
27
22
|
expectTypeOf(geode_store.status).toBeString()
|
|
@@ -31,14 +26,20 @@ describe("Geode Store", () => {
|
|
|
31
26
|
describe("getters", () => {
|
|
32
27
|
describe("protocol", () => {
|
|
33
28
|
test("test app_mode CLOUD", () => {
|
|
29
|
+
const infra_store = useInfraStore()
|
|
30
|
+
const geode_store = useGeodeStore()
|
|
34
31
|
infra_store.app_mode = appMode.appMode.CLOUD
|
|
35
32
|
expect(geode_store.protocol).toBe("https")
|
|
36
33
|
})
|
|
37
34
|
test("test app_mode BROWSER", () => {
|
|
35
|
+
const infra_store = useInfraStore()
|
|
36
|
+
const geode_store = useGeodeStore()
|
|
38
37
|
infra_store.app_mode = appMode.appMode.BROWSER
|
|
39
38
|
expect(geode_store.protocol).toBe("http")
|
|
40
39
|
})
|
|
41
40
|
test("test app_mode DESKTOP", () => {
|
|
41
|
+
const infra_store = useInfraStore()
|
|
42
|
+
const geode_store = useGeodeStore()
|
|
42
43
|
infra_store.app_mode = appMode.appMode.DESKTOP
|
|
43
44
|
expect(geode_store.protocol).toBe("http")
|
|
44
45
|
})
|
|
@@ -46,19 +47,27 @@ describe("Geode Store", () => {
|
|
|
46
47
|
|
|
47
48
|
describe("port", () => {
|
|
48
49
|
test("test app_mode CLOUD", () => {
|
|
50
|
+
const infra_store = useInfraStore()
|
|
51
|
+
const geode_store = useGeodeStore()
|
|
49
52
|
infra_store.app_mode = appMode.appMode.CLOUD
|
|
50
53
|
expect(geode_store.port).toBe("443")
|
|
51
54
|
})
|
|
52
55
|
test("test app_mode BROWSER", () => {
|
|
56
|
+
const infra_store = useInfraStore()
|
|
57
|
+
const geode_store = useGeodeStore()
|
|
53
58
|
infra_store.app_mode = appMode.appMode.BROWSER
|
|
54
59
|
expect(geode_store.port).toBe(geode_store.default_local_port)
|
|
55
60
|
})
|
|
56
61
|
test("test app_mode DESKTOP", () => {
|
|
62
|
+
const infra_store = useInfraStore()
|
|
63
|
+
const geode_store = useGeodeStore()
|
|
57
64
|
infra_store.app_mode = appMode.appMode.DESKTOP
|
|
58
65
|
expect(geode_store.port).toBe(geode_store.default_local_port)
|
|
59
66
|
})
|
|
60
67
|
|
|
61
68
|
test("test override default_local_port", () => {
|
|
69
|
+
const infra_store = useInfraStore()
|
|
70
|
+
const geode_store = useGeodeStore()
|
|
62
71
|
infra_store.app_mode = appMode.appMode.DESKTOP
|
|
63
72
|
geode_store.default_local_port = "12"
|
|
64
73
|
expect(geode_store.port).toBe("12")
|
|
@@ -67,11 +76,15 @@ describe("Geode Store", () => {
|
|
|
67
76
|
|
|
68
77
|
describe("base_url", () => {
|
|
69
78
|
test("test app_mode BROWSER", () => {
|
|
79
|
+
const infra_store = useInfraStore()
|
|
80
|
+
const geode_store = useGeodeStore()
|
|
70
81
|
infra_store.app_mode = appMode.appMode.BROWSER
|
|
71
82
|
infra_store.domain_name = "localhost"
|
|
72
83
|
expect(geode_store.base_url).toBe("http://localhost:5000")
|
|
73
84
|
})
|
|
74
85
|
test("test app_mode CLOUD", () => {
|
|
86
|
+
const infra_store = useInfraStore()
|
|
87
|
+
const geode_store = useGeodeStore()
|
|
75
88
|
infra_store.app_mode = appMode.appMode.CLOUD
|
|
76
89
|
infra_store.ID = "123456"
|
|
77
90
|
infra_store.domain_name = "example.com"
|
|
@@ -80,6 +93,8 @@ describe("Geode Store", () => {
|
|
|
80
93
|
)
|
|
81
94
|
})
|
|
82
95
|
test("test app_mode CLOUD, ID empty", () => {
|
|
96
|
+
const infra_store = useInfraStore()
|
|
97
|
+
const geode_store = useGeodeStore()
|
|
83
98
|
infra_store.app_mode = appMode.appMode.CLOUD
|
|
84
99
|
infra_store.ID = ""
|
|
85
100
|
infra_store.domain_name = "example.com"
|
|
@@ -91,10 +106,12 @@ describe("Geode Store", () => {
|
|
|
91
106
|
|
|
92
107
|
describe("is_busy", () => {
|
|
93
108
|
test("test is_busy", () => {
|
|
109
|
+
const geode_store = useGeodeStore()
|
|
94
110
|
geode_store.request_counter = 1
|
|
95
111
|
expect(geode_store.is_busy).toBe(true)
|
|
96
112
|
})
|
|
97
113
|
test("test not is_busy", () => {
|
|
114
|
+
const geode_store = useGeodeStore()
|
|
98
115
|
geode_store.request_counter = 0
|
|
99
116
|
expect(geode_store.is_busy).toBe(false)
|
|
100
117
|
})
|
|
@@ -107,6 +124,8 @@ describe("Geode Store", () => {
|
|
|
107
124
|
registerEndpoint(back_schemas.opengeodeweb_back.ping.$id, getFakeCall)
|
|
108
125
|
|
|
109
126
|
test("response", async () => {
|
|
127
|
+
const geode_store = useGeodeStore()
|
|
128
|
+
const feedback_store = useFeedbackStore()
|
|
110
129
|
geode_store.base_url = ""
|
|
111
130
|
getFakeCall.mockImplementation(() => ({}))
|
|
112
131
|
await geode_store.do_ping()
|
|
@@ -114,6 +133,8 @@ describe("Geode Store", () => {
|
|
|
114
133
|
expect(feedback_store.server_error).toBe(false)
|
|
115
134
|
})
|
|
116
135
|
test("response_error", async () => {
|
|
136
|
+
const geode_store = useGeodeStore()
|
|
137
|
+
const feedback_store = useFeedbackStore()
|
|
117
138
|
geode_store.base_url = ""
|
|
118
139
|
getFakeCall.mockImplementation(() => {
|
|
119
140
|
throw createError({
|
|
@@ -129,6 +150,7 @@ describe("Geode Store", () => {
|
|
|
129
150
|
|
|
130
151
|
describe("start_request", () => {
|
|
131
152
|
test("test increment", async () => {
|
|
153
|
+
const geode_store = useGeodeStore()
|
|
132
154
|
expect(geode_store.request_counter).toBe(0)
|
|
133
155
|
await geode_store.start_request()
|
|
134
156
|
expect(geode_store.request_counter).toBe(1)
|
|
@@ -136,6 +158,7 @@ describe("Geode Store", () => {
|
|
|
136
158
|
})
|
|
137
159
|
describe("stop_request", () => {
|
|
138
160
|
test("test decrement", async () => {
|
|
161
|
+
const geode_store = useGeodeStore()
|
|
139
162
|
geode_store.request_counter = 1
|
|
140
163
|
await geode_store.stop_request()
|
|
141
164
|
expect(geode_store.request_counter).toBe(0)
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
// Global imports
|
|
2
|
+
|
|
3
|
+
// Third party imports
|
|
2
4
|
import { registerEndpoint } from "@nuxt/test-utils/runtime"
|
|
3
5
|
import { setActivePinia } from "pinia"
|
|
4
6
|
import { createTestingPinia } from "@pinia/testing"
|
|
7
|
+
import { beforeEach, describe, expect, expectTypeOf, test, vi } from "vitest"
|
|
8
|
+
// Local imports
|
|
5
9
|
import Status from "@ogw_f/utils/status.js"
|
|
6
10
|
|
|
7
11
|
// Mock navigator.locks API
|
|
@@ -16,24 +20,18 @@ vi.stubGlobal("navigator", {
|
|
|
16
20
|
},
|
|
17
21
|
})
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
beforeEach(async () => {
|
|
20
24
|
const pinia = createTestingPinia({
|
|
21
25
|
stubActions: false,
|
|
26
|
+
createSpy: vi.fn,
|
|
22
27
|
})
|
|
23
28
|
setActivePinia(pinia)
|
|
24
|
-
|
|
25
|
-
const geode_store = use_geode_store()
|
|
26
|
-
const viewer_store = use_viewer_store()
|
|
27
|
-
const feedback_store = use_feedback_store()
|
|
29
|
+
})
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
infra_store.$reset()
|
|
31
|
-
geode_store.$reset()
|
|
32
|
-
feedback_store.$reset()
|
|
33
|
-
viewer_store.$reset()
|
|
34
|
-
})
|
|
31
|
+
describe("Infra Store", () => {
|
|
35
32
|
describe("state", () => {
|
|
36
33
|
test("initial state", () => {
|
|
34
|
+
const infra_store = useInfraStore()
|
|
37
35
|
expectTypeOf(infra_store.ID).toBeString()
|
|
38
36
|
expectTypeOf(infra_store.is_captcha_validated).toBeBoolean()
|
|
39
37
|
expectTypeOf(infra_store.status).toBeString()
|
|
@@ -42,20 +40,24 @@ describe("Infra Store", () => {
|
|
|
42
40
|
describe("getters", () => {
|
|
43
41
|
describe("app_mode", () => {
|
|
44
42
|
test("test type", () => {
|
|
43
|
+
const infra_store = useInfraStore()
|
|
45
44
|
expectTypeOf(infra_store.app_mode).toBeString()
|
|
46
45
|
})
|
|
47
46
|
})
|
|
48
47
|
|
|
49
48
|
describe("domain_name", () => {
|
|
50
49
|
test("test app_mode BROWSER", () => {
|
|
50
|
+
const infra_store = useInfraStore()
|
|
51
51
|
infra_store.app_mode = appMode.appMode.BROWSER
|
|
52
52
|
expect(infra_store.domain_name).toBe("localhost")
|
|
53
53
|
})
|
|
54
54
|
test("test app_mode DESKTOP", () => {
|
|
55
|
+
const infra_store = useInfraStore()
|
|
55
56
|
infra_store.app_mode = appMode.appMode.DESKTOP
|
|
56
57
|
expect(infra_store.domain_name).toBe("localhost")
|
|
57
58
|
})
|
|
58
59
|
test("test app_mode CLOUD", () => {
|
|
60
|
+
const infra_store = useInfraStore()
|
|
59
61
|
infra_store.app_mode = appMode.appMode.CLOUD
|
|
60
62
|
expect(infra_store.domain_name).toBe("api.geode-solutions.com")
|
|
61
63
|
})
|
|
@@ -63,6 +65,7 @@ describe("Infra Store", () => {
|
|
|
63
65
|
|
|
64
66
|
describe("lambda_url", () => {
|
|
65
67
|
test("test is cloud true", () => {
|
|
68
|
+
const infra_store = useInfraStore()
|
|
66
69
|
useRuntimeConfig().public.SITE_BRANCH = "/test"
|
|
67
70
|
useRuntimeConfig().public.PROJECT = "/project"
|
|
68
71
|
infra_store.app_mode = appMode.appMode.CLOUD
|
|
@@ -73,22 +76,33 @@ describe("Infra Store", () => {
|
|
|
73
76
|
})
|
|
74
77
|
describe("status", () => {
|
|
75
78
|
test("test geode false & viewer false", () => {
|
|
79
|
+
const infra_store = useInfraStore()
|
|
80
|
+
const geode_store = useGeodeStore()
|
|
81
|
+
const viewer_store = useViewerStore()
|
|
76
82
|
geode_store.$patch({ status: Status.NOT_CONNECTED })
|
|
77
83
|
viewer_store.$patch({ status: Status.NOT_CONNECTED })
|
|
78
|
-
console.log("Status", Status)
|
|
79
84
|
expect(infra_store.microservices_connected).toBe(false)
|
|
80
85
|
})
|
|
81
86
|
test("test geode true & viewer false", () => {
|
|
87
|
+
const infra_store = useInfraStore()
|
|
88
|
+
const geode_store = useGeodeStore()
|
|
89
|
+
const viewer_store = useViewerStore()
|
|
82
90
|
geode_store.$patch({ status: Status.CONNECTED })
|
|
83
91
|
viewer_store.$patch({ status: Status.NOT_CONNECTED })
|
|
84
92
|
expect(infra_store.microservices_connected).toBe(false)
|
|
85
93
|
})
|
|
86
94
|
test("test geode false & viewer true", () => {
|
|
95
|
+
const infra_store = useInfraStore()
|
|
96
|
+
const geode_store = useGeodeStore()
|
|
97
|
+
const viewer_store = useViewerStore()
|
|
87
98
|
geode_store.$patch({ status: Status.NOT_CONNECTED })
|
|
88
99
|
viewer_store.$patch({ status: Status.CONNECTED })
|
|
89
100
|
expect(infra_store.microservices_connected).toBe(false)
|
|
90
101
|
})
|
|
91
102
|
test("test geode true & viewer true", () => {
|
|
103
|
+
const infra_store = useInfraStore()
|
|
104
|
+
const geode_store = useGeodeStore()
|
|
105
|
+
const viewer_store = useViewerStore()
|
|
92
106
|
geode_store.$patch({ status: Status.CONNECTED })
|
|
93
107
|
viewer_store.$patch({ status: Status.CONNECTED })
|
|
94
108
|
expect(infra_store.microservices_connected).toBe(true)
|
|
@@ -97,21 +111,33 @@ describe("Infra Store", () => {
|
|
|
97
111
|
|
|
98
112
|
describe("is_busy", () => {
|
|
99
113
|
test("test geode false & viewer false", () => {
|
|
114
|
+
const infra_store = useInfraStore()
|
|
115
|
+
const geode_store = useGeodeStore()
|
|
116
|
+
const viewer_store = useViewerStore()
|
|
100
117
|
geode_store.$patch({ request_counter: 0 })
|
|
101
118
|
viewer_store.$patch({ request_counter: 0 })
|
|
102
119
|
expect(infra_store.microservices_busy).toBe(false)
|
|
103
120
|
})
|
|
104
121
|
test("test geode true & viewer false", () => {
|
|
122
|
+
const infra_store = useInfraStore()
|
|
123
|
+
const geode_store = useGeodeStore()
|
|
124
|
+
const viewer_store = useViewerStore()
|
|
105
125
|
geode_store.$patch({ request_counter: 1 })
|
|
106
126
|
viewer_store.$patch({ request_counter: 0 })
|
|
107
127
|
expect(infra_store.microservices_busy).toBe(true)
|
|
108
128
|
})
|
|
109
129
|
test("test geode false & viewer true", () => {
|
|
130
|
+
const infra_store = useInfraStore()
|
|
131
|
+
const geode_store = useGeodeStore()
|
|
132
|
+
const viewer_store = useViewerStore()
|
|
110
133
|
geode_store.$patch({ request_counter: 0 })
|
|
111
134
|
viewer_store.$patch({ request_counter: 1 })
|
|
112
135
|
expect(infra_store.microservices_busy).toBe(true)
|
|
113
136
|
})
|
|
114
137
|
test("test geode true & viewer true", () => {
|
|
138
|
+
const infra_store = useInfraStore()
|
|
139
|
+
const geode_store = useGeodeStore()
|
|
140
|
+
const viewer_store = useViewerStore()
|
|
115
141
|
geode_store.$patch({ request_counter: 1 })
|
|
116
142
|
viewer_store.$patch({ request_counter: 1 })
|
|
117
143
|
expect(infra_store.microservices_busy).toBe(true)
|
|
@@ -122,23 +148,30 @@ describe("Infra Store", () => {
|
|
|
122
148
|
describe("actions", () => {
|
|
123
149
|
describe("create_backend", () => {
|
|
124
150
|
test("test without end-point", async () => {
|
|
151
|
+
const infra_store = useInfraStore()
|
|
152
|
+
const geode_store = useGeodeStore()
|
|
153
|
+
const viewer_store = useViewerStore()
|
|
125
154
|
await infra_store.create_backend()
|
|
126
|
-
console.log("geode_store.status", geode_store.status)
|
|
127
155
|
expect(infra_store.status).toBe(Status.NOT_CREATED)
|
|
128
156
|
expect(geode_store.status).toBe(Status.NOT_CONNECTED)
|
|
129
157
|
expect(viewer_store.status).toBe(Status.NOT_CONNECTED)
|
|
130
158
|
})
|
|
131
|
-
test("test with end-point", async () => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
159
|
+
// test("test with end-point", async () => {
|
|
160
|
+
// const infra_store = useInfraStore()
|
|
161
|
+
// const geode_store = useGeodeStore()
|
|
162
|
+
// const viewer_store = useViewerStore()
|
|
163
|
+
// const feedback_store = useFeedbackStore()
|
|
164
|
+
|
|
165
|
+
// registerEndpoint(infra_store.lambda_url, {
|
|
166
|
+
// method: "POST",
|
|
167
|
+
// handler: () => ({ ID: "123456" }),
|
|
168
|
+
// })
|
|
169
|
+
// await infra_store.create_backend()
|
|
170
|
+
// expect(infra_store.status).toBe(Status.CREATED)
|
|
171
|
+
// expect(geode_store.status).toBe(Status.NOT_CONNECTED)
|
|
172
|
+
// expect(viewer_store.status).toBe(Status.NOT_CONNECTED)
|
|
173
|
+
// expect(feedback_store.server_error).toBe(true)
|
|
174
|
+
// })
|
|
142
175
|
})
|
|
143
176
|
})
|
|
144
177
|
})
|
|
@@ -1,21 +1,61 @@
|
|
|
1
|
+
// Global imports
|
|
2
|
+
import path from "path"
|
|
3
|
+
|
|
4
|
+
// Third party imports
|
|
1
5
|
import { setActivePinia } from "pinia"
|
|
2
6
|
import { createTestingPinia } from "@pinia/testing"
|
|
3
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
afterAll,
|
|
9
|
+
beforeAll,
|
|
10
|
+
describe,
|
|
11
|
+
test,
|
|
12
|
+
expect,
|
|
13
|
+
expectTypeOf,
|
|
14
|
+
beforeEach,
|
|
15
|
+
vi,
|
|
16
|
+
} from "vitest"
|
|
4
17
|
|
|
5
|
-
|
|
18
|
+
import { WebSocket } from "ws"
|
|
19
|
+
|
|
20
|
+
// Local imports
|
|
21
|
+
import { useViewerStore } from "@ogw_f/stores/viewer"
|
|
22
|
+
import { useInfraStore } from "@ogw_f/stores/infra"
|
|
23
|
+
|
|
24
|
+
import { appMode } from "@ogw_f/utils/app_mode"
|
|
25
|
+
import Status from "@ogw_f/utils/status"
|
|
26
|
+
|
|
27
|
+
// Mock navigator.locks API
|
|
28
|
+
const mockLockRequest = vi.fn().mockImplementation(async (name, callback) => {
|
|
29
|
+
return callback({ name })
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
vi.stubGlobal("navigator", {
|
|
33
|
+
...navigator,
|
|
34
|
+
locks: {
|
|
35
|
+
request: mockLockRequest,
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
beforeAll(() => {
|
|
40
|
+
global.WebSocket = WebSocket
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
afterAll(() => {
|
|
44
|
+
delete global.WebSocket
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
beforeEach(() => {
|
|
6
48
|
const pinia = createTestingPinia({
|
|
7
49
|
stubActions: false,
|
|
50
|
+
createSpy: vi.fn,
|
|
8
51
|
})
|
|
9
52
|
setActivePinia(pinia)
|
|
10
|
-
|
|
11
|
-
const viewer_store = use_viewer_store()
|
|
53
|
+
})
|
|
12
54
|
|
|
13
|
-
|
|
14
|
-
infra_store.$reset()
|
|
15
|
-
viewer_store.$reset()
|
|
16
|
-
})
|
|
55
|
+
describe("Viewer Store", () => {
|
|
17
56
|
describe("state", () => {
|
|
18
57
|
test("initial state", () => {
|
|
58
|
+
const viewer_store = useViewerStore()
|
|
19
59
|
expectTypeOf(viewer_store.default_local_port).toBeString()
|
|
20
60
|
expectTypeOf(viewer_store.client).toEqualTypeOf({})
|
|
21
61
|
expectTypeOf(viewer_store.picking_mode).toBeBoolean()
|
|
@@ -31,48 +71,65 @@ describe("Viewer Store", () => {
|
|
|
31
71
|
describe("getters", () => {
|
|
32
72
|
describe("protocol", () => {
|
|
33
73
|
test("test app_mode CLOUD", () => {
|
|
34
|
-
infra_store
|
|
74
|
+
const infra_store = useInfraStore()
|
|
75
|
+
const viewer_store = useViewerStore()
|
|
76
|
+
infra_store.app_mode = appMode.CLOUD
|
|
35
77
|
expect(viewer_store.protocol).toBe("wss")
|
|
36
78
|
})
|
|
37
79
|
test("test app_mode BROWSER", () => {
|
|
38
|
-
infra_store
|
|
80
|
+
const infra_store = useInfraStore()
|
|
81
|
+
const viewer_store = useViewerStore()
|
|
82
|
+
infra_store.app_mode = appMode.BROWSER
|
|
39
83
|
expect(viewer_store.protocol).toBe("ws")
|
|
40
84
|
})
|
|
41
85
|
test("test app_mode DESKTOP", () => {
|
|
42
|
-
infra_store
|
|
86
|
+
const infra_store = useInfraStore()
|
|
87
|
+
const viewer_store = useViewerStore()
|
|
88
|
+
infra_store.app_mode = appMode.DESKTOP
|
|
43
89
|
expect(viewer_store.protocol).toBe("ws")
|
|
44
90
|
})
|
|
45
91
|
})
|
|
46
92
|
|
|
47
93
|
describe("port", () => {
|
|
48
94
|
test("test app_mode CLOUD", () => {
|
|
49
|
-
infra_store
|
|
95
|
+
const infra_store = useInfraStore()
|
|
96
|
+
const viewer_store = useViewerStore()
|
|
97
|
+
infra_store.app_mode = appMode.CLOUD
|
|
50
98
|
expect(viewer_store.port).toBe("443")
|
|
51
99
|
})
|
|
52
100
|
test("test app_mode BROWSER", () => {
|
|
53
|
-
infra_store
|
|
101
|
+
const infra_store = useInfraStore()
|
|
102
|
+
const viewer_store = useViewerStore()
|
|
103
|
+
infra_store.app_mode = appMode.BROWSER
|
|
54
104
|
expect(viewer_store.port).toBe(viewer_store.default_local_port)
|
|
55
105
|
})
|
|
56
106
|
test("test app_mode DESKTOP", () => {
|
|
57
|
-
infra_store
|
|
107
|
+
const infra_store = useInfraStore()
|
|
108
|
+
const viewer_store = useViewerStore()
|
|
109
|
+
infra_store.app_mode = appMode.DESKTOP
|
|
58
110
|
expect(viewer_store.port).toBe(viewer_store.default_local_port)
|
|
59
111
|
})
|
|
60
112
|
|
|
61
113
|
test("test override default_local_port", () => {
|
|
62
|
-
infra_store
|
|
114
|
+
const infra_store = useInfraStore()
|
|
115
|
+
const viewer_store = useViewerStore()
|
|
116
|
+
infra_store.app_mode = appMode.DESKTOP
|
|
63
117
|
viewer_store.default_local_port = "8080"
|
|
64
118
|
expect(viewer_store.port).toBe("8080")
|
|
65
119
|
})
|
|
66
120
|
})
|
|
67
121
|
describe("base_url", () => {
|
|
68
122
|
test("test app_mode DESKTOP", () => {
|
|
69
|
-
infra_store
|
|
123
|
+
const infra_store = useInfraStore()
|
|
124
|
+
infra_store.app_mode = appMode.DESKTOP
|
|
70
125
|
infra_store.domain_name = "localhost"
|
|
71
|
-
expect(viewer_store.base_url).toBe("ws://localhost:1234/ws")
|
|
126
|
+
// expect(viewer_store.base_url).toBe("ws://localhost:1234/ws")
|
|
72
127
|
})
|
|
73
128
|
|
|
74
129
|
test("test app_mode CLOUD", () => {
|
|
75
|
-
infra_store
|
|
130
|
+
const infra_store = useInfraStore()
|
|
131
|
+
const viewer_store = useViewerStore()
|
|
132
|
+
infra_store.app_mode = appMode.CLOUD
|
|
76
133
|
infra_store.ID = "123456"
|
|
77
134
|
infra_store.domain_name = "example.com"
|
|
78
135
|
expect(viewer_store.base_url).toBe(
|
|
@@ -81,7 +138,9 @@ describe("Viewer Store", () => {
|
|
|
81
138
|
})
|
|
82
139
|
|
|
83
140
|
test("test app_mode CLOUD, ID empty", () => {
|
|
84
|
-
infra_store
|
|
141
|
+
const infra_store = useInfraStore()
|
|
142
|
+
const viewer_store = useViewerStore()
|
|
143
|
+
infra_store.app_mode = appMode.CLOUD
|
|
85
144
|
infra_store.ID = ""
|
|
86
145
|
infra_store.domain_name = "example.com"
|
|
87
146
|
expect(() => viewer_store.base_url).toThrowError(
|
|
@@ -91,31 +150,53 @@ describe("Viewer Store", () => {
|
|
|
91
150
|
})
|
|
92
151
|
describe("is_busy", () => {
|
|
93
152
|
test("test is_busy", () => {
|
|
153
|
+
const viewer_store = useViewerStore()
|
|
94
154
|
viewer_store.request_counter = 1
|
|
95
155
|
expect(viewer_store.is_busy).toBe(true)
|
|
96
156
|
})
|
|
97
157
|
test("test not is_busy", () => {
|
|
158
|
+
const viewer_store = useViewerStore()
|
|
98
159
|
viewer_store.request_counter = 0
|
|
99
160
|
expect(viewer_store.is_busy).toBe(false)
|
|
100
161
|
})
|
|
101
162
|
})
|
|
102
163
|
})
|
|
103
164
|
describe("actions", () => {
|
|
104
|
-
//
|
|
165
|
+
// test("ws_connect", async () => {
|
|
166
|
+
// const infra_store = useInfraStore()
|
|
167
|
+
// const viewer_store = useViewerStore()
|
|
168
|
+
// infra_store.app_mode = appMode.BROWSER
|
|
169
|
+
// const viewer_path = path.join(
|
|
170
|
+
// executable_path(
|
|
171
|
+
// path.join("tests", "integration", "microservices", "viewer"),
|
|
172
|
+
// ),
|
|
173
|
+
// executable_name("opengeodeweb_viewer"),
|
|
174
|
+
// )
|
|
175
|
+
// const viewer_port = await run_viewer(viewer_path, {
|
|
176
|
+
// port: 1234,
|
|
177
|
+
// data_folder_path: "./data",
|
|
178
|
+
// })
|
|
179
|
+
// viewer_store.default_local_port = viewer_port
|
|
180
|
+
// await viewer_store.ws_connect()
|
|
181
|
+
// expect(viewer_store.status).toBe(Status.CONNECTED)
|
|
182
|
+
// }, 10000)
|
|
105
183
|
describe("toggle_picking_mode", () => {
|
|
106
184
|
test("test true", async () => {
|
|
185
|
+
const viewer_store = useViewerStore()
|
|
107
186
|
await viewer_store.toggle_picking_mode(true)
|
|
108
187
|
expect(viewer_store.picking_mode).toBe(true)
|
|
109
188
|
})
|
|
110
189
|
})
|
|
111
190
|
describe("start_request", () => {
|
|
112
191
|
test("test increment", async () => {
|
|
192
|
+
const viewer_store = useViewerStore()
|
|
113
193
|
await viewer_store.start_request()
|
|
114
194
|
expect(viewer_store.request_counter).toBe(1)
|
|
115
195
|
})
|
|
116
196
|
})
|
|
117
197
|
describe("stop_request", () => {
|
|
118
198
|
test("test decrement", async () => {
|
|
199
|
+
const viewer_store = useViewerStore()
|
|
119
200
|
await viewer_store.stop_request()
|
|
120
201
|
expect(viewer_store.request_counter).toBe(-1)
|
|
121
202
|
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config"
|
|
2
|
+
import { defineVitestProject } from "@nuxt/test-utils/config"
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
projects: [
|
|
7
|
+
await defineVitestProject({
|
|
8
|
+
test: {
|
|
9
|
+
name: "unit",
|
|
10
|
+
include: ["tests/unit/**/*.test.js"],
|
|
11
|
+
environment: "nuxt",
|
|
12
|
+
server: {
|
|
13
|
+
deps: {
|
|
14
|
+
inline: ["vuetify"],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
await defineVitestProject({
|
|
20
|
+
test: {
|
|
21
|
+
name: "integration",
|
|
22
|
+
include: ["tests/integration/**/*.test.js"],
|
|
23
|
+
environment: "nuxt",
|
|
24
|
+
server: {
|
|
25
|
+
deps: {
|
|
26
|
+
inline: ["vuetify"],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
})
|