mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Merge branch 'main' of https://github.com/GSA/notifications-admin into notify-678
This commit is contained in:
@@ -517,7 +517,7 @@ def notification_json(
|
||||
"notification_type": template_type,
|
||||
"reply_to_text": reply_to_text,
|
||||
"client_reference": client_reference,
|
||||
"created_by_name": created_by_name,
|
||||
"created_by_name": None,
|
||||
}
|
||||
for i in range(rows)
|
||||
],
|
||||
|
||||
35
tests/app/main/test_beta_redirect.py
Normal file
35
tests/app/main/test_beta_redirect.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from flask import current_app
|
||||
|
||||
from app import create_beta_url
|
||||
|
||||
|
||||
def test_create_beta_url():
|
||||
url_for_redirect = create_beta_url("https://notify.gov/using-notify/get-started")
|
||||
assert url_for_redirect == "https://beta.notify.gov/using-notify/get-started"
|
||||
|
||||
|
||||
def test_no_redirect_notify_to_beta_non_production(monkeypatch, client_request):
|
||||
monkeypatch.setitem(current_app.config, "NOTIFY_ENVIRONMENT", "development")
|
||||
assert current_app.config["NOTIFY_ENVIRONMENT"] == "development"
|
||||
|
||||
client_request.get_response_from_url(
|
||||
"https://notify.gov/using-notify/get-started", _expected_status=200
|
||||
)
|
||||
|
||||
|
||||
def test_redirect_notify_to_beta(monkeypatch, client_request):
|
||||
monkeypatch.setitem(current_app.config, "NOTIFY_ENVIRONMENT", "production")
|
||||
assert current_app.config["NOTIFY_ENVIRONMENT"] == "production"
|
||||
|
||||
client_request.get_response_from_url(
|
||||
"https://notify.gov/using-notify/get-started", _expected_status=302
|
||||
)
|
||||
|
||||
|
||||
def test_no_redirect_beta_notify_to_beta(monkeypatch, client_request):
|
||||
monkeypatch.setitem(current_app.config, "NOTIFY_ENVIRONMENT", "production")
|
||||
assert current_app.config["NOTIFY_ENVIRONMENT"] == "production"
|
||||
|
||||
client_request.get_response_from_url(
|
||||
"https://beta.notify.gov/using-notify/get-started", _expected_status=200
|
||||
)
|
||||
@@ -5,7 +5,6 @@ from notifications_python_client.errors import HTTPError
|
||||
|
||||
from app.utils.user import is_gov_user
|
||||
from tests import organization_json
|
||||
from tests.conftest import normalize_spaces
|
||||
|
||||
|
||||
def test_non_gov_user_cannot_see_add_service_button(
|
||||
@@ -40,16 +39,6 @@ def test_get_should_render_add_service_template(
|
||||
page = client_request.get("main.add_service")
|
||||
assert page.select_one("h1").text.strip() == "About your service"
|
||||
assert page.select_one("input[name=name]").get("value") is None
|
||||
assert [label.text.strip() for label in page.select(".usa-radio label")] == [
|
||||
"Federal government",
|
||||
"State government",
|
||||
"Other",
|
||||
]
|
||||
assert [radio["value"] for radio in page.select(".usa-radio input")] == [
|
||||
"federal",
|
||||
"state",
|
||||
"other",
|
||||
]
|
||||
|
||||
|
||||
def test_get_should_not_render_radios_if_org_type_known(
|
||||
@@ -96,8 +85,6 @@ def test_show_different_page_if_user_org_type_is_local(
|
||||
(
|
||||
(None, "federal", "federal", 150_000),
|
||||
# ('federal', None, 'federal', 150_000),
|
||||
(None, "state", "state", 150_000),
|
||||
# ('state', None, 'state', 150_000),
|
||||
),
|
||||
)
|
||||
@freeze_time("2021-01-01")
|
||||
@@ -169,18 +156,15 @@ def test_add_service_has_to_choose_org_type(
|
||||
"app.organizations_client.get_organization_by_domain",
|
||||
return_value=None,
|
||||
)
|
||||
page = client_request.post(
|
||||
client_request.post(
|
||||
"main.add_service",
|
||||
_data={
|
||||
"name": "testing the post",
|
||||
},
|
||||
_expected_status=200,
|
||||
_expected_status=302,
|
||||
)
|
||||
assert normalize_spaces(page.select_one(".usa-error-message").text) == (
|
||||
"Error: Select the type of organization"
|
||||
)
|
||||
assert mock_create_service.called is False
|
||||
assert mock_create_service_template.called is False
|
||||
assert mock_create_service.called is True
|
||||
assert mock_create_service_template.called is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -253,17 +237,6 @@ def test_should_add_service_and_redirect_to_dashboard_when_existing_service(
|
||||
),
|
||||
)
|
||||
assert mock_get_services.called
|
||||
mock_create_service.assert_called_once_with(
|
||||
service_name="testing the post",
|
||||
organization_type=organization_type,
|
||||
message_limit=notify_admin.config["DEFAULT_SERVICE_LIMIT"],
|
||||
restricted=True,
|
||||
user_id=api_user_active["id"],
|
||||
email_from="testing.the.post",
|
||||
)
|
||||
assert len(mock_create_service_template.call_args_list) == 0
|
||||
with client_request.session_transaction() as session:
|
||||
assert session["service_id"] == 101
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -659,7 +659,7 @@ def test_should_show_upcoming_jobs_on_dashboard(
|
||||
assert normalize_spaces(page.select_one("main h2").text) == ("In the next few days")
|
||||
|
||||
assert normalize_spaces(page.select_one("a.banner-dashboard").text) == (
|
||||
"2 files waiting to send " "sending starts today at 11:09 UTC"
|
||||
"2 files waiting to send " "- sending starts today at 11:09 UTC"
|
||||
)
|
||||
|
||||
assert page.select_one("a.banner-dashboard")["href"] == url_for(
|
||||
|
||||
@@ -294,26 +294,6 @@ def test_email_branding_preview(
|
||||
assert mock_get_email_branding.called is email_branding_retrieved
|
||||
|
||||
|
||||
def test_font_preload(
|
||||
client_request,
|
||||
mock_get_service_and_organization_counts,
|
||||
):
|
||||
client_request.logout()
|
||||
page = client_request.get("main.index", _test_page_title=False)
|
||||
|
||||
preload_tags = page.select(
|
||||
'link[rel=preload][as=font][type="font/woff2"][crossorigin]'
|
||||
)
|
||||
|
||||
assert (
|
||||
len(preload_tags) == 4
|
||||
), "Run `npm run build` to copy fonts into app/static/fonts/"
|
||||
|
||||
for element in preload_tags:
|
||||
assert element["href"].startswith("https://static.example.com/fonts/")
|
||||
assert element["href"].endswith(".woff2")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("current_date, expected_rate", (("2022-05-01", "1.72"),))
|
||||
@pytest.mark.skip(reason="Currently hidden for TTS")
|
||||
def test_sms_price(
|
||||
|
||||
@@ -735,7 +735,7 @@ def test_platform_admin_displays_stats_in_right_boxes_and_with_correct_styling(
|
||||
assert (
|
||||
"1 technical failures"
|
||||
in page.find_all("div", class_="grid-col-6")[1]
|
||||
.find("div", class_="big-number-status-failing")
|
||||
.find("div", class_="big-number-status--failing")
|
||||
.text
|
||||
)
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ def _get_notifications_csv(
|
||||
rows=1,
|
||||
with_links=False,
|
||||
job_id=fake_uuid,
|
||||
created_by_name=None,
|
||||
created_by_email_address=None,
|
||||
created_by_name="Fake Person",
|
||||
created_by_email_address="FakePerson@fake.gov",
|
||||
):
|
||||
def _get(
|
||||
service_id,
|
||||
@@ -121,12 +121,22 @@ def test_generate_notifications_csv_without_job(
|
||||
phone_number
|
||||
2028675309
|
||||
""",
|
||||
["Row number", "phone_number", "Template", "Type", "Job", "Status", "Time"],
|
||||
[
|
||||
"Row number",
|
||||
"phone_number",
|
||||
"Template",
|
||||
"Type",
|
||||
"Sent by",
|
||||
"Job",
|
||||
"Status",
|
||||
"Time",
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"2028675309",
|
||||
"foo",
|
||||
"sms",
|
||||
"Fake Person",
|
||||
"bar.csv",
|
||||
"Delivered",
|
||||
"1943-04-19 12:00:00",
|
||||
@@ -145,6 +155,7 @@ def test_generate_notifications_csv_without_job(
|
||||
"c",
|
||||
"Template",
|
||||
"Type",
|
||||
"Sent by",
|
||||
"Job",
|
||||
"Status",
|
||||
"Time",
|
||||
@@ -157,6 +168,7 @@ def test_generate_notifications_csv_without_job(
|
||||
"🦀",
|
||||
"foo",
|
||||
"sms",
|
||||
"Fake Person",
|
||||
"bar.csv",
|
||||
"Delivered",
|
||||
"1943-04-19 12:00:00",
|
||||
@@ -175,6 +187,7 @@ def test_generate_notifications_csv_without_job(
|
||||
"c",
|
||||
"Template",
|
||||
"Type",
|
||||
"Sent by",
|
||||
"Job",
|
||||
"Status",
|
||||
"Time",
|
||||
@@ -187,6 +200,7 @@ def test_generate_notifications_csv_without_job(
|
||||
"🦀",
|
||||
"foo",
|
||||
"sms",
|
||||
"Fake Person",
|
||||
"bar.csv",
|
||||
"Delivered",
|
||||
"1943-04-19 12:00:00",
|
||||
@@ -209,6 +223,7 @@ def test_generate_notifications_csv_returns_correct_csv_file(
|
||||
csv_content = generate_notifications_csv(
|
||||
service_id="1234", job_id=fake_uuid, template_type="sms"
|
||||
)
|
||||
|
||||
csv_file = DictReader(StringIO("\n".join(csv_content)))
|
||||
assert csv_file.fieldnames == expected_column_headers
|
||||
assert next(csv_file) == dict(zip(expected_column_headers, expected_1st_row))
|
||||
|
||||
@@ -9,6 +9,7 @@ from uuid import UUID, uuid4
|
||||
|
||||
import pytest
|
||||
from bs4 import BeautifulSoup
|
||||
from dotenv import load_dotenv
|
||||
from flask import Flask, url_for
|
||||
from notifications_python_client.errors import HTTPError
|
||||
from notifications_utils.url_safe_token import generate_token
|
||||
@@ -33,6 +34,8 @@ from . import (
|
||||
user_json,
|
||||
)
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
class ElementNotFound(Exception):
|
||||
pass
|
||||
@@ -2392,6 +2395,7 @@ def _client(notify_admin):
|
||||
Do not use this fixture directly – use `client_request` instead
|
||||
"""
|
||||
with notify_admin.test_request_context(), notify_admin.test_client() as client:
|
||||
client.allow_subdomain_redirects = True
|
||||
yield client
|
||||
|
||||
|
||||
@@ -3661,18 +3665,7 @@ def login_for_end_to_end_testing(browser):
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def end_to_end_context(browser):
|
||||
# Create a context with HTTP Authentication credentials for Playwright E2E
|
||||
# tests, if the environment variables exist.
|
||||
if os.getenv("NOTIFY_E2E_TEST_HTTP_AUTH_USER"):
|
||||
context = browser.new_context(
|
||||
http_credentials={
|
||||
"username": os.getenv("NOTIFY_E2E_TEST_HTTP_AUTH_USER"),
|
||||
"password": os.getenv("NOTIFY_E2E_TEST_HTTP_AUTH_PASSWORD"),
|
||||
}
|
||||
)
|
||||
else:
|
||||
context = browser.new_context()
|
||||
|
||||
context = browser.new_context()
|
||||
yield context
|
||||
|
||||
|
||||
|
||||
@@ -2,50 +2,45 @@ import datetime
|
||||
import os
|
||||
import re
|
||||
|
||||
import pytest
|
||||
from playwright.sync_api import expect
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Not authenticating test users.")
|
||||
def test_accounts_page(end_to_end_authenticated_context):
|
||||
def _bypass_sign_in(end_to_end_context):
|
||||
# Open a new page and go to the staging site.
|
||||
page = end_to_end_authenticated_context.new_page()
|
||||
page = end_to_end_context.new_page()
|
||||
|
||||
accounts_uri = "{}accounts".format(os.getenv("NOTIFY_E2E_TEST_URI"))
|
||||
page.goto(os.getenv("NOTIFY_E2E_TEST_URI"))
|
||||
|
||||
page.goto(accounts_uri)
|
||||
sign_in_button = page.get_by_role("link", name="Sign in")
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
# Test trying to sign in. Because we are loading the email and password
|
||||
sign_in_button.click()
|
||||
|
||||
# Wait for the next page to fully load.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
return page
|
||||
|
||||
|
||||
def test_add_new_service_workflow(end_to_end_context):
|
||||
# page = end_to_end_context.new_page()
|
||||
page = _bypass_sign_in(end_to_end_context)
|
||||
page.goto(os.getenv("NOTIFY_E2E_TEST_URI"))
|
||||
|
||||
# sign_in_button = page.get_by_role("link", name="Sign in")
|
||||
#
|
||||
# Test trying to sign in. Because we are loading the email and password
|
||||
# sign_in_button.click()
|
||||
#
|
||||
# Wait for the next page to fully load.
|
||||
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"))
|
||||
|
||||
# Check for the sign in heading.
|
||||
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")
|
||||
)
|
||||
|
||||
expect(add_service_button).to_be_visible()
|
||||
|
||||
|
||||
@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,
|
||||
browser_type=end_to_end_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"))
|
||||
|
||||
page.goto(accounts_uri)
|
||||
@@ -100,7 +95,11 @@ def test_add_new_service_workflow(end_to_end_authenticated_context):
|
||||
|
||||
# Fill in the form.
|
||||
service_name_input.fill(new_service_name)
|
||||
federal_radio_button.click()
|
||||
expect(federal_radio_button).to_be_enabled()
|
||||
# Trying to click directly on the radio button resulted in a "not in viewport error" and this is the
|
||||
# suggested workaround. Googling, the reason seems to be that there might be some (invisible?) css positioned
|
||||
# above the radio button itself.
|
||||
page.click("text='Federal government'")
|
||||
|
||||
# Click on add service.
|
||||
add_service_button.click()
|
||||
@@ -112,3 +111,22 @@ def test_add_new_service_workflow(end_to_end_authenticated_context):
|
||||
service_heading = page.get_by_text(new_service_name)
|
||||
expect(service_heading).to_be_visible()
|
||||
expect(page).to_have_title(re.compile(new_service_name))
|
||||
|
||||
page.click("text='Settings'")
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
page.click("text='Delete this service'")
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
page.click("text='Yes, delete'")
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
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"))
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
import pytest
|
||||
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 = end_to_end_context.browser.new_page()
|
||||
page.goto(os.getenv("NOTIFY_E2E_TEST_URI"))
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
@@ -49,118 +48,120 @@ def test_landing_page(end_to_end_context):
|
||||
).to_be_visible()
|
||||
|
||||
|
||||
@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"))
|
||||
|
||||
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")
|
||||
|
||||
# Check the page title exists and matches what we expect.
|
||||
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")
|
||||
expect(sign_in_heading).to_be_visible()
|
||||
|
||||
# Check for the sign in form elements.
|
||||
# NOTE: Playwright cannot find input elements by role and recommends using
|
||||
# get_by_label() instead; however, hidden form elements do not have
|
||||
# labels associated with them, hence the XPath!
|
||||
# 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")
|
||||
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?")
|
||||
|
||||
# Make sure form elements are visible and not visible as expected.
|
||||
expect(email_address_input).to_be_visible()
|
||||
expect(password_input).to_be_visible()
|
||||
expect(continue_button).to_be_visible()
|
||||
expect(forgot_password_link).to_be_visible()
|
||||
|
||||
expect(csrf_token).to_be_hidden()
|
||||
|
||||
# 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")
|
||||
|
||||
# Sign in to the site.
|
||||
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")
|
||||
|
||||
# Check the page title exists and matches what we expect.
|
||||
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")
|
||||
expect(sign_in_heading).to_be_visible()
|
||||
|
||||
# Check for the sign in form elements.
|
||||
# NOTE: Playwright cannot find input elements by role and recommends using
|
||||
# get_by_label() instead; however, hidden form elements do not have
|
||||
# labels associated with them, hence the XPath!
|
||||
# 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")
|
||||
csrf_token = page.locator('xpath=//input[@name="csrf_token"]')
|
||||
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?"
|
||||
)
|
||||
|
||||
# Make sure form elements are visible and not visible as expected.
|
||||
expect(mfa_input).to_be_visible()
|
||||
expect(continue_button).to_be_visible()
|
||||
expect(not_received_message_link).to_be_visible()
|
||||
|
||||
expect(csrf_token).to_be_hidden()
|
||||
|
||||
# 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")
|
||||
|
||||
# Enter MFA code and continue.
|
||||
# TODO: Revisit this at a later point in time.
|
||||
# totp = pyotp.TOTP(
|
||||
# os.getenv('MFA_TOTP_SECRET'),
|
||||
# digits=int(os.getenv('MFA_TOTP_LENGTH'))
|
||||
# )
|
||||
|
||||
# mfa_input.fill('totp.now()')
|
||||
# continue_button.click()
|
||||
|
||||
# # Check to make sure that we've arrived at the next page.
|
||||
# page.wait_for_load_state('domcontentloaded')
|
||||
|
||||
# # Check that no MFA code error happened.
|
||||
# code_not_found_error = page.get_by_text('Code not found')
|
||||
# expect(code_not_found_error).to_have_count(0)
|
||||
|
||||
# # Check the page title exists and matches what we expect.
|
||||
# # This could be either the Dashboard of a service if there is only
|
||||
# # one, or choosing a service if there are multiple.
|
||||
# expect(page).to_have_title(re.compile('Dashboard|Choose service'))
|
||||
# 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"))
|
||||
# print(f"test_sign_in_and_mfa_pages initial {page}")
|
||||
#
|
||||
# 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")
|
||||
#
|
||||
# # Check the page title exists and matches what we expect.
|
||||
# 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")
|
||||
# expect(sign_in_heading).to_be_visible()
|
||||
#
|
||||
# # Check for the sign in form elements.
|
||||
# # NOTE: Playwright cannot find input elements by role and recommends using
|
||||
# # get_by_label() instead; however, hidden form elements do not have
|
||||
# # labels associated with them, hence the XPath!
|
||||
# # 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")
|
||||
# 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?")
|
||||
#
|
||||
# # Make sure form elements are visible and not visible as expected.
|
||||
# expect(email_address_input).to_be_visible()
|
||||
# expect(password_input).to_be_visible()
|
||||
# expect(continue_button).to_be_visible()
|
||||
# expect(forgot_password_link).to_be_visible()
|
||||
#
|
||||
# expect(csrf_token).to_be_hidden()
|
||||
#
|
||||
# # 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")
|
||||
#
|
||||
# # Sign in to the site.
|
||||
# email_address_input.fill(os.getenv("NOTIFY_E2E_TEST_EMAIL"))
|
||||
# password_input.fill(os.getenv("NOTIFY_E2E_TEST_PASSWORD"))
|
||||
# print(f"email and password {os.getenv('NOTIFY_E2E_TEST_EMAIL')} {os.getenv('NOTIFY_E2E_TEST_PASSWORD')}")
|
||||
# continue_button.click()
|
||||
#
|
||||
# # Wait for the next page to fully load.
|
||||
# page.wait_for_load_state("domcontentloaded")
|
||||
#
|
||||
# # Check the page title exists and matches what we expect.
|
||||
# print(f"test_sign_in_and_mfa_pages finally is {page}")
|
||||
# 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")
|
||||
# expect(sign_in_heading).to_be_visible()
|
||||
#
|
||||
# # Check for the sign in form elements.
|
||||
# # NOTE: Playwright cannot find input elements by role and recommends using
|
||||
# # get_by_label() instead; however, hidden form elements do not have
|
||||
# # labels associated with them, hence the XPath!
|
||||
# # 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")
|
||||
# csrf_token = page.locator('xpath=//input[@name="csrf_token"]')
|
||||
# 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?"
|
||||
# )
|
||||
#
|
||||
# # Make sure form elements are visible and not visible as expected.
|
||||
# expect(mfa_input).to_be_visible()
|
||||
# expect(continue_button).to_be_visible()
|
||||
# expect(not_received_message_link).to_be_visible()
|
||||
#
|
||||
# expect(csrf_token).to_be_hidden()
|
||||
#
|
||||
# # 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")
|
||||
#
|
||||
# # Enter MFA code and continue.
|
||||
# # TODO: Revisit this at a later point in time.
|
||||
# # totp = pyotp.TOTP(
|
||||
# # os.getenv('MFA_TOTP_SECRET'),
|
||||
# # digits=int(os.getenv('MFA_TOTP_LENGTH'))
|
||||
# # )
|
||||
#
|
||||
# # mfa_input.fill('totp.now()')
|
||||
# # continue_button.click()
|
||||
#
|
||||
# # # Check to make sure that we've arrived at the next page.
|
||||
# # page.wait_for_load_state('domcontentloaded')
|
||||
#
|
||||
# # # Check that no MFA code error happened.
|
||||
# # code_not_found_error = page.get_by_text('Code not found')
|
||||
# # expect(code_not_found_error).to_have_count(0)
|
||||
#
|
||||
# # # Check the page title exists and matches what we expect.
|
||||
# # # This could be either the Dashboard of a service if there is only
|
||||
# # # one, or choosing a service if there are multiple.
|
||||
# # expect(page).to_have_title(re.compile('Dashboard|Choose service'))
|
||||
|
||||
Reference in New Issue
Block a user