diff --git a/frontend/src/assets/404_black.png b/frontend/src/assets/404_black.png new file mode 100644 index 00000000..e2b3e801 Binary files /dev/null and b/frontend/src/assets/404_black.png differ diff --git a/frontend/src/assets/404_white.png b/frontend/src/assets/404_white.png new file mode 100644 index 00000000..34249b41 Binary files /dev/null and b/frontend/src/assets/404_white.png differ diff --git a/frontend/src/i18n/locales/en.ts b/frontend/src/i18n/locales/en.ts index 5f96584b..573b7c43 100644 --- a/frontend/src/i18n/locales/en.ts +++ b/frontend/src/i18n/locales/en.ts @@ -91,6 +91,9 @@ export default { }, subject: { register: "Register to subject:", + yes: "Yes", + no: "No", + registered: "You are already registered to this course", academy_year: "Academic year", projects: "Projects", announcements: "Announcements", diff --git a/frontend/src/i18n/locales/nl.ts b/frontend/src/i18n/locales/nl.ts index 1fbb25a7..ad3759b0 100644 --- a/frontend/src/i18n/locales/nl.ts +++ b/frontend/src/i18n/locales/nl.ts @@ -90,7 +90,10 @@ export default { }, }, subject: { - register: "Registreer bij vak:", + register: "Inschrijven voor vak:", + yes: "Ja", + no: "Nee", + registered: "Je bent al ingeschreven voor dit vak", academy_year: "Academiejaar", projects: "Projecten", announcements: "Meldingen", diff --git a/frontend/src/views/NotFoundView.vue b/frontend/src/views/NotFoundView.vue index d1b6331f..b5b5ce68 100644 --- a/frontend/src/views/NotFoundView.vue +++ b/frontend/src/views/NotFoundView.vue @@ -1,9 +1,43 @@ - + + + diff --git a/frontend/src/views/SubjectRegisterView.vue b/frontend/src/views/SubjectRegisterView.vue index c7bb6e99..aaa402b9 100644 --- a/frontend/src/views/SubjectRegisterView.vue +++ b/frontend/src/views/SubjectRegisterView.vue @@ -1,22 +1,32 @@ diff --git a/frontend/tests/views/NotFoundView.spec.ts b/frontend/tests/views/NotFoundView.spec.ts new file mode 100644 index 00000000..8bd51eef --- /dev/null +++ b/frontend/tests/views/NotFoundView.spec.ts @@ -0,0 +1,15 @@ +import { mount } from "@vue/test-utils"; +import {expect, describe, it} from "vitest"; +import NotFoundView from "../../src/views/NotFoundView.vue" +import blackThemeImg from '@/assets/404_black.png'; + +describe("NotFoundView", () => { + const wrapper = mount(NotFoundView, {}) + it("render 404 view", () => { + expect(wrapper.text()).toContain("Pagina niet gevonden") + const image = (wrapper.vm as any).imageSrc + expect(image).toBe(blackThemeImg) + const theme = (wrapper.vm as any).theme + expect(theme).toBe("black") + }); +}); diff --git a/frontend/tests/views/SubjectRegisterView.spec.ts b/frontend/tests/views/SubjectRegisterView.spec.ts new file mode 100644 index 00000000..26f54358 --- /dev/null +++ b/frontend/tests/views/SubjectRegisterView.spec.ts @@ -0,0 +1,63 @@ +import { mount } from "@vue/test-utils"; +import {expect, describe, it, vi} from "vitest"; +import SubjectRegisterView from "../../src/views/SubjectRegisterView.vue" +import {ref} from "vue"; + +const mockRouter = { + push: vi.fn(), +}; + +vi.mock("vue-router", () => ({ + useRouter: () => mockRouter, +})); + +const testSubjectsUuidQuery = { + isLoading: ref(false), + isError: ref(true), + setError(value){ + this.isError.value = value + }, + error: ref({message: "test error message"}), + data: ref({name: "testsubject", id: 1}), + setData(id){ + this.data.value.id = id + } +} + +const testSubjectsQuery = { + data: ref({as_student: [ + {id: 2} + ]}) +} + +vi.mock("@/queries/Subject", () => ({ + useRegisterToSubjectMutation: vi.fn(() => vi.fn()), + useSubjectUuidQuery: vi.fn(() => testSubjectsUuidQuery), + useSubjectsQuery: vi.fn(() => testSubjectsQuery), +})) + +describe("SubjectRegisterView", () => { + const wrapper = mount(SubjectRegisterView, { + props :{ + uuid: "testuuid" + } + }) + + it("render error message", () => { + expect(wrapper.text()).toContain("test error message") + }); + it("render register view", async () => { + testSubjectsUuidQuery.setError(false) + await wrapper.vm.$nextTick() + const registered = (wrapper.vm as any).registered + expect(registered).toBe(false) + expect(wrapper.text()).toContain("Inschrijven voor vak: testsubject") + }); + it("render if already registered", async () => { + testSubjectsUuidQuery.setData(2) + await wrapper.vm.$nextTick() + const registered = (wrapper.vm as any).registered + expect(registered).toBe(true) + expect(wrapper.text()).toContain("Je bent al ingeschreven voor dit vak.") + }) +});