diff --git a/frontend/src/test/unit/services/course_service.test.ts b/frontend/src/test/unit/services/course_service.test.ts index 78ca4fbd..6b6d4fb5 100644 --- a/frontend/src/test/unit/services/course_service.test.ts +++ b/frontend/src/test/unit/services/course_service.test.ts @@ -153,6 +153,7 @@ describe('course', (): void => { const exampleCourse = new Course( 'course_id', // id 'course_name', // name + 'course_excerpt', // excerpt 'course_description', // description 2024, // acedemic_startyear, null, // parent_course @@ -179,6 +180,7 @@ describe('course', (): void => { expect(courses.value?.[prevLength]?.id).toBe('course_id'); expect(courses.value?.[prevLength]?.name).toBe('course_name'); expect(courses.value?.[prevLength]?.description).toBe('course_description'); + expect(courses.value?.[prevLength]?.excerpt).toBe('course_excerpt'); expect(courses.value?.[prevLength]?.academic_startyear).toBe(2024); }); }); diff --git a/frontend/src/test/unit/services/project_service.test.ts b/frontend/src/test/unit/services/project_service.test.ts index 0c93ab34..5c33646f 100644 --- a/frontend/src/test/unit/services/project_service.test.ts +++ b/frontend/src/test/unit/services/project_service.test.ts @@ -3,7 +3,7 @@ import { describe, it, expect } from 'vitest'; import { useProject } from '@/composables/services/project.service.ts'; import { useCourses } from '@/composables/services/course.service'; import { Project } from '@/types/Project'; -import { type Course } from '@/types/Course'; +import { Course } from '@/types/Course'; const { projects, @@ -31,7 +31,7 @@ describe('project', (): void => { await getProjectByID('0'); expect(project.value).not.toBeNull(); expect(project.value?.name).toBe('sel2'); - expect(project.value?.course).toBeNull(); + expect(project.value?.course).toBeInstanceOf(Course); expect(project.value?.description).toBe('this is a test'); expect(project.value?.visible).toBe(true); expect(project.value?.archived).toBe(false); @@ -41,14 +41,13 @@ describe('project', (): void => { expect(project.value?.max_score).toBe(100); expect(project.value?.score_visible).toBe(true); expect(project.value?.group_size).toBe(8); - expect(project.value?.course).toBeNull(); expect(project.value?.structureChecks).toEqual([]); expect(project.value?.extra_checks).toEqual([]); expect(project.value?.groups).toEqual([]); expect(project.value?.submissions).toEqual([]); }); - it('gets projects data', async () => { + it('gets projects data by course', async () => { resetService(); await getProjectsByCourse('1'); @@ -57,7 +56,7 @@ describe('project', (): void => { expect(projects.value?.length).toBe(2); expect(projects.value).not.toBeNull(); expect(projects.value?.[0]?.name).toBe('sel2'); - expect(projects.value?.[0]?.course).toBeNull(); + expect(projects.value?.[0].course).toBeInstanceOf(Course); expect(projects.value?.[0]?.description).toBe('this is a test'); expect(projects.value?.[0]?.visible).toBe(true); expect(projects.value?.[0]?.archived).toBe(false); @@ -67,14 +66,13 @@ describe('project', (): void => { expect(projects.value?.[0]?.max_score).toBe(100); expect(projects.value?.[0]?.score_visible).toBe(true); expect(projects.value?.[0]?.group_size).toBe(8); - expect(projects.value?.[0]?.course).toBeNull(); expect(projects.value?.[0]?.structureChecks).toEqual([]); expect(projects.value?.[0]?.extra_checks).toEqual([]); expect(projects.value?.[0]?.groups).toEqual([]); expect(projects.value?.[0]?.submissions).toEqual([]); expect(projects.value?.[1]?.name).toBe('sel3'); - expect(projects.value?.[1]?.course).toBeNull(); + expect(projects.value?.[1].course).toBeInstanceOf(Course); expect(projects.value?.[1]?.description).toBe('make a project'); expect(projects.value?.[1]?.visible).toBe(true); expect(projects.value?.[1]?.archived).toBe(false); @@ -84,50 +82,6 @@ describe('project', (): void => { expect(projects.value?.[1]?.max_score).toBe(20); expect(projects.value?.[1]?.score_visible).toBe(false); expect(projects.value?.[1]?.group_size).toBe(3); - expect(projects.value?.[1]?.course).toBeNull(); - expect(projects.value?.[1]?.structureChecks).toEqual([]); - expect(projects.value?.[1]?.extra_checks).toEqual([]); - expect(projects.value?.[1]?.groups).toEqual([]); - expect(projects.value?.[1]?.submissions).toEqual([]); - }); - - it('gets projects data', async () => { - resetService(); - - await getProjectsByStudent('1'); - expect(projects).not.toBeNull(); - expect(Array.isArray(projects.value)).toBe(true); - expect(projects.value?.length).toBe(2); - expect(projects.value).not.toBeNull(); - expect(projects.value?.[0]?.name).toBe('sel2'); - expect(projects.value?.[0]?.course).toBeNull(); - expect(projects.value?.[0]?.description).toBe('this is a test'); - expect(projects.value?.[0]?.visible).toBe(true); - expect(projects.value?.[0]?.archived).toBe(false); - expect(projects.value?.[0]?.locked_groups).toBe(false); - expect(projects.value?.[0]?.start_date).toStrictEqual(new Date('July 21, 2024 01:15:00')); - expect(projects.value?.[0]?.deadline).toStrictEqual(new Date('July 23, 2024 01:15:00')); - expect(projects.value?.[0]?.max_score).toBe(100); - expect(projects.value?.[0]?.score_visible).toBe(true); - expect(projects.value?.[0]?.group_size).toBe(8); - expect(projects.value?.[0]?.course).toBeNull(); - expect(projects.value?.[0]?.structureChecks).toEqual([]); - expect(projects.value?.[0]?.extra_checks).toEqual([]); - expect(projects.value?.[0]?.groups).toEqual([]); - expect(projects.value?.[0]?.submissions).toEqual([]); - - expect(projects.value?.[1]?.name).toBe('sel3'); - expect(projects.value?.[1]?.course).toBeNull(); - expect(projects.value?.[1]?.description).toBe('make a project'); - expect(projects.value?.[1]?.visible).toBe(true); - expect(projects.value?.[1]?.archived).toBe(false); - expect(projects.value?.[1]?.locked_groups).toBe(false); - expect(projects.value?.[1]?.start_date).toStrictEqual(new Date('July 21, 2024 01:15:00')); - expect(projects.value?.[1]?.deadline).toStrictEqual(new Date('July 23, 2024 01:15:00')); - expect(projects.value?.[1]?.max_score).toBe(20); - expect(projects.value?.[1]?.score_visible).toBe(false); - expect(projects.value?.[1]?.group_size).toBe(3); - expect(projects.value?.[1]?.course).toBeNull(); expect(projects.value?.[1]?.structureChecks).toEqual([]); expect(projects.value?.[1]?.extra_checks).toEqual([]); expect(projects.value?.[1]?.groups).toEqual([]); diff --git a/frontend/src/test/unit/services/setup/data.ts b/frontend/src/test/unit/services/setup/data.ts index 5f1ef104..e25dd5e4 100644 --- a/frontend/src/test/unit/services/setup/data.ts +++ b/frontend/src/test/unit/services/setup/data.ts @@ -28,7 +28,7 @@ export const projects = [ score_visible: true, group_size: 8, submissions: ['1', '2'], - groups: ['0', '1'],z + groups: ['0', '1'], }, { id: 1, @@ -51,6 +51,7 @@ export const projects = [ export const courses = [ { id: '1', + excerpt: 'excerpt1', teachers: ['123', '124'], assistants: ['235', '236'], students: ['1', '2', '3', '000201247011'], @@ -63,6 +64,7 @@ export const courses = [ }, { id: '2', + excerpt: 'excerpt2', teachers: [], assistants: [], students: [], @@ -75,6 +77,7 @@ export const courses = [ }, { id: '3', + excerpt: 'excerpt3', teachers: [], assistants: [], students: [], @@ -87,6 +90,7 @@ export const courses = [ }, { id: '12', + excerpt: 'excerpt12', teachers: [], assistants: [], students: [], @@ -99,6 +103,7 @@ export const courses = [ }, { id: '13', + excerpt: 'excerpt13', teachers: [], assistants: [], students: [], @@ -111,6 +116,7 @@ export const courses = [ }, { id: '14', + excerpt: 'excerpt14', teachers: [], assistants: [], students: [], @@ -123,6 +129,7 @@ export const courses = [ }, { id: '15', + excerpt: 'excerpt15', teachers: [], assistants: [], students: [], diff --git a/frontend/src/test/unit/services/setup/get_handlers.ts b/frontend/src/test/unit/services/setup/get_handlers.ts index 6db68be1..52de20eb 100644 --- a/frontend/src/test/unit/services/setup/get_handlers.ts +++ b/frontend/src/test/unit/services/setup/get_handlers.ts @@ -13,6 +13,7 @@ import { structureChecks, submissions, } from './data'; +import { json } from 'stream/consumers'; const baseUrl = 'http://localhost'; diff --git a/frontend/src/test/unit/types/course.test.ts b/frontend/src/test/unit/types/course.test.ts index ffeaa019..122a06db 100644 --- a/frontend/src/test/unit/types/course.test.ts +++ b/frontend/src/test/unit/types/course.test.ts @@ -29,6 +29,7 @@ describe('course type', () => { expect(course).toBeInstanceOf(Course); expect(course.id).toBe(courseData.id); expect(course.name).toBe(courseData.name); + expect(course.excerpt).toBe(courseData.excerpt); expect(course.description).toBe(courseData.description); expect(course.academic_startyear).toBe(courseData.academic_startyear); expect(course.parent_course).toBe(courseData.parent_course); diff --git a/frontend/src/test/unit/types/helper.ts b/frontend/src/test/unit/types/helper.ts index de2fc30d..81e7e171 100644 --- a/frontend/src/test/unit/types/helper.ts +++ b/frontend/src/test/unit/types/helper.ts @@ -85,6 +85,7 @@ export function createCourse(courseData: any): Course { return new Course( courseData.id, courseData.name, + courseData.excerpt, courseData.description, courseData.academic_startyear, courseData.parent_course,