Skip to content

Commit 5814194

Browse files
luizhf42gustavosbarreto
authored andcommitted
refactor(ui): use BaseDialog @close event in Device components
1 parent c286609 commit 5814194

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

ui/src/components/Devices/DeviceAcceptWarning.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<BaseDialog
33
v-if="hasAuthorization"
44
v-model="showDialog"
5+
@close="close"
56
transition="dialog-bottom-transition"
67
data-test="device-accept-warning-dialog"
78
>
@@ -20,7 +21,7 @@
2021
<v-card-actions>
2122
<v-spacer />
2223

23-
<v-btn variant="text" data-test="close-btn" @click="close()"> Close </v-btn>
24+
<v-btn variant="text" data-test="close-btn" @click="close"> Close </v-btn>
2425
</v-card-actions>
2526
</v-card>
2627
</BaseDialog>

ui/src/components/Devices/DeviceActionButton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<span data-test="tooltip-text"> You don't have this kind of authorization. </span>
2525
</v-tooltip>
2626
</v-list-item>
27-
<BaseDialog v-model="showDialog" @click:outside="close" data-test="device-action-dialog">
27+
<BaseDialog v-model="showDialog" @close="close" data-test="device-action-dialog">
2828
<v-card class="bg-v-theme-surface">
2929
<v-card-title class="text-h5 pa-5 bg-primary">
3030
{{ capitalizeText(variant) }} {{ capitalizeText(action) }}

ui/src/components/Devices/DeviceChooser.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<BaseDialog
33
v-if="hasAuthorization"
44
v-model="showDialog"
5+
@close="close"
56
data-test="device-chooser-dialog"
67
>
78
<v-card

ui/src/components/Devices/DeviceRename.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</div>
1010
</v-list-item>
1111

12-
<BaseDialog v-model="showDialog" data-test="device-rename-dialog" @click:outside="close">
12+
<BaseDialog v-model="showDialog" data-test="device-rename-dialog" @close="close">
1313
<v-card class="bg-v-theme-surface" data-test="device-rename-card">
1414
<v-card-title class="text-h5 pa-5 bg-primary" data-test="text-title">
1515
Rename Device

ui/tests/components/Devices/DeviceActionButton.spec.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { setActivePinia, createPinia } from "pinia";
22
import { DOMWrapper, mount, VueWrapper } from "@vue/test-utils";
33
import { createVuetify } from "vuetify";
44
import MockAdapter from "axios-mock-adapter";
5-
import { expect, describe, it, beforeEach, vi } from "vitest";
5+
import { expect, describe, it, beforeEach } from "vitest";
66
import DeviceActionButton from "@/components/Devices/DeviceActionButton.vue";
77
import { router } from "@/router";
88
import { devicesApi } from "@/api/http";
@@ -95,14 +95,10 @@ describe("Device Action Button", () => {
9595
expect(wrapper.vm.showDialog).toBe(true);
9696
});
9797

98-
it("Closing dialog sets dialog value to false", async () => {
99-
vi.spyOn(console, "warn").mockImplementation((message) => {
100-
if (message.includes("click:outside")) return;
101-
console.log(message);
102-
});
98+
it("Closing dialog sets showDialog value to false", async () => {
10399
wrapper.vm.showDialog = true;
104-
const dialogComponent = wrapper.findComponent({ name: "VDialog" });
105-
await dialogComponent.vm.$emit("click:outside");
100+
const dialogComponent = wrapper.findComponent({ name: "BaseDialog" });
101+
await dialogComponent.vm.$emit("close");
106102
expect(wrapper.vm.showDialog).toBe(false);
107103
});
108104

0 commit comments

Comments
 (0)