Skip to content
Open
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
12 changes: 12 additions & 0 deletions pages/profile_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from playwright.sync_api import Page


class ProfilePage:
def __init__(self, page: Page) -> None:
self.page = page
self.name = page.get_by_test_id("profile-name")
self.student_id = page.get_by_test_id("profile-student-id")
self.degree_course = page.get_by_test_id("profile-degree")

def goto(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manca il tipo di ritorno, def goto(self) -> None:

self.page.goto("/profile")
14 changes: 14 additions & 0 deletions tests/features/student_id.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Feature: StudentId

# Background:

Scenario: Correct student id
Given I log in as "mario" with password "password123"
When I goto profile page
Then I see the student ID "1000012345"

Scenario: Wrong student id
Given I log in as "luigi" with password "password123"
When I goto profile page
Then I cannot enter profile page
And I do not see any student ID
36 changes: 36 additions & 0 deletions tests/test_student_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from playwright.sync_api import Page, expect
from pytest_bdd import given, parsers, scenarios, then, when

from pages.login_page import LoginPage
from pages.profile_page import ProfilePage

scenarios("features/student_id.feature")


@given(parsers.parse('I log in as "{username}" with password "{password}"'))
def login_as_user(page: Page, username: str, password: str) -> None:
login_page = LoginPage(page)
login_page.goto()
login_page.login(username, password)


@when("I goto profile page", target_fixture="profile_page")
def goto_profile_page(page: Page) -> ProfilePage:
profile_page = ProfilePage(page)
profile_page.goto()
return profile_page


@then(parsers.parse('I see the student ID "{student_id}"'))
def see_student_id(profile_page: ProfilePage, student_id: str) -> None:
expect(profile_page.student_id).to_have_text(student_id)


@then("I do not see any student ID")
def dont_see_student_id(profile_page: ProfilePage) -> None:
expect(profile_page.student_id).to_have_count(0)


@then("I cannot enter profile page")
def dont_see_student_id(page: Page) -> None:
expect(page).not_to_have_url("/profile")