Skip to content

Commit

Permalink
e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnoutAllaert committed May 23, 2024
1 parent ba45e16 commit 5fe98d2
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 3 deletions.
15 changes: 15 additions & 0 deletions api/middleware/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from django.contrib.auth.models import User
from api.models.gebruiker import Gebruiker
from api.serializers.gebruiker import GebruikerSerializer
from api.serializers.template import TemplateSerializer
from django.core.files import File
import requests
import os

URL = "https://graph.microsoft.com/v1.0/me"

Expand Down Expand Up @@ -59,6 +62,16 @@ def __call__(self, request):
try:
Gebruiker.objects.get(pk=request.user.id)
except Gebruiker.DoesNotExist:
directory_path = "api/base_templates"
for filename in os.listdir(directory_path):
file_path = os.path.join(directory_path, filename)
with open(file_path, "rb") as f:
django_file = File(f)
template_data = {"user": request.user.id, "bestand": django_file}
serializer = TemplateSerializer(data=template_data)
if serializer.is_valid():
serializer.save()

gebruiker_post_data = {
"user": request.user.id,
"subjects": [],
Expand All @@ -71,6 +84,8 @@ def __call__(self, request):
return self.get_response(request)




class DisableCSRFMiddleware(object):

def __init__(self, get_response):
Expand Down
1 change: 0 additions & 1 deletion api/middleware/middleware_lesgever_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from api.serializers.gebruiker import GebruikerSerializer
from api.serializers.template import TemplateSerializer
from django.core.files import File
import requests
import os


Expand Down
1 change: 1 addition & 0 deletions frontend/frontend/cypress/e2e/student/group.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('student chooses a group and leaves', () => {
})

it('join', () => {
// student should able to choose a group because of the teacher groups test
cy.contains('test course').click()
cy.contains('test project').click()
cy.get('#group').click()
Expand Down
5 changes: 5 additions & 0 deletions frontend/frontend/cypress/e2e/teacher/project.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { cyan } from "@mui/material/colors"

describe('add and change projects', () => {
beforeEach(() => {
cy.visit('http://localhost:5173')
Expand All @@ -16,6 +18,9 @@ describe('add and change projects', () => {
cy.get('#setVisible').click()
cy.get('#groupSize').clear().type('2')
cy.get('#maxScore').clear().type('30')
// add an assignment
cy.get('#uploadButton').selectFile('cypress/fixtures/test.pdf')
cy.contains('test.pdf').should('exist')
// add a restriction script
cy.get('#addRestrictionButton').click()
// create a new script
Expand Down
7 changes: 5 additions & 2 deletions frontend/frontend/cypress/e2e/teacher/score.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ describe('assign scores to submissions', () => {
cy.contains('test course').click()
cy.contains('test project').click()
cy.get('#adjustScores').click()

// TODO adjust the scores
cy.get('#score').type('10')
cy.get('#saveScores').click()
cy.get('#confirm').click()
// check if the score is assigned
cy.contains('10/30').should('exist')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ export function ProjectScoresPage() {
title={t('save_scores')}
>
<IconButton
id='saveScores'
onClick={() =>
setOpenSaveScoresPopup(
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export function StudentScoreListItem({
height={'25px'}
>
<TextField
id='score'
hiddenLabel
defaultValue={score}
onChange={(event) =>
Expand Down

0 comments on commit 5fe98d2

Please sign in to comment.