Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #146 from SELab-2/frontend-tests
Browse files Browse the repository at this point in the history
Frontend tests
  • Loading branch information
msathieu authored Apr 18, 2024
2 parents 3ccb6c8 + 2fb9dc2 commit a716d03
Show file tree
Hide file tree
Showing 13 changed files with 2,176 additions and 52 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,19 @@ Volg deze stappen om de frontend van het project op te zetten:
3. Installeer alle npm dependencies
```bash
npm install
```
```
4. Build de frontend:
```bash
npm run build
```
De gecompileerde html/css/js bevindt zich nu in de `dist` folder

De gecompileerde html/css/js bevindt zich nu in de `dist` folder.
5. Deploy:

Zet de inhoud van de `dist` folder op de juiste plaats, zodat het geserveerd kan worden.

6. De testen kunnen uitgevoerd worden met: (nog niet geïmplementeerd)
6. De testen kunnen uitgevoerd worden met:
```bash
npm run tests
```
Dit draait zowel de unit als de e2e testen. De e2e testen kun je ook debuggen met een UI in je browser via:
```bash
npm run test:e2e:ui
```
82 changes: 68 additions & 14 deletions backend/fill_database_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

from create_database_tables import initialize_tables
from db.extensions import engine
from db.models import SubmissionState
from db.models import SubjectInput, SubmissionState
from domain.logic.admin import create_admin
from domain.logic.group import add_student_to_group, create_group
from domain.logic.project import create_project
from domain.logic.role_enum import Role
from domain.logic.student import create_student
from domain.logic.subject import add_student_to_subject, add_teacher_to_subject, create_subject
from domain.logic.subject import add_student_to_subject, add_teacher_to_subject, create_subject, update_subject
from domain.logic.submission import create_submission
from domain.logic.teacher import create_teacher
from domain.logic.user import modify_user_roles
Expand All @@ -25,6 +25,7 @@ def fill_database_mock() -> None:
objeprog = create_subject(session, name="Objectgericht Programmeren")
algoritmen = create_subject(session, name="Algoritmen en Datastructuren")
webtech = create_subject(session, name="Webtechnologie")
funcprog = create_subject(session, name="Haskell")

# Create projects for subjects
objprog_project = create_project(
Expand Down Expand Up @@ -84,6 +85,18 @@ def fill_database_mock() -> None:
deadline=datetime(2024, 10, 30, 23, 59, 59, tzinfo=tz.LOCAL),
)

haskell_project = create_project(
session=session,
subject_id=funcprog.id,
name="RPG Game in Haskell",
archived=False,
visible=True,
description="Maak een RPG game in Haskell!",
requirements='{"type": "zip_constraint", "name": "submission.zip", "sub_constraints": []}',
max_students=1,
deadline=datetime(2023, 7, 17, 22, 33, 44, tzinfo=tz.LOCAL),
)

# Create groups for projects
groep1_objprog = create_group(session, objprog_project.id)
groep2_objprog = create_group(session, objprog_project.id)
Expand All @@ -99,16 +112,21 @@ def fill_database_mock() -> None:
groep8_algo = create_group(session, algo_project.id)
groep1_web = create_group(session, web_project.id)
create_group(session, web_project.id)
groep1funcprog = create_group(session, haskell_project.id)
groep2funcprog = create_group(session, haskell_project.id)
groep3funcprog = create_group(session, haskell_project.id)
groep4funcprog = create_group(session, haskell_project.id)
create_group(session, haskell_project.id) # lege groep

# Create students
student1 = create_student(session, "Lukas", "Lukas.BarraganTorres@UGent.be")
student2 = create_student(session, "Alberic", "Alberic.Loos@UGent.be")
student3 = create_student(session, "Matthias", "matseghe.Seghers@UGent.be")
student4 = create_student(session, "Ruben", "Ruben.Vandamme@UGent.be")
student5 = create_student(session, "Emma", "emmavdwa.Vandewalle@UGent.be")
student6 = create_student(session, "Robbe", "Robbe.VandeKeere@UGent.be")
student1 = create_student(session, "Lukas", "lukas.barragantorres@ugent.be")
student2 = create_student(session, "Alberic", "alberic.loos@ugent.be")
student3 = create_student(session, "Matthias", "matseghe.seghers@ugent.be")
student4 = create_student(session, "Ruben", "ruben.vandamme@ugent.be")
student5 = create_student(session, "Emma", "emmavdwa.vandewalle@ugent.be")
student6 = create_student(session, "Robbe", "robbe.vandekeere@ugent.be")
student7 = create_student(session, "Stef", "stef.osse@ugent.be")
student8 = create_student(session, "Mathieu", "Mathieu.Strypsteen@UGent.be")
student8 = create_student(session, "Mathieu", "mathieu.strypsteen@ugent.be")

# Create teachers
teacher1 = create_teacher(session, "Kris Coolsaet", "kris.coolsaet@ugent.be")
Expand Down Expand Up @@ -139,19 +157,24 @@ def fill_database_mock() -> None:
add_student_to_subject(session, student1.id, algoritmen.id)
add_student_to_subject(session, student2.id, algoritmen.id)
add_student_to_subject(session, student3.id, algoritmen.id)
# noinspection DuplicatedCode
add_student_to_subject(session, student4.id, algoritmen.id)
add_student_to_subject(session, student5.id, algoritmen.id)
# noinspection DuplicatedCode
add_student_to_subject(session, student6.id, algoritmen.id)
add_student_to_subject(session, student7.id, algoritmen.id)
add_student_to_subject(session, student8.id, algoritmen.id)

add_student_to_subject(session, student1.id, webtech.id)
add_student_to_subject(session, student2.id, webtech.id)
add_student_to_subject(session, student3.id, webtech.id)
add_student_to_subject(session, student5.id, webtech.id) # 4 en 8 zullen assistent zijn bij dit vak
add_student_to_subject(session, student6.id, webtech.id)
add_student_to_subject(session, student7.id, webtech.id)
add_student_to_subject(session, student4.id, webtech.id)
add_student_to_subject(session, student5.id, webtech.id)
add_student_to_subject(session, student7.id, webtech.id) # 6 en 8 zullen assistent zijn bij dit vak

add_student_to_subject(session, student2.id, funcprog.id)
add_student_to_subject(session, student4.id, funcprog.id)
add_student_to_subject(session, student6.id, funcprog.id)
add_student_to_subject(session, student8.id, funcprog.id)

# Add students to groups

Expand All @@ -166,9 +189,9 @@ def fill_database_mock() -> None:
add_student_to_group(session, student8.id, groep3_objprog.id)

add_student_to_group(session, student4.id, groep1_algo.id)
# noinspection DuplicatedCode
add_student_to_group(session, student5.id, groep2_algo.id)
add_student_to_group(session, student6.id, groep3_algo.id)
# noinspection DuplicatedCode
add_student_to_group(session, student1.id, groep4_algo.id)
add_student_to_group(session, student2.id, groep5_algo.id)
add_student_to_group(session, student3.id, groep6_algo.id)
Expand All @@ -179,6 +202,11 @@ def fill_database_mock() -> None:
add_student_to_group(session, student3.id, groep1_web.id)
add_student_to_group(session, student5.id, groep1_web.id)

add_student_to_group(session, student2.id, groep1funcprog.id)
add_student_to_group(session, student4.id, groep2funcprog.id)
add_student_to_group(session, student6.id, groep3funcprog.id)
add_student_to_group(session, student8.id, groep4funcprog.id)

# Create submissions (one per group)
create_submission(
session=session,
Expand Down Expand Up @@ -250,13 +278,39 @@ def fill_database_mock() -> None:
filename="sorteer_algoritmen.py",
)

create_submission(
session=session,
student_id=student2.id,
group_id=groep1funcprog.id,
message="nieuwe sprites",
state=SubmissionState.Approved,
date_time=datetime(2023, 7, 16, 23, 0, 0, tzinfo=tz.LOCAL),
filename="RPG.zip",
)

create_submission(
session=session,
student_id=student8.id,
group_id=groep4funcprog.id,
message="fix inventory bug",
state=SubmissionState.Approved,
date_time=datetime(2023, 7, 18, 21, 2, 5, tzinfo=tz.LOCAL),
filename="fungame.zip",
)

# make assistants
modify_user_roles(session, student4.id, [Role.TEACHER])
add_teacher_to_subject(session, student4.id, webtech.id)

modify_user_roles(session, student8.id, [Role.TEACHER])
add_teacher_to_subject(session, student8.id, webtech.id)

modify_user_roles(session, student6.id, [Role.TEACHER])
add_teacher_to_subject(session, student6.id, funcprog.id)

# Archive a subject
update_subject(session, funcprog.id, SubjectInput(name="Functioneel Programmeren", archived=True))

session.commit()
session.close()

Expand Down
5 changes: 4 additions & 1 deletion frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
plugins: ['vitest', 'react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
Expand All @@ -24,6 +24,9 @@ module.exports = {
tsconfigRootDir: __dirname,
},
settings: {
"vitest": {
"typecheck": true
},
"react": {
"version": "detect", // React version
"flowVersion": "0.53" // Flow version
Expand Down
72 changes: 71 additions & 1 deletion frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,74 @@ dist-ssr
*.sw?

# React Component Preview
previewConfig.json
previewConfig.json
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/coverage/src/utils/ApiFetch.ts.html
/coverage/src/context/AuthContext.ts.html
/coverage/src/components/authentication/AuthProvider.tsx.html
/coverage/base.css
/coverage/block-navigation.js
/coverage/src/pages/student/CoursesViewStudent.tsx.html
/coverage/src/pages/teacher/CoursesViewTeacher.tsx.html
/coverage/src/pages/teacher/CreateCourse.tsx.html
/coverage/src/pages/teacher/CreateProject.tsx.html
/coverage/src/pages/student/DeadlineTable.tsx.html
/coverage/src/components/DefaultErrorPage.tsx.html
/coverage/src/pages/error.tsx.html
/coverage/src/components/authentication/ErrorLogin.tsx.html
/coverage/favicon.png
/coverage/src/components/FieldWithLabel.tsx.html
/coverage/src/components/Header.tsx.html
/coverage/src/pages/admin/HomeAdmin.tsx.html
/coverage/src/pages/student/HomeStudent.tsx.html
/coverage/src/pages/teacher/HomeTeacher.tsx.html
/coverage/src/components/authentication/index.html
/coverage/src/components/index.html
/coverage/src/context/index.html
/coverage/src/dataloaders/index.html
/coverage/src/hooks/index.html
/coverage/src/pages/admin/index.html
/coverage/src/pages/login/index.html
/coverage/src/pages/student/index.html
/coverage/src/pages/teacher/index.html
/coverage/src/pages/index.html
/coverage/src/types/index.html
/coverage/src/utils/index.html
/coverage/src/index.html
/coverage/index.html
/coverage/src/components/Inputfield.tsx.html
/coverage/src/components/authentication/LoginForm.tsx.html
/coverage/src/dataloaders/LoginLoader.ts.html
/coverage/src/pages/login/LoginScreen.tsx.html
/coverage/src/main.tsx.html
/coverage/prettify.css
/coverage/prettify.js
/coverage/src/types/project.ts.html
/coverage/src/pages/student/ProjectCardStudent.tsx.html
/coverage/src/pages/student/ProjectsViewStudent.tsx.html
/coverage/src/pages/teacher/ProjectsViewTeacher.tsx.html
/coverage/src/pages/student/ProjectViewStudent.tsx.html
/coverage/src/pages/teacher/ProjectViewTeacher.tsx.html
/coverage/src/components/RegularATag.tsx.html
/coverage/src/components/RegularButton.tsx.html
/coverage/src/components/authentication/RequireAuth.tsx.html
/coverage/src/pages/root.tsx.html
/coverage/src/components/SearchBar.tsx.html
/coverage/src/components/SelectionBox.tsx.html
/coverage/src/components/Settings.tsx.html
/coverage/src/dataloaders/SharedFunctions.ts.html
/coverage/src/components/Sidebar.tsx.html
/coverage/sort-arrow-sprite.png
/coverage/sorter.js
/coverage/src/components/Statistics.tsx.html
/coverage/src/dataloaders/StudentLoader.ts.html
/coverage/src/dataloaders/SubjectsTeacherLoader.ts.html
/coverage/src/components/Table.tsx.html
/coverage/src/dataloaders/TeacherLoader.ts.html
/coverage/src/components/authentication/Unauthorized.tsx.html
/coverage/src/hooks/useAuth.ts.html
/coverage/src/components/ViewProjectStudentComponent.tsx.html
/coverage/src/components/ViewProjectTeacherComponent.tsx.html
Loading

0 comments on commit a716d03

Please sign in to comment.