@geode/opengeodeweb-front 9.2.0 → 9.2.1-rc.2
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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<FetchingData v-if="loading" />
|
|
3
3
|
<FileUploader
|
|
4
4
|
v-else
|
|
5
|
-
v-bind="{ multiple, accept, files }"
|
|
5
|
+
v-bind="{ multiple, accept, files, auto_upload }"
|
|
6
6
|
@files_uploaded="files_uploaded_event"
|
|
7
7
|
/>
|
|
8
8
|
</template>
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
multiple: { type: Boolean, required: true },
|
|
22
22
|
supported_feature: { type: String, required: false, default: null },
|
|
23
23
|
files: { type: Array, required: false, default: [] },
|
|
24
|
+
auto_upload: { type: Boolean, required: false, default: true },
|
|
24
25
|
})
|
|
25
26
|
|
|
26
|
-
const { multiple, supported_feature } = props
|
|
27
|
-
|
|
27
|
+
const { auto_upload, multiple, supported_feature } = props
|
|
28
28
|
const accept = ref("")
|
|
29
29
|
const loading = ref(false)
|
|
30
30
|
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
function files_uploaded_event(value) {
|
|
34
34
|
if (value.length) {
|
|
35
|
-
emit("update_values", { files: value })
|
|
35
|
+
emit("update_values", { files: value, auto_upload: false })
|
|
36
36
|
emit("increment_step")
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
multiple: { type: Boolean, required: true },
|
|
41
41
|
accept: { type: String, required: true },
|
|
42
42
|
files: { type: Array, required: false, default: [] },
|
|
43
|
+
auto_upload: { type: Boolean, required: false, default: false },
|
|
43
44
|
})
|
|
44
45
|
|
|
45
46
|
const { multiple, accept } = toRefs(props)
|
|
@@ -83,7 +84,9 @@
|
|
|
83
84
|
|
|
84
85
|
if (props.files.length) {
|
|
85
86
|
files.value = props.files
|
|
86
|
-
|
|
87
|
+
if (props.auto_upload) {
|
|
88
|
+
upload_files()
|
|
89
|
+
}
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
function clear() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @vitest-environment nuxt
|
|
2
2
|
|
|
3
|
-
import { describe, expect, test } from "vitest"
|
|
3
|
+
import { describe, expect, test, vi } from "vitest"
|
|
4
4
|
import { registerEndpoint, mountSuspended } from "@nuxt/test-utils/runtime"
|
|
5
5
|
import { flushPromises } from "@vue/test-utils"
|
|
6
6
|
|
|
@@ -54,6 +54,7 @@ describe("FileSelector.vue", async () => {
|
|
|
54
54
|
const v_file_input = file_uploader.findComponent(components.VFileInput)
|
|
55
55
|
await v_file_input.trigger("click")
|
|
56
56
|
const files = [new File(["fake_file"], "fake_file.txt")]
|
|
57
|
+
const auto_upload = false
|
|
57
58
|
await v_file_input.setValue(files)
|
|
58
59
|
await v_file_input.trigger("change")
|
|
59
60
|
const v_btn = wrapper.findComponent(components.VBtn)
|
|
@@ -63,10 +64,11 @@ describe("FileSelector.vue", async () => {
|
|
|
63
64
|
expect(wrapper.emitted().update_values).toHaveLength(1)
|
|
64
65
|
expect(wrapper.emitted().update_values[0][0]).toEqual({
|
|
65
66
|
files,
|
|
67
|
+
auto_upload,
|
|
66
68
|
})
|
|
67
69
|
})
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
describe(`Files prop`, () => {
|
|
70
72
|
registerEndpoint(allowed_files_schema.$id, {
|
|
71
73
|
method: allowed_files_schema.methods[0],
|
|
72
74
|
handler: () => ({
|
|
@@ -74,25 +76,57 @@ describe("FileSelector.vue", async () => {
|
|
|
74
76
|
}),
|
|
75
77
|
})
|
|
76
78
|
|
|
77
|
-
const files = [new File(["fake_file"], "fake_file.txt")]
|
|
78
|
-
|
|
79
|
-
const wrapper = await mountSuspended(FileSelector, {
|
|
80
|
-
global: {
|
|
81
|
-
plugins: [vuetify, pinia],
|
|
82
|
-
},
|
|
83
|
-
props: { multiple: false, supported_feature: "test", files: files },
|
|
84
|
-
})
|
|
85
79
|
registerEndpoint(upload_file_schema.$id, {
|
|
86
80
|
method: upload_file_schema.methods[1],
|
|
87
81
|
handler: () => ({}),
|
|
88
82
|
})
|
|
89
83
|
|
|
90
|
-
|
|
84
|
+
const files = [new File(["fake_file"], "fake_file.txt")]
|
|
85
|
+
test("auto_upload true", async () => {
|
|
86
|
+
const auto_upload = true
|
|
87
|
+
const wrapper = await mountSuspended(FileSelector, {
|
|
88
|
+
global: {
|
|
89
|
+
plugins: [vuetify, pinia],
|
|
90
|
+
},
|
|
91
|
+
props: {
|
|
92
|
+
multiple: false,
|
|
93
|
+
supported_feature: "test",
|
|
94
|
+
files: files,
|
|
95
|
+
auto_upload,
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
await flushPromises()
|
|
100
|
+
expect(wrapper.componentVM.files).toEqual(files)
|
|
101
|
+
expect(wrapper.emitted()).toHaveProperty("update_values")
|
|
102
|
+
expect(wrapper.emitted().update_values).toHaveLength(1)
|
|
103
|
+
expect(wrapper.emitted().update_values[0][0]).toEqual({
|
|
104
|
+
files,
|
|
105
|
+
auto_upload: false,
|
|
106
|
+
})
|
|
107
|
+
})
|
|
91
108
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
109
|
+
test("auto_upload false", async () => {
|
|
110
|
+
const auto_upload = false
|
|
111
|
+
const wrapper = await mountSuspended(FileSelector, {
|
|
112
|
+
global: {
|
|
113
|
+
plugins: [vuetify, pinia],
|
|
114
|
+
},
|
|
115
|
+
props: {
|
|
116
|
+
multiple: false,
|
|
117
|
+
supported_feature: "test",
|
|
118
|
+
files: files,
|
|
119
|
+
auto_upload,
|
|
120
|
+
},
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
await flushPromises()
|
|
124
|
+
|
|
125
|
+
const file_uploader = wrapper.findComponent(FileUploader)
|
|
126
|
+
console.log("wrapper", wrapper)
|
|
127
|
+
expect(wrapper.vm.files).toEqual(files)
|
|
128
|
+
const upload_files = vi.spyOn(file_uploader.vm, "upload_files")
|
|
129
|
+
expect(upload_files).not.toHaveBeenCalled()
|
|
96
130
|
})
|
|
97
131
|
})
|
|
98
132
|
})
|
|
@@ -27,31 +27,47 @@ describe("FileUploader.vue", async () => {
|
|
|
27
27
|
const geode_store = use_geode_store()
|
|
28
28
|
geode_store.base_url = ""
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
30
|
+
registerEndpoint(upload_file_schema.$id, {
|
|
31
|
+
method: upload_file_schema.methods[0],
|
|
32
|
+
handler: () => ({}),
|
|
33
|
+
})
|
|
34
|
+
registerEndpoint(upload_file_schema.$id, {
|
|
35
|
+
method: upload_file_schema.methods[1],
|
|
36
|
+
handler: () => ({}),
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const files = [new File(["fake_file"], "fake_file.txt")]
|
|
40
|
+
|
|
41
|
+
describe(`Upload file`, async () => {
|
|
42
|
+
test(`prop auto_upload false`, async () => {
|
|
43
|
+
const wrapper = await mountSuspended(FileUploader, {
|
|
44
|
+
global: {
|
|
45
|
+
plugins: [vuetify, pinia],
|
|
46
|
+
},
|
|
47
|
+
props: { multiple: false, accept: "*.txt" },
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const v_file_input = wrapper.findComponent(components.VFileInput)
|
|
51
|
+
await v_file_input.trigger("click")
|
|
52
|
+
|
|
53
|
+
await v_file_input.setValue(files)
|
|
54
|
+
await v_file_input.trigger("change")
|
|
55
|
+
const v_btn = wrapper.findComponent(components.VBtn)
|
|
56
|
+
|
|
57
|
+
await v_btn.trigger("click")
|
|
58
|
+
await flushPromises()
|
|
59
|
+
expect(wrapper.emitted().files_uploaded[0][0]).toEqual(files)
|
|
51
60
|
})
|
|
52
61
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
test(`prop auto_upload true`, async () => {
|
|
63
|
+
const wrapper = await mountSuspended(FileUploader, {
|
|
64
|
+
global: {
|
|
65
|
+
plugins: [vuetify, pinia],
|
|
66
|
+
},
|
|
67
|
+
props: { multiple: false, accept: "*.txt", files, auto_upload: true },
|
|
68
|
+
})
|
|
69
|
+
await flushPromises()
|
|
70
|
+
expect(wrapper.emitted().files_uploaded[0][0]).toEqual(files)
|
|
71
|
+
})
|
|
56
72
|
})
|
|
57
73
|
})
|