Skip to content

Commit

Permalink
SubmissionsTeacherView.spec.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
masinnae committed May 20, 2024
1 parent b8eb99c commit aa418bf
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
20 changes: 12 additions & 8 deletions frontend/src/views/SubmissionsTeacherView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<v-col class="col-sm-12 col-md-6 col-lg-8">
<v-skeleton-loader :loading="projectLoading || submissionsLoading" type="card" class="card">
<v-card-title class="title">{{ $t("submission.submissions_title", { project: project.name }) }}</v-card-title>
<v-card-subtitle v-if="submissions.length == 0" icon="$warning" color="warning">
{{ $t("submission.no_submissions") }}</v-card-subtitle
>
<v-card-subtitle v-else icon="$info">{{ $t("submission.teacher_submissions_info") }}</v-card-subtitle>
<v-btn class="primary-button" @click="downloadAll" prepend-icon="mdi-download">
{{ $t("project.submissions_zip") }}
</v-btn>
<v-card-subtitle v-if="submissions.length == 0" class="subtitle">{{ $t("submission.no_submissions") }}</v-card-subtitle>
<div v-else>
<v-card-subtitle class="subtitle">{{ $t("submission.teacher_submissions_info") }}</v-card-subtitle>
<v-btn class="primary-button" @click="downloadAll" prepend-icon="mdi-download">
{{ $t("project.submissions_zip") }}
</v-btn>
</div>
<SubmissionTeacherCard
class="ma-3"
v-for="submission in submissions"
Expand Down Expand Up @@ -72,11 +72,15 @@ const downloadAll = () => {
padding: 15px;
}
.title{
.title, .subtitle{
width: 100%;
}
.backbutton{
margin-top: 30px;
}
.primary-button {
margin: 15px;
}
</style>
20 changes: 20 additions & 0 deletions frontend/tests/components/project/ProjectInfo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
import {mount} from "@vue/test-utils";
import {expect, describe, it, vi} from "vitest";
import ProjectInfo from "@/components/project/ProjectInfo.vue"
import {ref} from "vue";

const mockRouter = {
push: vi.fn(),
};

vi.mock("vue-router", () => ({
useRouter: () => mockRouter,
}));

const testAuthStore = {
isLoggedIn: ref(true),
setLoggedIn(value) {
this.isLoggedIn.value = value;
},
};

vi.mock("@/stores/auth-store", () => ({
useAuthStore: vi.fn(() => testAuthStore),
}));

const mockProject = {
name: "projectname",
Expand Down
8 changes: 7 additions & 1 deletion frontend/tests/views/SubmissionsTeacherView.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ vi.mock("@/queries/Submission", () => ({
}))

const testProjectQuery = {
data: ref({id: 1, name: "testproject"}),
data: ref({id: 1, name: "testproject", deadline: new Date(2025, 5, 31)}),
isLoading: ref(false)
}

Expand All @@ -48,7 +48,13 @@ describe("SubmissionsTeacherView", () => {
const text = wrapper.text()
expect(text).toContain("Indieningen voor project testproject")
expect(text).toContain("Deze pagina bevat een lijst van de laatste indiening van elke groep voor dit project.")
expect(text).toContain("Download alle indieningen")
expect(wrapper.findComponent({name: "SubmissionTeacherCard"}).exists()).toBeTruthy()
expect(wrapper.findComponent({name: "BackButton"}).exists()).toBeTruthy()
testProjectSubmissionsQuery.setData([])
await wrapper.vm.$nextTick()
});
it("render if no submissions", () => {
expect(wrapper.text()).toContain("Nog geen indieningen")
});
})

0 comments on commit aa418bf

Please sign in to comment.