generated from nationalarchives/da-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c0eb0a
commit 4f83a59
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.")) |