-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: create course * fix: send id to backend when creating faculty * test: create faculty * test: create group * test: cleanup create tests * test: assistant type * test: services and types folder * test: start with create project * test: cleanup setup file * test: cleanup request handlers * test: reset services + fix mistakes in teacher/assistant service * chore: fix linting * test: create project * chore: linting autofix * chore: bring back multipart/from-data * Better academic year selector, filtering and sorting (#292) * feat: academic year selector, better pagination and filtering composables * chore: added course pagination * Run submission checks (#268) * chore: celery #206 * chore: Support partial update for project * chore: support patch for project 2 * refactor!: rework checks and submissions * chore: allow models passed to tasks * feat: added -k to test.sh * fix: re-add translations * chore: display faculty in course edit * fix: courses to create projects filtered on selected calendar date * fix: make teacher command * fix: linting * test: admin delete * test: fix service mistake, assistant delete --------- Co-authored-by: Ewout Verlinde <[email protected]> Co-authored-by: Vincent Vallaeys <[email protected]> Co-authored-by: Bram Meir <[email protected]>
- Loading branch information
Showing
29 changed files
with
1,196 additions
and
648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ export function useAdmin(): AdminState { | |
return { | ||
admins, | ||
admin, | ||
|
||
getAdminByID, | ||
getAdmins, | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,23 @@ import { User } from '@/types/users/User.ts'; | |
const { | ||
admins, | ||
admin, | ||
|
||
getAdminByID, | ||
getAdmins, | ||
|
||
createAdmin, | ||
deleteAdmin, | ||
} = useAdmin(); | ||
|
||
function resetService(): void { | ||
admin.value = null; | ||
admins.value = null; | ||
} | ||
|
||
describe('admin', (): void => { | ||
it('gets assistant data by id', async () => { | ||
resetService(); | ||
|
||
await getAdminByID('300201547011'); | ||
expect(admin.value).not.toBeNull(); | ||
expect(admin.value?.username).toBe('tverslyp'); | ||
|
@@ -28,6 +37,8 @@ describe('admin', (): void => { | |
}); | ||
|
||
it('gets admins data', async () => { | ||
resetService(); | ||
|
||
await getAdmins(); | ||
expect(admins).not.toBeNull(); | ||
expect(Array.isArray(admins.value)).toBe(true); | ||
|
@@ -55,22 +66,24 @@ describe('admin', (): void => { | |
}); | ||
|
||
it('create admin', async () => { | ||
resetService(); | ||
|
||
const exampleAdmin = new User( | ||
'101', // id | ||
'sample_admin', // username | ||
'', // id | ||
'', // username | ||
'[email protected]', // email | ||
'Sample', // first_name | ||
'Admin', // last_name | ||
2024, // last_enrolled | ||
'admin_first_name', // first_name | ||
'admin_last_name', // last_name | ||
-1, // last_enrolled | ||
true, // is_staff | ||
['user'], // roles | ||
[], // roles | ||
[], // faculties | ||
new Date('April 2, 2023 01:15:00'), // create_time | ||
new Date('April 2, 2024 01:15:00'), // last_login | ||
new Date(), // create_time | ||
null, // last_login | ||
); | ||
|
||
await getAdmins(); | ||
expect(admins).not.toBeNull(); | ||
expect(admins.value).not.toBeNull(); | ||
expect(Array.isArray(admins.value)).toBe(true); | ||
const prevLength = admins.value?.length ?? 0; | ||
|
||
|
@@ -81,9 +94,31 @@ describe('admin', (): void => { | |
expect(Array.isArray(admins.value)).toBe(true); | ||
expect(admins.value?.length).toBe(prevLength + 1); | ||
|
||
expect(admins.value?.[prevLength]?.first_name).toBe('Sample'); | ||
expect(admins.value?.[prevLength]?.last_name).toBe('Admin'); | ||
// Only check for fields that are sent to the backend | ||
expect(admins.value?.[prevLength]?.first_name).toBe('admin_first_name'); | ||
expect(admins.value?.[prevLength]?.last_name).toBe('admin_last_name'); | ||
expect(admins.value?.[prevLength]?.email).toBe('[email protected]'); | ||
expect(admins.value?.[prevLength]?.is_staff).toBe(true); | ||
}); | ||
|
||
it('delete admin', async () => { | ||
resetService(); | ||
|
||
await getAdmins(); | ||
expect(admins.value).not.toBeNull(); | ||
expect(Array.isArray(admins.value)).toBe(true); | ||
const prevLength = admins.value?.length ?? 0; | ||
|
||
let adminId = '0'; | ||
if (admins.value?.[0]?.id !== undefined && admins.value?.[0].id !== null) { | ||
adminId = admins.value?.[0]?.id; | ||
} | ||
|
||
await deleteAdmin(adminId); | ||
await getAdmins(); | ||
|
||
expect(admins).not.toBeNull(); | ||
expect(Array.isArray(admins.value)).toBe(true); | ||
expect(admins.value?.length).toBe(prevLength - 1); | ||
expect(admins.value?.[0]?.id).not.toBe(adminId); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,21 @@ const { | |
getAssistants, | ||
|
||
createAssistant, | ||
deleteAssistant, | ||
|
||
assistantJoinCourse, | ||
assistantLeaveCourse, | ||
} = useAssistant(); | ||
|
||
function resetService(): void { | ||
assistant.value = null; | ||
assistants.value = null; | ||
} | ||
|
||
describe('assistant', (): void => { | ||
it('gets assistant data by id', async () => { | ||
resetService(); | ||
|
||
await getAssistantByID('235'); | ||
expect(assistant.value).not.toBeNull(); | ||
expect(assistant.value?.username).toBe('bsimpson'); | ||
|
@@ -31,6 +42,8 @@ describe('assistant', (): void => { | |
}); | ||
|
||
it('gets assistants data', async () => { | ||
resetService(); | ||
|
||
await getAssistants(); | ||
expect(assistants).not.toBeNull(); | ||
expect(Array.isArray(assistants.value)).toBe(true); | ||
|
@@ -60,6 +73,8 @@ describe('assistant', (): void => { | |
}); | ||
|
||
it('gets assistants data by course', async () => { | ||
resetService(); | ||
|
||
await getAssistantByCourse('1'); | ||
expect(assistants).not.toBeNull(); | ||
expect(Array.isArray(assistants.value)).toBe(true); | ||
|
@@ -89,19 +104,21 @@ describe('assistant', (): void => { | |
}); | ||
|
||
it('create assistant', async () => { | ||
resetService(); | ||
|
||
const exampleAssistant = new Assistant( | ||
'102', | ||
'sample_assistant', | ||
'[email protected]', | ||
'Sample', | ||
'Assistant', | ||
2023, | ||
true, | ||
[], | ||
[], | ||
[], | ||
new Date('April 2, 2023 01:15:00'), | ||
new Date('April 2, 2024 01:15:00'), | ||
'', // id | ||
'', // username | ||
'[email protected]', // email | ||
'assistant_first_name', // first_name | ||
'assistant_last_name', // last name | ||
2023, // last enrolled | ||
true, // is_staff | ||
[], // roles | ||
[], // faculties | ||
[], // courses | ||
new Date(), // create_time | ||
null, // last_login | ||
); | ||
|
||
await getAssistants(); | ||
|
@@ -116,9 +133,31 @@ describe('assistant', (): void => { | |
expect(Array.isArray(assistants.value)).toBe(true); | ||
expect(assistants.value?.length).toBe(prevLength + 1); | ||
|
||
expect(assistants.value?.[prevLength]?.first_name).toBe('Sample'); | ||
expect(assistants.value?.[prevLength]?.last_name).toBe('Assistant'); | ||
// Only check for fields that are sent to the backend | ||
expect(assistants.value?.[prevLength]?.first_name).toBe('assistant_first_name'); | ||
expect(assistants.value?.[prevLength]?.last_name).toBe('assistant_last_name'); | ||
expect(assistants.value?.[prevLength]?.email).toBe('[email protected]'); | ||
expect(assistants.value?.[prevLength]?.roles).toContain('assistant'); | ||
}); | ||
|
||
it('delete assistant', async () => { | ||
resetService(); | ||
|
||
await getAssistants(); | ||
expect(assistants.value).not.toBeNull(); | ||
expect(Array.isArray(assistants.value)).toBe(true); | ||
const prevLength = assistants.value?.length ?? 0; | ||
|
||
let assistantId = '0'; | ||
if (assistants.value?.[0]?.id !== undefined && assistants.value?.[0].id !== null) { | ||
assistantId = assistants.value?.[0]?.id; | ||
} | ||
|
||
await deleteAssistant(assistantId); | ||
await getAssistants(); | ||
|
||
expect(assistants).not.toBeNull(); | ||
expect(Array.isArray(assistants.value)).toBe(true); | ||
expect(assistants.value?.length).toBe(prevLength - 1); | ||
expect(assistants.value?.[0]?.id).not.toBe(assistantId); | ||
}); | ||
}); |
Oops, something went wrong.