Skip to content

Commit 535b3e9

Browse files
fix tests
1 parent b8238bb commit 535b3e9

File tree

7 files changed

+98
-21
lines changed

7 files changed

+98
-21
lines changed

components/Inspector/InspectionButton.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"decrement_step",
2525
])
2626
const props = defineProps({
27-
input_geode_object: { type: String, required: false },
28-
filename: { type: String, required: false },
27+
input_geode_object: { type: String, required: true },
28+
filename: { type: String, required: true },
2929
})
3030
const loading = ref(false)
3131
const toggle_loading = useToggle(loading)

components/Inspector/ResultPanel.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
v-if="result.children"
2525
:inspection_result="result.children"
2626
/>
27-
<v-container v-if="result.nb_issues > 0">
27+
<v-container v-if="result.issues">
2828
<v-col>
2929
<v-row
3030
v-for="(issue, index) in result.issues"
@@ -50,6 +50,6 @@
5050
onMounted(async () => {
5151
opened_panels.value = props.inspection_result
5252
.map((result, i) => (result.nb_issues > 0 ? i : -1))
53-
.filter((index) => index !== false)
53+
.filter((index) => index !== -1)
5454
})
5555
</script>

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"geode_objects": "node scripts/generate_geode_objects.js && prettier ./assets/geode_objects.js --write"
88
},
99
"devDependencies": {
10-
"@nuxt/test-utils": "^3.12.1",
10+
"@nuxt/test-utils": "^3.12.0",
1111
"@vitejs/plugin-vue": "^5.0.4",
1212
"@vitest/coverage-v8": "^1.4.0",
1313
"@vue/test-utils": "^2.4.5",
@@ -40,19 +40,19 @@
4040
"dependencies": {
4141
"@geode/opengeodeweb-back": "4.1.0",
4242
"@geode/opengeodeweb-viewer": "0.1.1",
43-
"@kitware/vtk.js": "^30.4.1",
43+
"@kitware/vtk.js": "^30.3.1",
4444
"@mdi/font": "^7.4.47",
4545
"@pinia/nuxt": "^0.5.1",
46-
"@types/node": "^20.12.7",
46+
"@types/node": "^20.12.4",
4747
"@vueuse/components": "^10.9.0",
4848
"@vueuse/nuxt": "^10.9.0",
49-
"ajv": "^8.13.0",
49+
"ajv": "^8.12.0",
5050
"pinia": "^2.1.7",
51-
"sass": "^1.75.0",
51+
"sass": "^1.74.1",
5252
"semver": "^7.6.0",
5353
"vue-recaptcha": "^2.0.3",
5454
"vue3-carousel": "^0.3.3",
55-
"vuetify": "^3.5.17"
55+
"vuetify": "^3.5.14"
5656
},
5757
"repository": {
5858
"type": "git",

test/components/ErrorsSnackers.nuxt.test.js renamed to test/components/Errors/ErrorsSnackers.nuxt.test.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @vitest-environment nuxt
22

33
import { describe, expect, test } from "vitest"
4-
import { flushPromises, mount } from "@vue/test-utils"
4+
import { mount } from "@vue/test-utils"
55
import { createVuetify } from "vuetify"
66
import * as components from "vuetify/components"
77
import * as directives from "vuetify/directives"
@@ -11,16 +11,30 @@ import ErrorsSnackers from "@/components/Errors/Snackers.vue"
1111
const vuetify = createVuetify({
1212
components,
1313
directives,
14+
layout: {
15+
name: "custom",
16+
render(h, children) {
17+
return h("div", {}, children)
18+
},
19+
},
1420
})
1521

1622
describe("ErrorsSnackers.vue", async () => {
1723
test(`Test delete error`, async () => {
18-
const wrapper = await mount(ErrorsSnackers, {
19-
global: {
20-
plugins: [vuetify],
24+
const wrapper = mount(
25+
{
26+
template: "<v-layout><ErrorsSnackers/></v-layout>",
2127
},
22-
})
23-
console.log("wrapper", wrapper.componentVM)
28+
{
29+
props: {},
30+
global: {
31+
components: {
32+
ErrorsSnackers,
33+
},
34+
plugins: [vuetify],
35+
},
36+
},
37+
)
2438

2539
const errors_store = use_errors_store()
2640
const error = {
@@ -30,12 +44,8 @@ describe("ErrorsSnackers.vue", async () => {
3044
description: "Test desription",
3145
}
3246
await errors_store.add_error(error)
33-
await flushPromises()
3447
expect(errors_store.errors.length).toBe(1)
35-
console.log("errors_store.errors", errors_store.errors)
3648
const v_btn = await wrapper.findComponent(components.VBtn)
37-
console.log("v_btn", v_btn)
38-
3949
await v_btn.trigger("click")
4050
expect(errors_store.errors.length).toBe(0)
4151
})
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// @vitest-environment nuxt
2+
3+
import { describe, expect, test } from "vitest"
4+
import { registerEndpoint, mountSuspended } from "@nuxt/test-utils/runtime"
5+
import { mount } from "@vue/test-utils"
6+
import { flushPromises } from "@vue/test-utils"
7+
8+
import { createVuetify } from "vuetify"
9+
import * as components from "vuetify/components"
10+
import * as directives from "vuetify/directives"
11+
12+
import InspectorInspectionButton from "@/components/Inspector/InspectionButton.vue"
13+
import schemas from "@geode/opengeodeweb-back/schemas.json"
14+
const schema = schemas.opengeodeweb_back.inspect_file
15+
16+
const vuetify = createVuetify({
17+
components,
18+
directives,
19+
})
20+
21+
describe("Inspector/InspectionButton.vue", async () => {
22+
test(`Test with issues`, async () => {
23+
var inspection_result = {
24+
title: "Brep inspection",
25+
nb_issues: 3,
26+
children: [
27+
{
28+
title: "Brep inspection",
29+
nb_issues: 2,
30+
issues: ["issue 1", "issue 2"],
31+
},
32+
{
33+
title: "Brep inspection",
34+
nb_issues: 1,
35+
issues: ["issue 1"],
36+
},
37+
],
38+
}
39+
40+
registerEndpoint(schema.$id, {
41+
method: schema.methods[0],
42+
handler: () => ({
43+
inspection_result,
44+
}),
45+
})
46+
const input_geode_object = "BRep"
47+
const filename = "test.txt"
48+
49+
const wrapper = await mountSuspended(InspectorInspectionButton, {
50+
global: {
51+
plugins: [vuetify],
52+
},
53+
props: { input_geode_object, filename },
54+
})
55+
56+
expect(wrapper.exists()).toBe(true)
57+
const v_btn = await wrapper.findComponent(components.VBtn)
58+
await v_btn.trigger("click")
59+
await flushPromises()
60+
61+
expect(wrapper.emitted()).toHaveProperty("update_values")
62+
expect(wrapper.emitted().update_values).toHaveLength(1)
63+
expect(wrapper.emitted().update_values[0][0]).toStrictEqual({
64+
inspection_result: [inspection_result],
65+
})
66+
expect(wrapper.emitted()).toHaveProperty("increment_step")
67+
})
68+
})

test/components/Inspector/ResultPanel.nuxt.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ describe("Inspector/ResultPanel.vue", async () => {
5050
{
5151
title: "Brep inspection",
5252
nb_issues: 0,
53-
children: [],
5453
},
5554
]
5655
const wrapper = await mountSuspended(InspectorResultPanel, {

0 commit comments

Comments
 (0)