mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 18:37:33 -04:00
notify-api-412 use black to enforce python coding style
This commit is contained in:
@@ -6,74 +6,69 @@ import pytest
|
||||
from playwright.sync_api import expect
|
||||
|
||||
|
||||
@pytest.mark.skip(reason='Not authenticating test users.')
|
||||
@pytest.mark.skip(reason="Not authenticating test users.")
|
||||
def test_accounts_page(end_to_end_authenticated_context):
|
||||
# Open a new page and go to the staging site.
|
||||
page = end_to_end_authenticated_context.new_page()
|
||||
|
||||
accounts_uri = '{}accounts'.format(os.getenv('NOTIFY_E2E_TEST_URI'))
|
||||
accounts_uri = "{}accounts".format(os.getenv("NOTIFY_E2E_TEST_URI"))
|
||||
|
||||
page.goto(accounts_uri)
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state('domcontentloaded')
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
# Check the page title exists and matches what we expect.
|
||||
expect(page).to_have_title(re.compile('Choose service'))
|
||||
expect(page).to_have_title(re.compile("Choose service"))
|
||||
|
||||
# Check for the sign in heading.
|
||||
sign_in_heading = page.get_by_role('heading', name='Choose service')
|
||||
sign_in_heading = page.get_by_role("heading", name="Choose service")
|
||||
expect(sign_in_heading).to_be_visible()
|
||||
|
||||
# Retrieve some prominent elements on the page for testing.
|
||||
add_service_button = page.get_by_role(
|
||||
'button',
|
||||
name=re.compile('Add a new service')
|
||||
"button", name=re.compile("Add a new service")
|
||||
)
|
||||
|
||||
expect(add_service_button).to_be_visible()
|
||||
|
||||
|
||||
@pytest.mark.skip(reason='Not authenticating test users.')
|
||||
@pytest.mark.skip(reason="Not authenticating test users.")
|
||||
def test_add_new_service_workflow(end_to_end_authenticated_context):
|
||||
# Prepare for adding a new service later in the test.
|
||||
current_date_time = datetime.datetime.now()
|
||||
new_service_name = 'E2E Federal Test Service {now} - {browser_type}'.format(
|
||||
now=current_date_time.strftime('%m/%d/%Y %H:%M:%S'),
|
||||
browser_type=end_to_end_authenticated_context.browser.browser_type.name
|
||||
new_service_name = "E2E Federal Test Service {now} - {browser_type}".format(
|
||||
now=current_date_time.strftime("%m/%d/%Y %H:%M:%S"),
|
||||
browser_type=end_to_end_authenticated_context.browser.browser_type.name,
|
||||
)
|
||||
|
||||
# Open a new page and go to the staging site.
|
||||
page = end_to_end_authenticated_context.new_page()
|
||||
|
||||
accounts_uri = '{}accounts'.format(os.getenv('NOTIFY_E2E_TEST_URI'))
|
||||
accounts_uri = "{}accounts".format(os.getenv("NOTIFY_E2E_TEST_URI"))
|
||||
|
||||
page.goto(accounts_uri)
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state('domcontentloaded')
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
# Check the page title exists and matches what we expect.
|
||||
expect(page).to_have_title(re.compile('Choose service'))
|
||||
expect(page).to_have_title(re.compile("Choose service"))
|
||||
|
||||
# Check for the sign in heading.
|
||||
sign_in_heading = page.get_by_role('heading', name='Choose service')
|
||||
sign_in_heading = page.get_by_role("heading", name="Choose service")
|
||||
expect(sign_in_heading).to_be_visible()
|
||||
|
||||
# Retrieve some prominent elements on the page for testing.
|
||||
add_service_button = page.get_by_role(
|
||||
'button',
|
||||
name=re.compile('Add a new service')
|
||||
"button", name=re.compile("Add a new service")
|
||||
)
|
||||
|
||||
expect(add_service_button).to_be_visible()
|
||||
|
||||
existing_service_link = page.get_by_role(
|
||||
'link',
|
||||
name=new_service_name
|
||||
)
|
||||
existing_service_link = page.get_by_role("link", name=new_service_name)
|
||||
|
||||
# Check to see if the service was already created - if so, we should fail.
|
||||
# TODO: Figure out how to make this truly isolated, and/or work in a
|
||||
@@ -84,10 +79,10 @@ def test_add_new_service_workflow(end_to_end_authenticated_context):
|
||||
add_service_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state('domcontentloaded')
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# Check for the sign in heading.
|
||||
about_heading = page.get_by_role('heading', name='About your service')
|
||||
about_heading = page.get_by_role("heading", name="About your service")
|
||||
expect(about_heading).to_be_visible()
|
||||
|
||||
# Retrieve some prominent elements on the page for testing.
|
||||
@@ -95,10 +90,7 @@ def test_add_new_service_workflow(end_to_end_authenticated_context):
|
||||
federal_radio_button = page.locator('xpath=//input[@value="federal"]')
|
||||
state_radio_button = page.locator('xpath=//input[@value="state"]')
|
||||
other_radio_button = page.locator('xpath=//input[@value="other"]')
|
||||
add_service_button = page.get_by_role(
|
||||
'button',
|
||||
name=re.compile('Add service')
|
||||
)
|
||||
add_service_button = page.get_by_role("button", name=re.compile("Add service"))
|
||||
|
||||
expect(service_name_input).to_be_visible()
|
||||
expect(federal_radio_button).to_be_visible()
|
||||
@@ -114,7 +106,7 @@ def test_add_new_service_workflow(end_to_end_authenticated_context):
|
||||
add_service_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state('domcontentloaded')
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# Check for the service name title and heading.
|
||||
service_heading = page.get_by_text(new_service_name)
|
||||
|
||||
@@ -8,24 +8,20 @@ from playwright.sync_api import expect
|
||||
def test_landing_page(end_to_end_context):
|
||||
# Open a new page and go to the staging site.
|
||||
page = end_to_end_context.new_page()
|
||||
page.goto(os.getenv('NOTIFY_E2E_TEST_URI'))
|
||||
page.goto(os.getenv("NOTIFY_E2E_TEST_URI"))
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state('domcontentloaded')
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# Check the page title exists and matches what we expect.
|
||||
expect(page).to_have_title(re.compile('Notify.gov'))
|
||||
expect(page).to_have_title(re.compile("Notify.gov"))
|
||||
|
||||
# Retrieve some prominent elements on the page for testing.
|
||||
main_header = page.get_by_role(
|
||||
'heading',
|
||||
name='Send text messages to your participants'
|
||||
)
|
||||
sign_in_button = page.get_by_role('link', name='Sign in')
|
||||
benefits_studio_email = page.get_by_role(
|
||||
'link',
|
||||
name='tts-benefits-studio@gsa.gov'
|
||||
"heading", name="Send text messages to your participants"
|
||||
)
|
||||
sign_in_button = page.get_by_role("link", name="Sign in")
|
||||
benefits_studio_email = page.get_by_role("link", name="tts-benefits-studio@gsa.gov")
|
||||
|
||||
# Check to make sure the elements are visible.
|
||||
expect(main_header).to_be_visible()
|
||||
@@ -33,46 +29,45 @@ def test_landing_page(end_to_end_context):
|
||||
expect(benefits_studio_email).to_be_visible()
|
||||
|
||||
# Check to make sure the sign-in button and email links are correct.
|
||||
expect(sign_in_button).to_have_attribute('href', '/sign-in')
|
||||
expect(sign_in_button).to_have_attribute("href", "/sign-in")
|
||||
expect(benefits_studio_email).to_have_attribute(
|
||||
'href',
|
||||
'mailto:tts-benefits-studio@gsa.gov'
|
||||
"href", "mailto:tts-benefits-studio@gsa.gov"
|
||||
)
|
||||
|
||||
# Retrieve all other main content headers and check that they're
|
||||
# visible.
|
||||
content_headers = [
|
||||
'Control your content',
|
||||
'See how your messages perform',
|
||||
'No technical integration needed',
|
||||
'About the product',
|
||||
"Control your content",
|
||||
"See how your messages perform",
|
||||
"No technical integration needed",
|
||||
"About the product",
|
||||
]
|
||||
|
||||
for content_header in content_headers:
|
||||
expect(
|
||||
page.get_by_role('heading', name=re.compile(content_header))
|
||||
page.get_by_role("heading", name=re.compile(content_header))
|
||||
).to_be_visible()
|
||||
|
||||
|
||||
@pytest.mark.skip(reason='Not authenticating test users.')
|
||||
@pytest.mark.skip(reason="Not authenticating test users.")
|
||||
def test_sign_in_and_mfa_pages(end_to_end_context):
|
||||
# Open a new page and go to the staging site.
|
||||
page = end_to_end_context.new_page()
|
||||
page.goto(os.getenv('NOTIFY_E2E_TEST_URI'))
|
||||
page.goto(os.getenv("NOTIFY_E2E_TEST_URI"))
|
||||
|
||||
sign_in_button = page.get_by_role('link', name='Sign in')
|
||||
sign_in_button = page.get_by_role("link", name="Sign in")
|
||||
|
||||
# Test trying to sign in.
|
||||
sign_in_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state('domcontentloaded')
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# Check the page title exists and matches what we expect.
|
||||
expect(page).to_have_title(re.compile('Sign in'))
|
||||
expect(page).to_have_title(re.compile("Sign in"))
|
||||
|
||||
# Check for the sign in heading.
|
||||
sign_in_heading = page.get_by_role('heading', name='Sign in')
|
||||
sign_in_heading = page.get_by_role("heading", name="Sign in")
|
||||
expect(sign_in_heading).to_be_visible()
|
||||
|
||||
# Check for the sign in form elements.
|
||||
@@ -82,17 +77,11 @@ def test_sign_in_and_mfa_pages(end_to_end_context):
|
||||
# See https://playwright.dev/python/docs/api/class-page#page-get-by-label
|
||||
# and https://playwright.dev/python/docs/locators#locate-by-css-or-xpath
|
||||
# for more information.
|
||||
email_address_input = page.get_by_label('Email address')
|
||||
password_input = page.get_by_label('Password')
|
||||
email_address_input = page.get_by_label("Email address")
|
||||
password_input = page.get_by_label("Password")
|
||||
csrf_token = page.locator('xpath=//input[@name="csrf_token"]')
|
||||
continue_button = page.get_by_role(
|
||||
'button',
|
||||
name=re.compile('Continue')
|
||||
)
|
||||
forgot_password_link = page.get_by_role(
|
||||
'link',
|
||||
name='Forgot your password?'
|
||||
)
|
||||
continue_button = page.get_by_role("button", name=re.compile("Continue"))
|
||||
forgot_password_link = page.get_by_role("link", name="Forgot your password?")
|
||||
|
||||
# Make sure form elements are visible and not visible as expected.
|
||||
expect(email_address_input).to_be_visible()
|
||||
@@ -104,33 +93,25 @@ def test_sign_in_and_mfa_pages(end_to_end_context):
|
||||
|
||||
# Make sure form elements are configured correctly with the right
|
||||
# attributes.
|
||||
expect(email_address_input).to_have_attribute('type', 'email')
|
||||
expect(password_input).to_have_attribute('type', 'password')
|
||||
expect(csrf_token).to_have_attribute('type', 'hidden')
|
||||
expect(continue_button).to_have_attribute('type', 'submit')
|
||||
expect(forgot_password_link).to_have_attribute(
|
||||
'href',
|
||||
'/forgot-password'
|
||||
)
|
||||
expect(email_address_input).to_have_attribute("type", "email")
|
||||
expect(password_input).to_have_attribute("type", "password")
|
||||
expect(csrf_token).to_have_attribute("type", "hidden")
|
||||
expect(continue_button).to_have_attribute("type", "submit")
|
||||
expect(forgot_password_link).to_have_attribute("href", "/forgot-password")
|
||||
|
||||
# Sign in to the site.
|
||||
email_address_input.fill(
|
||||
os.getenv('NOTIFY_E2E_TEST_EMAIL')
|
||||
)
|
||||
password_input.fill(os.getenv('NOTIFY_E2E_TEST_PASSWORD'))
|
||||
email_address_input.fill(os.getenv("NOTIFY_E2E_TEST_EMAIL"))
|
||||
password_input.fill(os.getenv("NOTIFY_E2E_TEST_PASSWORD"))
|
||||
continue_button.click()
|
||||
|
||||
# Wait for the next page to fully load.
|
||||
page.wait_for_load_state('domcontentloaded')
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# Check the page title exists and matches what we expect.
|
||||
expect(page).to_have_title(re.compile('Check your phone'))
|
||||
expect(page).to_have_title(re.compile("Check your phone"))
|
||||
|
||||
# Check for the sign in heading.
|
||||
sign_in_heading = page.get_by_role(
|
||||
'heading',
|
||||
name='Check your phone'
|
||||
)
|
||||
sign_in_heading = page.get_by_role("heading", name="Check your phone")
|
||||
expect(sign_in_heading).to_be_visible()
|
||||
|
||||
# Check for the sign in form elements.
|
||||
@@ -140,15 +121,11 @@ def test_sign_in_and_mfa_pages(end_to_end_context):
|
||||
# See https://playwright.dev/python/docs/api/class-page#page-get-by-label
|
||||
# and https://playwright.dev/python/docs/locators#locate-by-css-or-xpath
|
||||
# for more information.
|
||||
mfa_input = page.get_by_label('Text message code')
|
||||
mfa_input = page.get_by_label("Text message code")
|
||||
csrf_token = page.locator('xpath=//input[@name="csrf_token"]')
|
||||
continue_button = page.get_by_role(
|
||||
'button',
|
||||
name=re.compile('Continue')
|
||||
)
|
||||
continue_button = page.get_by_role("button", name=re.compile("Continue"))
|
||||
not_received_message_link = page.get_by_role(
|
||||
'link',
|
||||
name='Not received a text message?'
|
||||
"link", name="Not received a text message?"
|
||||
)
|
||||
|
||||
# Make sure form elements are visible and not visible as expected.
|
||||
@@ -160,14 +137,11 @@ def test_sign_in_and_mfa_pages(end_to_end_context):
|
||||
|
||||
# Make sure form elements are configured correctly with the right
|
||||
# attributes.
|
||||
expect(mfa_input).to_have_attribute('type', 'tel')
|
||||
expect(mfa_input).to_have_attribute('pattern', '[0-9]*')
|
||||
expect(csrf_token).to_have_attribute('type', 'hidden')
|
||||
expect(continue_button).to_have_attribute('type', 'submit')
|
||||
expect(not_received_message_link).to_have_attribute(
|
||||
'href',
|
||||
'/text-not-received'
|
||||
)
|
||||
expect(mfa_input).to_have_attribute("type", "tel")
|
||||
expect(mfa_input).to_have_attribute("pattern", "[0-9]*")
|
||||
expect(csrf_token).to_have_attribute("type", "hidden")
|
||||
expect(continue_button).to_have_attribute("type", "submit")
|
||||
expect(not_received_message_link).to_have_attribute("href", "/text-not-received")
|
||||
|
||||
# Enter MFA code and continue.
|
||||
# TODO: Revisit this at a later point in time.
|
||||
|
||||
Reference in New Issue
Block a user