Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions e2e_tests/assets/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def hello() -> str:
return "Hello Python!"
2 changes: 2 additions & 0 deletions e2e_tests/assets/functions2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def hello() -> str:
return "Hello, world!"
2 changes: 1 addition & 1 deletion e2e_tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def logout(page: Page):
def upload_submission(page: Page, chapter_name: str, exercise_name: str, files: List[File]):
page.get_by_label("Course").get_by_role(
"link", name="Course materials").click()
page.get_by_role("link", name=chapter_name).click()
page.get_by_role("link", name=chapter_name).first.click()
for file in files:
page.get_by_label(file.label).set_input_files(os.path.join(assets_path, file.name))
page.locator(exercise_name).get_by_role("button", name="Submit").click()
Expand Down
39 changes: 37 additions & 2 deletions e2e_tests/test_file_upload_grader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re
from playwright.sync_api import Page, expect
from e2e_tests.helpers import navigate_to_default_course, login
from e2e_tests.helpers import File, navigate_to_default_course, login, upload_submission


def test_should_not_submit_without_files(page: Page):
Expand All @@ -22,4 +22,39 @@ def test_should_not_submit_without_files(page: Page):
#clicking submit without files will not result in a submission
expect(points).to_contain_text("0 / 10")

#TODO more tests ?
def test_should_give_zero_points_on_incorrect_answer(page: Page):
page.goto("http://localhost:8000/?hl=en")
login(page, "student", "student")
navigate_to_default_course(page)

upload_submission(
page,
chapter_name="6.3 Exercises with Python",
exercise_name="#chapter-exercise-1",
files=[File("functions2.py", "functions.py")]
)

exercise = page.locator('#chapter-exercise-1')
points = exercise.get_by_role("button", name=re.compile("Points"))

#the submission should be incorrect and give zero points
expect(points).to_contain_text("0 / 10")


def test_should_give_full_points_on_correct_answer(page: Page):
page.goto("http://localhost:8000/?hl=en")
login(page, "student", "student")
navigate_to_default_course(page)

upload_submission(
page,
chapter_name="6.3 Exercises with Python",
exercise_name="#chapter-exercise-1",
files=[File("functions.py")]
)

exercise = page.locator('#chapter-exercise-1')
points = exercise.get_by_role("button", name=re.compile("Points"))

#the submission should be correct and give full points
expect(points).to_contain_text("10 / 10")
41 changes: 38 additions & 3 deletions e2e_tests/test_main_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,48 @@ def test_main_navigation(page: Page):
page.goto("http://localhost:8000/?hl=en")
login(page, "teacher", "teacher")
navigate_to_default_course(page)
sidebar = page.locator("#main-course-menu")

page.get_by_role("link", name="Your points").click()
sidebar.get_by_role("link", name="Course materials").click()
expect(page).to_have_url(re.compile("/toc/"))
navigate_to_default_course(page)

sidebar.get_by_role("link", name="Your points").click()
expect(page).to_have_url(re.compile("/user/results/"))
navigate_to_default_course(page)

page.get_by_role("link", name="All results").click()
sidebar.get_by_role("link", name="Participants").click()
expect(page).to_have_url(re.compile("/teachers/participants/"))
navigate_to_default_course(page)

sidebar.get_by_role("link", name="Groups").click()
expect(page).to_have_url(re.compile("/teachers/groups/"))
navigate_to_default_course(page)

sidebar.get_by_role("link", name="All results").click()
expect(page).to_have_url(re.compile("/teachers/results/"))
navigate_to_default_course(page)

sidebar.get_by_role("link", name="Visualizations").click()
expect(page).to_have_url(re.compile("/teachers/analytics/"))
navigate_to_default_course(page)

sidebar.get_by_role("link", name="Edit news").click()
expect(page).to_have_url(re.compile("/teachers/news/"))
navigate_to_default_course(page)

sidebar.get_by_role("link", name="Edit course").click()
expect(page).to_have_url(re.compile("/teachers/"))
navigate_to_default_course(page)

sidebar.get_by_role("link", name="Deadline deviations").click()
expect(page).to_have_url(re.compile("/teachers/deadline-deviations/"))
navigate_to_default_course(page)

sidebar.get_by_role("link", name="Submission deviations").click()
expect(page).to_have_url(re.compile("/teachers/submission-deviations/"))
navigate_to_default_course(page)

#TODO test rest of links? Also student view?
sidebar.get_by_role("link", name="All submissions").click()
expect(page).to_have_url(re.compile("/teachers/all-submissions/"))

6 changes: 3 additions & 3 deletions e2e_tests/test_text_exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_should_give_partial_points_on_partially_correct_submission(page: Page):
page.goto("http://localhost:8000/?hl=en")
login(page, "student", "student")
navigate_to_default_course(page)
page.get_by_role("link", name="5.1 Creating questionnaire exercises").click()
page.get_by_role("link", name="5.1 Creating questionnaire exercises").first.click()

#fill in an partially correct answer for exercise 5.1.3
#fill in different exercise to make the test work independently of the previous test
Expand All @@ -78,7 +78,7 @@ def test_should_give_full_points_on_correct_submission(page: Page):
page.goto("http://localhost:8000/?hl=en")
login(page, "student", "student")
navigate_to_default_course(page)
page.get_by_role("link", name="5.1 Creating questionnaire exercises").click()
page.get_by_role("link", name="5.1 Creating questionnaire exercises").first.click()

#fill in an correct answer for exercise 5.1.4
#fill in different exercise to make the test work independently of the previous test
Expand All @@ -99,7 +99,7 @@ def test_should_not_accept_submission_after_max_submissions_reached(page: Page):
page.goto("http://localhost:8000/?hl=en")
login(page, "student", "student")
navigate_to_default_course(page)
page.get_by_role("link", name="5.1 Creating questionnaire exercises").click()
page.get_by_role("link", name="5.1 Creating questionnaire exercises").first.click()

#fill in an false answer for exercise 5.1.2 until max submissions reached
exercise = page.locator("#chapter-exercise-2")
Expand Down
Loading