Skip to content

Commit

Permalink
Add e2e tests for personalized points goal
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelGusse committed Aug 12, 2024
1 parent a2b46c3 commit bd05872
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions e2e_tests/test_points_goal_set.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from playwright.sync_api import Page, expect
from e2e_tests.helpers import login

def test_points_goal_set(page: Page) -> None:
login(page, "student", "student")

page.get_by_role("link", name="Def. Course Current DEF000 1.").click()
page.get_by_role("link", name="Your points").click()
page.locator("#progress-questionnaires").get_by_role("button", name="Points goal").click()
page.get_by_label("Input personalized goal as").fill("50")
page.get_by_label("Input personalized goal as").press("Tab")
page.get_by_role("button", name="Save").click()
expect(page.locator("#success-alert")).to_contain_text("Succesfully set personalized points goal")
page.get_by_role("button", name="Close", exact=True).click()
expect(page.get_by_text("Points goal: 50"))
expect(page.locator("#goal-points"))


def test_points_goal_reached(page: Page) -> None:
login(page, "student", "student")
page.get_by_role("link", name="Def. Course Current DEF000 1.").click()
page.get_by_role("link", name="Creating questionnaire exercises").click()
page.locator("label").filter(has_text="2").first.click()
page.locator("label").filter(has_text="an integer").first.click()
page.locator("div:nth-child(4) > div:nth-child(6) > label").click()
page.locator("label").filter(has_text="-").nth(1).click()
page.locator("label").filter(has_text="an integer").nth(1).click()
page.locator("div:nth-child(5) > div:nth-child(6) > label").click()
page.locator("label").filter(has_text="-").nth(3).click()
page.locator("#chapter-exercise-1").get_by_role("button", name="Submit").click()
expect(page.get_by_label("5.1.1 Single-choice and")).to_contain_text("30 / 40")
page.get_by_role("link", name="Your points").click()
page.locator("#progress-questionnaires").get_by_role("button", name="Points goal").click()
page.get_by_label("Input personalized goal as").fill("30")
page.get_by_role("button", name="Save").click()
expect(page.locator("#success-alert")).to_contain_text("Succesfully set personalized points goal")
page.get_by_role("button", name="Close", exact=True).click()
expect(page.locator("#progress-questionnaires > .progress > .progress-bar")).to_have_class("progress-bar progress-bar-striped progress-bar-primary")

0 comments on commit bd05872

Please sign in to comment.