Skip to content

Commit f48aee0

Browse files
luannmoreiragustavosbarreto
authored andcommitted
test(ui): add firewall section related unitary tests
This commit adds unitary tests related to the firewall section, testing integration with the API and the component rendering and validation.
1 parent 2a7f246 commit f48aee0

13 files changed

+1570
-831
lines changed

ui/src/components/firewall/FirewallRuleAdd.vue

Lines changed: 270 additions & 289 deletions
Large diffs are not rendered by default.

ui/src/components/firewall/FirewallRuleDelete.vue

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@click="showDialog = true"
44
v-bind="$attrs"
55
:disabled="notHasAuthorization"
6+
data-test="firewall-delete-dialog-btn"
67
>
78
<div class="d-flex align-center">
89
<div class="mr-2">
@@ -50,55 +51,46 @@
5051
</v-dialog>
5152
</template>
5253

53-
<script lang="ts">
54-
import { defineComponent, ref } from "vue";
54+
<script setup lang="ts">
55+
import { ref } from "vue";
5556
import {
5657
INotificationsError,
5758
INotificationsSuccess,
5859
} from "../../interfaces/INotifications";
5960
import { useStore } from "../../store";
6061
import handleError from "@/utils/handleError";
6162
62-
export default defineComponent({
63-
props: {
64-
id: {
65-
type: String,
66-
required: true,
67-
},
68-
notHasAuthorization: {
69-
type: Boolean,
70-
default: false,
71-
},
63+
const props = defineProps({
64+
id: {
65+
type: String,
66+
required: true,
7267
},
73-
emits: ["update"],
74-
setup(props, ctx) {
75-
const showDialog = ref(false);
76-
const store = useStore();
77-
78-
const remove = async () => {
79-
try {
80-
await store.dispatch("firewallRules/remove", props.id);
81-
82-
store.dispatch(
83-
"snackbar/showSnackbarSuccessAction",
84-
INotificationsSuccess.firewallRuleDeleting,
85-
);
86-
ctx.emit("update");
87-
} catch (error: unknown) {
88-
store.dispatch(
89-
"snackbar/showSnackbarErrorAction",
90-
INotificationsError.firewallRuleDeleting,
91-
);
92-
handleError(error);
93-
} finally {
94-
showDialog.value = false;
95-
}
96-
};
97-
98-
return {
99-
showDialog,
100-
remove,
101-
};
68+
notHasAuthorization: {
69+
type: Boolean,
70+
default: false,
10271
},
10372
});
73+
const emit = defineEmits(["update"]);
74+
const showDialog = ref(false);
75+
const store = useStore();
76+
77+
const remove = async () => {
78+
try {
79+
await store.dispatch("firewallRules/remove", props.id);
80+
81+
store.dispatch(
82+
"snackbar/showSnackbarSuccessAction",
83+
INotificationsSuccess.firewallRuleDeleting,
84+
);
85+
emit("update");
86+
} catch (error: unknown) {
87+
store.dispatch(
88+
"snackbar/showSnackbarErrorAction",
89+
INotificationsError.firewallRuleDeleting,
90+
);
91+
handleError(error);
92+
} finally {
93+
showDialog.value = false;
94+
}
95+
};
10496
</script>

0 commit comments

Comments
 (0)