Skip to content

Commit 5efeabc

Browse files
tests passing
1 parent 0e42f4b commit 5efeabc

File tree

7 files changed

+24
-19
lines changed

7 files changed

+24
-19
lines changed

nuxt.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ export default defineNuxtConfig({
55
SITE_BRANCH:
66
process.env.NODE_ENV === "production" ? process.env.SITE_BRANCH : "",
77
PROJECT: process.env.NODE_ENV === "production" ? process.env.PROJECT : "",
8-
BROWSER: process.env.BROWSER || false,
9-
GEODE_PORT: process.env.GEODE_PORT || "",
10-
VIEWER_PORT: process.env.VIEWER_PORT || "",
8+
BROWSER: process.env.BROWSER ?? false,
9+
GEODE_PORT: process.env.GEODE_PORT ?? null,
10+
VIEWER_PORT: process.env.VIEWER_PORT ?? null,
1111
},
1212
},
1313

stores/geode.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ export const use_geode_store = defineStore("geode", {
1818
if (use_infra_store().app_mode == appMode.appMode.CLOUD) {
1919
return "443"
2020
}
21-
if (useRuntimeConfig().public.GEODE_PORT) {
22-
return useRuntimeConfig().public.GEODE_PORT
21+
const GEODE_PORT = useRuntimeConfig().public.GEODE_PORT
22+
if (GEODE_PORT != null && GEODE_PORT !== "") {
23+
return GEODE_PORT
2324
}
2425
return this.default_local_port
2526
},

stores/infra.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { useStorage } from "@vueuse/core"
22
import Status from "@ogw_f/utils/status.js"
3+
import getCaptchaState from "@ogw_f/utils/captcha_state.js"
34

45
export const use_infra_store = defineStore("infra", {
56
state: () => ({
67
app_mode: getAppMode(),
78
ID: useStorage("ID", ""),
8-
is_captcha_validated: true,
9+
is_captcha_validated: getCaptchaState(),
910
status: Status.NOT_CREATED,
1011
}),
1112
getters: {

stores/viewer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import vtkWSLinkClient from "@kitware/vtk.js/IO/Core/WSLinkClient"
33
import "@kitware/vtk.js/Rendering/OpenGL/Profiles/Geometry"
44
import schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
55
import Status from "@ogw_f/utils/status.js"
6-
import { useRuntimeConfig } from "nuxt/app"
76

87
export const use_viewer_store = defineStore("viewer", {
98
state: () => ({
@@ -27,8 +26,9 @@ export const use_viewer_store = defineStore("viewer", {
2726
if (use_infra_store().app_mode == appMode.appMode.CLOUD) {
2827
return "443"
2928
}
30-
if (useRuntimeConfig().public.VIEWER_PORT) {
31-
return useRuntimeConfig().public.VIEWER_PORT
29+
const VIEWER_PORT = useRuntimeConfig().public.VIEWER_PORT
30+
if (VIEWER_PORT != null && VIEWER_PORT !== "") {
31+
return VIEWER_PORT
3232
}
3333
return this.default_local_port
3434
},

test/components/Launcher.nuxt.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ global.ResizeObserver = require("resize-observer-polyfill")
3131

3232
describe("Launcher.vue", async () => {
3333
test(`Mount`, async () => {
34-
const spy_infra_store = vi.spyOn(infra_store, "create_backend")
34+
const spy_create_backend = vi.spyOn(infra_store, "create_backend")
3535
const wrapper = await mountSuspended(Launcher, {
3636
global: {
3737
plugins: [vuetify],
@@ -40,6 +40,6 @@ describe("Launcher.vue", async () => {
4040
expect(wrapper.exists()).toBe(true)
4141
await infra_store.$patch({ is_captcha_validated: true })
4242
flushPromises()
43-
expect(spy_infra_store).toHaveBeenCalled()
43+
expect(spy_create_backend).toHaveBeenCalled()
4444
})
4545
})

test/stores/Viewer.nuxt.test.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { setActivePinia } from "pinia"
22
import { createTestingPinia } from "@pinia/testing"
33
import { describe, test, expect, expectTypeOf, beforeEach } from "vitest"
4-
import { useRuntimeConfig } from "nuxt/app"
54

65
describe("Viewer Store", () => {
76
const pinia = createTestingPinia({
@@ -64,13 +63,6 @@ describe("Viewer Store", () => {
6463
viewer_store.default_local_port = "8080"
6564
expect(viewer_store.port).toBe("8080")
6665
})
67-
68-
test("test env VIEWER_PORT", () => {
69-
process.env.VIEWER_PORT = "8080"
70-
infra_store.app_mode = appMode.appMode.DESKTOP
71-
console.log("VIEWER_PORT", useRuntimeConfig().public.VIEWER_PORT)
72-
expect(viewer_store.port).toBe("8080")
73-
})
7466
})
7567
describe("base_url", () => {
7668
test("test app_mode DESKTOP", () => {

utils/captcha_state.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function getCaptchaState() {
2+
if (
3+
getAppMode() === appMode.appMode.BROWSER ||
4+
getAppMode() === appMode.appMode.DESKTOP
5+
) {
6+
return true
7+
}
8+
return false
9+
}
10+
11+
export default getCaptchaState

0 commit comments

Comments
 (0)