Skip to content

Commit

Permalink
Add e2e tests for login view
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyhashemi committed Nov 2, 2023
1 parent 0c0eb0a commit 4f83a59
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions e2e_tests/test_login.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os

from playwright.sync_api import Page, expect


def test_login_succeeds_when_valid_credentials(page: Page):
"""
Given a user is on the login page,
When they provide valid credentials and click the "Sign in" button,
Then they should see a success message indicating they are logged in with access to AYR.
And they should be on the '/poc-search-view' page.
"""
page.goto("/login")
page.get_by_label("Email address").fill(os.environ.get("AYR_TEST_USERNAME"))
page.get_by_label("Password").fill(os.environ.get("AYR_TEST_PASSWORD"))
page.get_by_role("button", name="Sign in").click()
expect(page).to_have_url("/poc-search-view")
expect(page.get_by_text("TNA User is logged in and has access to AYR."))


def test_login_fails_when_invalid_credentials(page: Page):
"""
Given a user is on the login page,
When they provide invalid credentials and click the "Sign in" button,
Then they should see an error message indicating the provided credentials are invalid.
"""
page.goto("/login")
page.get_by_label("Email address").fill("bad")
page.get_by_label("Password").fill("credentials")
page.get_by_role("button", name="Sign in").click()
expect(page.get_by_text("Invalid username or password."))

0 comments on commit 4f83a59

Please sign in to comment.