-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Playwright setup #2500
Draft
angela-tran
wants to merge
11
commits into
main
Choose a base branch
from
feat/playwright-setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Feat: Playwright setup #2500
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
816aacc
feat: add setup for a separate container to run playwright
angela-tran d8bb7cd
feat(playwright): add scaffolding for writing and running tests
angela-tran fed78b6
refactor: extract some helper script args out into pytest.ini file
angela-tran 2b10995
test: add agency card flow test
angela-tran f5ecfb4
fix(ci): specify directory to use for running unit tests
angela-tran 787e769
fix(ci): mark 'playwright' service under a 'testing' profile
angela-tran ac111d6
refactor: use optional env_file instead of profile-based approach
angela-tran 2589eb7
refactor(tests): remove usage of .env file entirely for now
angela-tran c980ff0
refactor: move playwright directory under tests directory
angela-tran bff1ec0
refactor: make playwright service's default command be to run the tests
angela-tran 694aeae
refactor: simplify helper script
angela-tran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,10 @@ | ||
MEDICARE_FLOW_USERNAME= | ||
MEDICARE_FLOW_PASSWORD= | ||
|
||
AGENCY_CARD_SUB= | ||
AGENCY_CARD_NAME= | ||
|
||
TRANSIT_PROCESSOR_CARDHOLDER_NAME= | ||
TRANSIT_PROCESSOR_CARD_NUMBER= | ||
TRANSIT_PROCESSOR_CARD_EXPIRATION= | ||
TRANSIT_PROCESSOR_CARD_SECURITY_CODE= |
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,3 @@ | ||
__pycache__ | ||
.pytest_cache | ||
test-results |
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,11 @@ | ||
# https://playwright.dev/docs/docker | ||
FROM mcr.microsoft.com/playwright/python:v1.48.0-jammy | ||
|
||
WORKDIR /playwright | ||
|
||
COPY playwright/requirements.txt requirements.txt | ||
|
||
RUN python -m pip install --upgrade pip && \ | ||
pip install -r requirements.txt | ||
|
||
USER pwuser |
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,2 @@ | ||
[pytest] | ||
addopts = --tracing on -v --template=html1/index.html --report=test-results/report.html --video on |
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,3 @@ | ||
pytest | ||
pytest-playwright | ||
pytest-reporter-html1 |
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,8 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
base_url="https://dev-benefits.calitp.org" | ||
|
||
# also uses arguments from pytest.ini | ||
pytest --base-url $base_url |
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,70 @@ | ||
import os | ||
|
||
from playwright.sync_api import Page, expect | ||
|
||
|
||
def test_agency_card_flow(page: Page): | ||
page.goto("https://dev-benefits.calitp.org/") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you meant |
||
|
||
# Index - select transit agency | ||
page.get_by_role("link", name="Choose your Provider").click() | ||
page.get_by_role("link", name="California State Transit (dev)").click() | ||
|
||
# Eligibility Index - select enrollment flow | ||
page.get_by_label("Agency Cardholder").check() | ||
page.get_by_role("button", name="Choose this benefit").click() | ||
|
||
# Eligibility Start - continue | ||
page.get_by_role("button", name="Continue").click() | ||
|
||
# Eligibility Confirm - fill out form and submit | ||
page.get_by_placeholder("12345").click() | ||
|
||
sub = os.environ.get("AGENCY_CARD_SUB") | ||
page.get_by_placeholder("12345").fill(sub) | ||
page.keyboard.press("Tab") | ||
|
||
name = os.environ.get("AGENCY_CARD_NAME") | ||
page.get_by_placeholder("Hernandez-Demarcos").fill(name) | ||
|
||
page.get_by_role("button", name="Find my record").click() | ||
|
||
# Enrollment Index - fill out transit processor form in pop-up window | ||
page.mouse.wheel(0, 200) | ||
|
||
with page.expect_popup() as popup_info: | ||
page.get_by_role("button", name="Enroll").click() | ||
|
||
popup = popup_info.value | ||
popup.wait_for_timeout(3000) | ||
|
||
popup.get_by_text("Cardholder name").click() | ||
|
||
cardholder_name = os.environ.get("TRANSIT_PROCESSOR_CARDHOLDER_NAME") | ||
popup.get_by_label("Cardholder name").fill(cardholder_name) | ||
popup.keyboard.press("Tab") | ||
|
||
card_number = os.environ.get("TRANSIT_PROCESSOR_CARD_NUMBER") | ||
popup.get_by_label("Card number").fill(card_number) | ||
popup.keyboard.press("Tab") | ||
|
||
expiration = os.environ.get("TRANSIT_PROCESSOR_CARD_EXPIRATION") | ||
popup.get_by_label("mm/yy").fill(expiration) | ||
popup.keyboard.press("Tab") | ||
|
||
security_code = os.environ.get("TRANSIT_PROCESSOR_CARD_SECURITY_CODE") | ||
popup.get_by_text("Security code", exact=True).click() | ||
popup.get_by_label("Security code").fill(security_code) | ||
|
||
# trigger form validation - not sure why their form behaves this way | ||
popup.keyboard.press("Shift+Tab") | ||
popup.keyboard.press("Shift+Tab") | ||
popup.keyboard.press("Shift+Tab") | ||
popup.keyboard.press("Tab") | ||
|
||
popup.get_by_role("group", name="Enter your card details").get_by_role("button").click() | ||
|
||
page.wait_for_timeout(10000) | ||
|
||
success_message = page.get_by_text("You can now use your contactless card to tap to ride with a reduced fare!") | ||
expect(success_message).to_be_visible() |
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,13 @@ | ||
from playwright.sync_api import Page | ||
|
||
|
||
def test_older_adult_flow(page: Page): | ||
pass | ||
|
||
|
||
def test_veteran_flow(page: Page): | ||
pass | ||
|
||
|
||
def test_calfresh_cardholder_flow(page: Page): | ||
pass |
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,26 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from playwright.sync_api import Page, expect | ||
|
||
|
||
@pytest.mark.skip(reason="WIP - Medicare.gov not allowing test to login") | ||
def test_medicare_cardholder_flow(page: Page): | ||
page.goto("/") | ||
page.click("text='Choose your Provider'") | ||
page.get_by_role("link", name="California State Transit (dev)").click() | ||
page.get_by_label("Medicare Cardholder You must").check() | ||
page.get_by_role("button", name="Choose this benefit").click() | ||
page.get_by_role("button", name="Continue to Medicare.gov").click() | ||
page.get_by_label("Username", exact=True).click() | ||
|
||
username = os.environ.get("MEDICARE_FLOW_USERNAME") | ||
page.get_by_label("Username", exact=True).fill(username) | ||
|
||
password = os.environ.get("MEDICARE_FLOW_PASSWORD") | ||
page.get_by_label("Password").fill(password) | ||
|
||
page.get_by_role("button", name="Log in").click() | ||
|
||
expect |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe take this from the command line?