Skip to content

Commit ad05157

Browse files
pr comments / coverage
1 parent e89cf39 commit ad05157

File tree

4 files changed

+53
-45
lines changed

4 files changed

+53
-45
lines changed

components/PackagesVersions.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@
1919
</template>
2020

2121
<script setup>
22-
const infra_store = use_infra_store()
22+
import Status from "@/utils/status.js"
2323
2424
const props = defineProps({
2525
schema: { type: Object, required: true },
2626
})
27-
const { schema } = props
2827
28+
const geode_store = use_geode_store()
2929
const packages_versions = ref([])
3030
3131
async function get_packages_versions() {
3232
const array_promise = []
3333
3434
const promise = new Promise((resolve, reject) => {
3535
api_fetch(
36-
{ schema },
36+
{ schema: props.schema },
3737
{
3838
request_error_function: () => {
3939
reject()
@@ -52,8 +52,8 @@
5252
await Promise.all(array_promise)
5353
}
5454
55-
watch(infra_store.status, () => {
56-
get_packages_versions()
55+
watch(geode_store.status, (value) => {
56+
if (value == Status.CONNECTED) get_packages_versions()
5757
})
5858
5959
await get_packages_versions()

composables/run_function_when_microservices_connected.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import Status from "@/utils/status.js"
2-
31
export function run_function_when_microservices_connected(function_to_run) {
42
const infra_store = use_infra_store()
53
const { microservices_connected } = storeToRefs(infra_store)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"@nuxt/test-utils": "^3.15.1",
1111
"@pinia/testing": "^0.1.7",
1212
"@vitejs/plugin-vue": "^5.2.1",
13+
"@vitest/coverage-v8": "^3.0.8",
1314
"@vue/test-utils": "^2.4.6",
1415
"eslint": "^8.57.0",
1516
"eslint-plugin-import": "^2.29.1",
@@ -73,4 +74,4 @@
7374
"publishConfig": {
7475
"access": "public"
7576
}
76-
}
77+
}
Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,47 @@
1-
// // @vitest-environment nuxt
2-
3-
// import { describe, expect, test, vi } from "vitest"
4-
// import { flushPromises } from "@vue/test-utils"
5-
// import { mountSuspended } from "@nuxt/test-utils/runtime"
6-
7-
// import { createVuetify } from "vuetify"
8-
// import * as components from "vuetify/components"
9-
// import * as directives from "vuetify/directives"
10-
11-
// import Launcher from "@/components/Launcher.vue"
12-
13-
// const vuetify = createVuetify({
14-
// components,
15-
// directives,
16-
// })
17-
18-
// const infra_store = use_infra_store()
19-
20-
// global.ResizeObserver = require("resize-observer-polyfill")
21-
22-
// describe("Launcher.vue", async () => {
23-
// test(`Mount`, async () => {
24-
// const spy_infra_store = vi.spyOn(infra_store, "create_backend")
25-
// const wrapper = await mountSuspended(Launcher, {
26-
// global: {
27-
// plugins: [vuetify],
28-
// },
29-
// })
30-
// expect(wrapper.exists()).toBe(true)
31-
// await infra_store.$patch({ is_captcha_validated: true })
32-
// flushPromises()
33-
// expect(spy_infra_store).toHaveBeenCalled()
34-
// })
35-
// })
36-
describe("Fake", async () => {
37-
test(`Fake`, async () => {})
1+
// @vitest-environment nuxt
2+
3+
import { describe, expect, test, vi } from "vitest"
4+
import { flushPromises } from "@vue/test-utils"
5+
import { mountSuspended } from "@nuxt/test-utils/runtime"
6+
7+
import { createVuetify } from "vuetify"
8+
import * as components from "vuetify/components"
9+
import * as directives from "vuetify/directives"
10+
11+
import Launcher from "@/components/Launcher.vue"
12+
13+
const vuetify = createVuetify({
14+
components,
15+
directives,
16+
})
17+
18+
const infra_store = use_infra_store()
19+
20+
// Mock navigator.locks API
21+
const mockLockRequest = vi.fn().mockImplementation(async (name, callback) => {
22+
return callback({ name })
23+
})
24+
25+
vi.stubGlobal("navigator", {
26+
...navigator,
27+
locks: {
28+
request: mockLockRequest,
29+
},
30+
})
31+
32+
global.ResizeObserver = require("resize-observer-polyfill")
33+
34+
describe("Launcher.vue", async () => {
35+
test(`Mount`, async () => {
36+
const spy_infra_store = vi.spyOn(infra_store, "create_backend")
37+
const wrapper = await mountSuspended(Launcher, {
38+
global: {
39+
plugins: [vuetify],
40+
},
41+
})
42+
expect(wrapper.exists()).toBe(true)
43+
await infra_store.$patch({ is_captcha_validated: true })
44+
flushPromises()
45+
expect(spy_infra_store).toHaveBeenCalled()
46+
})
3847
})

0 commit comments

Comments
 (0)