Skip to content
Snippets Groups Projects
Commit 69c2e545 authored by Hanna Führ's avatar Hanna Führ Committed by Benedikt Heinrichs
Browse files

Update: Setting up ToS tests

parent 4518cd4c
No related branches found
No related tags found
4 merge requests!192Release: Sprint/2023 03 :robot:,!187Dev,!184Update: Setting up ToS tests,!181Dev
/* Testing imports */
import { createLocalVue, mount } from "@vue/test-utils";
import { createTestingPinia } from "@pinia/testing";
/* Vue i18n */
import i18n, { def } from "@/plugins/vue-i18n";
import { LoginI18nMessages } from "@/modules/login/i18n/index";
i18n.availableLocales.forEach((locale) => {
i18n.setLocaleMessage(locale, def[locale]); // default locale messages
i18n.mergeLocaleMessage(locale, LoginI18nMessages[locale]); // append the locale messages for the component
});
/* Pinia */
import { PiniaVuePlugin } from "pinia";
/* Tested Component */
import ToS from "./ToS.vue";
import type Vue from "vue";
/* Create a local Vue instance */
const localVue = createLocalVue();
localVue.use(PiniaVuePlugin);
describe("ToS.vue", () => {
/* Testing ToS and PP accepted*/
test("ToSAndPPAccepted", async () => {
/* Mount the Component */
const wrapper = mount(ToS as unknown as typeof Vue, {
pinia: createTestingPinia({
createSpy: vitest.fn,
}),
i18n,
localVue,
});
// wait for created in ToS.vue
await wrapper.vm.$nextTick();
// initial state, Confirm Button is disabled
expect(wrapper.get("#confirmBtn").attributes()["disabled"]).toBe("disabled");
// check TosAccepted and PpAccepted
const toSFound = wrapper.find("#TosAccepted");
await toSFound.setChecked(true);
const pPFound = wrapper.find("#PpAccepted");
await pPFound.setChecked(true);
// Confirm button should be active
expect(wrapper.get("#confirmBtn").attributes()["disabled"]).not.toBe("disabled")
});
/* Testing only ToS accepted*/
test("ToSAccepted", async () => {
/* Mount the Component */
const wrapper = mount(ToS as unknown as typeof Vue, {
pinia: createTestingPinia({
createSpy: vitest.fn,
}),
i18n,
localVue,
});
// wait for created in ToS.vue
await wrapper.vm.$nextTick();
// initial state, Confirm Button is disabled
expect(wrapper.get("#confirmBtn").attributes()["disabled"]).toBe("disabled");
// check TosAccepted
const toSFound = wrapper.find("#TosAccepted");
await toSFound.setChecked(true);
// Confirm button should be disabled, since PP not accepted
expect(wrapper.get("#confirmBtn").attributes()["disabled"]).toBe("disabled")
});
/* Testing only Pp accepted*/
test("PpAccepted", async () => {
/* Mount the Component */
const wrapper = mount(ToS as unknown as typeof Vue, {
pinia: createTestingPinia({
createSpy: vitest.fn,
}),
i18n,
localVue,
});
// wait for created in ToS.vue
await wrapper.vm.$nextTick();
// initial state, Confirm Button is disabled
expect(wrapper.get("#confirmBtn").attributes()["disabled"]).toBe("disabled");
// check PpAccepted
const pPFound = wrapper.find("#PpAccepted");
await pPFound.setChecked(true);
// Confirm button should be disabled, since PP not accepted
expect(wrapper.get("#confirmBtn").attributes()["disabled"]).toBe("disabled")
});
});
......@@ -10,7 +10,11 @@
</a>
</template>
</i18n>
<b-form-checkbox v-model="isTosChecked" :disabled="areTosAccepted">
<b-form-checkbox
id="TosAccepted"
v-model="isTosChecked"
:disabled="areTosAccepted"
>
{{ $t("page.tos.checkbox.tos") }}
</b-form-checkbox>
</b-card-body>
......@@ -24,13 +28,18 @@
</a>
</template>
</i18n>
<b-form-checkbox v-model="isPpChecked" :disabled="areTosAccepted">
<b-form-checkbox
id="PpAccepted"
v-model="isPpChecked"
:disabled="areTosAccepted"
>
{{ $t("page.tos.checkbox.pp") }}
</b-form-checkbox>
</b-card-body>
<div class="v_gapped_container">
<b-button
id="confirmBtn"
variant="primary"
:disabled="!isTosChecked || !isPpChecked || areTosAccepted"
@click="accept"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment