mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Merge main fix conflicts
This commit is contained in:
@@ -48,7 +48,6 @@ def test_form_class_not_mutated(notify_admin):
|
||||
(False, "phone number", "sms", "2028675309", None),
|
||||
(False, "phone number", "sms", "+1 (202) 867-5309", None),
|
||||
(True, "phone number", "sms", "+123", "Not enough digits"),
|
||||
(True, "phone number", "sms", "+44(0)7900 900-123", None),
|
||||
(True, "phone number", "sms", "+1-2345-678890", None),
|
||||
(False, "anything else", "sms", "", "Cannot be empty"),
|
||||
(False, "anything else", "email", "", "Cannot be empty"),
|
||||
|
||||
@@ -133,7 +133,6 @@ def test_service_navigation_for_org_user(
|
||||
(
|
||||
"Send messages",
|
||||
"Sent messages",
|
||||
"Usage",
|
||||
),
|
||||
200,
|
||||
),
|
||||
|
||||
@@ -363,7 +363,7 @@ def test_should_show_back_to_service_if_user_belongs_to_service(
|
||||
):
|
||||
mock_get_service.return_value = service_one
|
||||
expected_page_text = (
|
||||
"Test Service Switch service " "Send messages " "Dashboard " "Usage"
|
||||
"Test Service Switch service " "Send messages " "Dashboard"
|
||||
) # TODO: set sidebar variables in common test module
|
||||
|
||||
page = client_request.get(
|
||||
|
||||
@@ -40,7 +40,7 @@ from tests.conftest import (
|
||||
{"message_type": "sms"},
|
||||
"/sms.json",
|
||||
7,
|
||||
"Text messages",
|
||||
"Text message",
|
||||
),
|
||||
(
|
||||
create_active_caseworking_user(),
|
||||
|
||||
@@ -354,10 +354,9 @@ def test_inbound_messages_shows_count_of_messages_when_there_are_no_messages(
|
||||
"(202) 867-5300 message-2 1 hour ago",
|
||||
"(202) 867-5300 message-3 1 hour ago",
|
||||
"(202) 867-5302 message-4 3 hours ago",
|
||||
"+33 1 12 34 56 78 message-5 5 hours ago",
|
||||
"+33(0)1 12345678 message-5 5 hours ago",
|
||||
"(202) 555-0104 message-6 7 hours ago",
|
||||
"(202) 555-0104 message-7 9 hours ago",
|
||||
"+682 12345 message-8 9 hours ago",
|
||||
]
|
||||
),
|
||||
)
|
||||
@@ -519,10 +518,10 @@ def test_download_inbox(
|
||||
"(202) 867-5300,message-2,07-01-2016 10:59 US/Eastern\r\n"
|
||||
"(202) 867-5300,message-3,07-01-2016 10:59 US/Eastern\r\n"
|
||||
"(202) 867-5302,message-4,07-01-2016 08:59 US/Eastern\r\n"
|
||||
"+33 1 12 34 56 78,message-5,07-01-2016 06:59 US/Eastern\r\n"
|
||||
"+33(0)1 12345678,message-5,07-01-2016 06:59 US/Eastern\r\n"
|
||||
"(202) 555-0104,message-6,07-01-2016 04:59 US/Eastern\r\n"
|
||||
"(202) 555-0104,message-7,07-01-2016 02:59 US/Eastern\r\n"
|
||||
"+682 12345,message-8,07-01-2016 02:59 US/Eastern\r\n"
|
||||
"+68212345,message-8,07-01-2016 02:59 US/Eastern\r\n"
|
||||
)
|
||||
|
||||
|
||||
@@ -655,7 +654,7 @@ def test_should_not_show_recent_templates_on_dashboard_if_only_one_template_used
|
||||
expected_count = stats[0]["count"]
|
||||
assert expected_count == 50
|
||||
assert normalize_spaces(page.select_one("#total-sms .big-number-smaller").text) == (
|
||||
"{} text messages sent".format(expected_count)
|
||||
"{} text messages sent in the last seven days".format(expected_count)
|
||||
)
|
||||
|
||||
|
||||
@@ -1058,16 +1057,9 @@ def test_usage_page_monthly_breakdown(
|
||||
monthly_breakdown = normalize_spaces(page.find("table").text)
|
||||
|
||||
assert "January" in monthly_breakdown
|
||||
|
||||
assert "October" in monthly_breakdown
|
||||
assert "February" in monthly_breakdown
|
||||
assert "$16.40" in monthly_breakdown
|
||||
assert "140 free text messages" in monthly_breakdown
|
||||
assert "960 text messages at 1.65p" in monthly_breakdown
|
||||
assert "33 text messages at 1.70p" in monthly_breakdown
|
||||
|
||||
assert "March" in monthly_breakdown
|
||||
assert "$20.91" in monthly_breakdown
|
||||
assert "1,230 text messages at 1.70p" in monthly_breakdown
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -1818,15 +1810,8 @@ def test_service_dashboard_shows_usage(
|
||||
|
||||
usage_table = page.find("table", class_="usage-table")
|
||||
|
||||
# Check if the "Usage" table exists
|
||||
assert usage_table is not None
|
||||
|
||||
table_rows = usage_table.find_all("tbody")[0].find_all("tr")
|
||||
|
||||
assert len(table_rows) == 1
|
||||
|
||||
assert "500" in table_rows[0].find_all("td")[0].text
|
||||
assert "9500" in table_rows[0].find_all("td")[1].text
|
||||
# Check if the "Usage" table doesn't exist
|
||||
assert usage_table is None
|
||||
|
||||
|
||||
def test_service_dashboard_shows_free_allowance(
|
||||
@@ -1861,7 +1846,7 @@ def test_service_dashboard_shows_free_allowance(
|
||||
|
||||
usage_text = normalize_spaces(page.select_one("[data-key=usage]").text)
|
||||
assert "spent on text messages" not in usage_text
|
||||
assert "Daily Usage Remaining 1,000 249,000" in usage_text
|
||||
assert "Daily Sent Remaining 1,000 249,000" in usage_text
|
||||
|
||||
|
||||
def test_service_dashboard_shows_batched_jobs(
|
||||
|
||||
@@ -320,15 +320,14 @@ def test_should_show_old_job(
|
||||
service_id=SERVICE_ONE_ID,
|
||||
job_id=fake_uuid,
|
||||
)
|
||||
assert not page.select(".pill")
|
||||
assert not page.select("p.hint")
|
||||
assert not page.select("a[download]")
|
||||
assert page.select_one("tbody").text.strip() == expected_message
|
||||
assert [
|
||||
normalize_spaces(column.text) for column in page.select("main .grid-col-3")
|
||||
normalize_spaces(column.text) for column in page.select("main .pill .pill-item")
|
||||
] == [
|
||||
"1 total text messages",
|
||||
"1 pending",
|
||||
"1 pending text message",
|
||||
"0 delivered text messages",
|
||||
"0 failed text messages",
|
||||
]
|
||||
|
||||
@@ -975,11 +975,11 @@ def test_upload_valid_csv_shows_preview_and_table(
|
||||
for row_index, row in enumerate(
|
||||
[
|
||||
(
|
||||
'<td class="table-field-left-aligned"> <div class=""> 2028675301 </div> </td>',
|
||||
'<td class="table-field-left-aligned"> <div class=""> A </div> </td>',
|
||||
'<td class="table-field-left-aligned"> <div> 2028675301 </div> </td>',
|
||||
'<td class="table-field-left-aligned"> <div> A </div> </td>',
|
||||
(
|
||||
'<td class="table-field-left-aligned"> '
|
||||
'<div class="table-field-status-default"> '
|
||||
"<div> "
|
||||
"<ul> "
|
||||
"<li>foo</li> <li>foo</li> <li>foo</li> "
|
||||
"</ul> "
|
||||
@@ -988,11 +988,11 @@ def test_upload_valid_csv_shows_preview_and_table(
|
||||
),
|
||||
),
|
||||
(
|
||||
'<td class="table-field-left-aligned"> <div class=""> 2028675302 </div> </td>',
|
||||
'<td class="table-field-left-aligned"> <div class=""> B </div> </td>',
|
||||
'<td class="table-field-left-aligned"> <div> 2028675302 </div> </td>',
|
||||
'<td class="table-field-left-aligned"> <div> B </div> </td>',
|
||||
(
|
||||
'<td class="table-field-left-aligned"> '
|
||||
'<div class="table-field-status-default"> '
|
||||
"<div> "
|
||||
"<ul> "
|
||||
"<li>foo</li> <li>foo</li> <li>foo</li> "
|
||||
"</ul> "
|
||||
@@ -1001,11 +1001,11 @@ def test_upload_valid_csv_shows_preview_and_table(
|
||||
),
|
||||
),
|
||||
(
|
||||
'<td class="table-field-left-aligned"> <div class=""> 2028675303 </div> </td>',
|
||||
'<td class="table-field-left-aligned"> <div class=""> C </div> </td>',
|
||||
'<td class="table-field-left-aligned"> <div> 2028675303 </div> </td>',
|
||||
'<td class="table-field-left-aligned"> <div> C </div> </td>',
|
||||
(
|
||||
'<td class="table-field-left-aligned"> '
|
||||
'<div class="table-field-status-default"> '
|
||||
"<div> "
|
||||
"<ul> "
|
||||
"<li>foo</li> <li>foo</li> "
|
||||
"</ul> "
|
||||
|
||||
@@ -1868,7 +1868,8 @@ def test_should_show_message_before_redacting_template(
|
||||
)
|
||||
|
||||
assert (
|
||||
"Are you sure you want to hide personalization after sending?"
|
||||
"Are you sure you want to hide all personalized and conditional"
|
||||
" content after sending for increased privacy protection?"
|
||||
) in page.select(".banner-dangerous")[0].text
|
||||
|
||||
form = page.select(".banner-dangerous form")[0]
|
||||
|
||||
@@ -401,7 +401,7 @@ def test_navigation_urls(
|
||||
assert [a["href"] for a in page.select(".nav a")] == [
|
||||
"/services/{}/templates".format(SERVICE_ONE_ID),
|
||||
"/services/{}".format(SERVICE_ONE_ID),
|
||||
"/services/{}/usage".format(SERVICE_ONE_ID),
|
||||
# "/services/{}/usage".format(SERVICE_ONE_ID),
|
||||
# "/services/{}/users".format(SERVICE_ONE_ID),
|
||||
# "/services/{}/service-settings".format(SERVICE_ONE_ID),
|
||||
# '/services/{}/api'.format(SERVICE_ONE_ID),
|
||||
|
||||
188
tests/end_to_end/test_create_new_template.py
Normal file
188
tests/end_to_end/test_create_new_template.py
Normal file
@@ -0,0 +1,188 @@
|
||||
import datetime
|
||||
import os
|
||||
import re
|
||||
import uuid
|
||||
|
||||
from playwright.sync_api import expect
|
||||
|
||||
E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
|
||||
|
||||
|
||||
def _setup(page):
|
||||
# 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=page.context.browser.browser_type.name,
|
||||
)
|
||||
|
||||
page.goto(f"{E2E_TEST_URI}/accounts")
|
||||
|
||||
# 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"))
|
||||
|
||||
# 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()
|
||||
|
||||
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
|
||||
# delete service workflow.
|
||||
expect(existing_service_link).to_have_count(0)
|
||||
|
||||
# Click on add a new service.
|
||||
add_service_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# Check for the sign in heading.
|
||||
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.
|
||||
service_name_input = page.locator('xpath=//input[@name="name"]')
|
||||
add_service_button = page.get_by_role("button", name=re.compile("Add service"))
|
||||
|
||||
expect(service_name_input).to_be_visible()
|
||||
expect(add_service_button).to_be_visible()
|
||||
|
||||
# Fill in the form.
|
||||
service_name_input.fill(new_service_name)
|
||||
|
||||
# Click on add service.
|
||||
add_service_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# Check for the service name title and heading.
|
||||
service_heading = page.get_by_text(new_service_name, exact=True)
|
||||
|
||||
expect(service_heading).to_be_visible()
|
||||
expect(page).to_have_title(re.compile(new_service_name))
|
||||
|
||||
return new_service_name
|
||||
|
||||
|
||||
def create_new_template(page):
|
||||
|
||||
current_service_link = page.get_by_text("Current service")
|
||||
expect(current_service_link).to_be_visible()
|
||||
current_service_link.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
send_messages_button = page.get_by_role("link", name="Send messages")
|
||||
expect(send_messages_button).to_be_visible()
|
||||
send_messages_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
create_template_button = page.get_by_role("button", name="New template")
|
||||
expect(create_template_button).to_be_visible()
|
||||
create_template_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
start_with_a_blank_template_radio = page.get_by_text("Start with a blank template")
|
||||
expect(start_with_a_blank_template_radio).to_be_visible()
|
||||
start_with_a_blank_template_radio.click()
|
||||
|
||||
continue_button = page.get_by_role("button", name="Continue")
|
||||
|
||||
# continue_button = page.get_by_text("Continue")
|
||||
expect(continue_button).to_be_visible()
|
||||
continue_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
template_name_input = page.get_by_text("Template name")
|
||||
expect(template_name_input).to_be_visible()
|
||||
template_name = str(uuid.uuid4())
|
||||
template_name_input.fill(template_name)
|
||||
message_input = page.get_by_role("textbox", name="Message")
|
||||
expect(message_input).to_be_visible()
|
||||
message = "Test message for e2e test"
|
||||
message_input.fill(message)
|
||||
|
||||
save_button = page.get_by_text("Save")
|
||||
expect(save_button).to_be_visible()
|
||||
save_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
use_this_template_button = page.get_by_text("Use this template")
|
||||
expect(use_this_template_button).to_be_visible()
|
||||
use_this_template_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
use_my_phone_number_link = page.get_by_text("Use my phone number")
|
||||
expect(use_my_phone_number_link).to_be_visible()
|
||||
use_my_phone_number_link.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
preview_button = page.get_by_text("Preview")
|
||||
expect(preview_button).to_be_visible()
|
||||
preview_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# We are not going to send the message for this test, we just want to confirm
|
||||
# that the template has been created and we are now seeing the message from the
|
||||
# template in the preview.
|
||||
assert "Test message for e2e test" in page.content()
|
||||
|
||||
|
||||
def test_create_new_template(authenticated_page):
|
||||
page = authenticated_page
|
||||
|
||||
_setup(page)
|
||||
|
||||
create_new_template(page)
|
||||
|
||||
_teardown(page)
|
||||
|
||||
|
||||
def _teardown(page):
|
||||
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"))
|
||||
339
tests/end_to_end/test_send_message_from_existing_template.py
Normal file
339
tests/end_to_end/test_send_message_from_existing_template.py
Normal file
@@ -0,0 +1,339 @@
|
||||
import datetime
|
||||
import os
|
||||
import re
|
||||
import uuid
|
||||
|
||||
from playwright.sync_api import expect
|
||||
|
||||
E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
|
||||
|
||||
|
||||
def _setup(page):
|
||||
# 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=page.context.browser.browser_type.name,
|
||||
)
|
||||
|
||||
page.goto(f"{E2E_TEST_URI}/accounts")
|
||||
|
||||
# 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"))
|
||||
|
||||
# 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()
|
||||
|
||||
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
|
||||
# delete service workflow.
|
||||
expect(existing_service_link).to_have_count(0)
|
||||
|
||||
# Click on add a new service.
|
||||
add_service_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# Check for the sign in heading.
|
||||
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.
|
||||
service_name_input = page.locator('xpath=//input[@name="name"]')
|
||||
add_service_button = page.get_by_role("button", name=re.compile("Add service"))
|
||||
|
||||
expect(service_name_input).to_be_visible()
|
||||
expect(add_service_button).to_be_visible()
|
||||
|
||||
# Fill in the form.
|
||||
service_name_input.fill(new_service_name)
|
||||
|
||||
# Click on add service.
|
||||
add_service_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# Check for the service name title and heading.
|
||||
service_heading = page.get_by_text(new_service_name, exact=True)
|
||||
|
||||
expect(service_heading).to_be_visible()
|
||||
expect(page).to_have_title(re.compile(new_service_name))
|
||||
|
||||
return new_service_name
|
||||
|
||||
|
||||
def handle_no_existing_template_case(page):
|
||||
"""
|
||||
This is the test path for local development. Developers have their own
|
||||
databases and typically they have service or two already created, which
|
||||
means they won't see the "Example text message template" which is done
|
||||
as an introduction. Instead they will see "Create your first template".
|
||||
Note that this test goes all the way through sending and downloading the
|
||||
report and verifying the phone number, etc. in the report. This is because
|
||||
developer systems are fully connected to AWS.
|
||||
"""
|
||||
|
||||
create_template_button = page.get_by_text("Create your first template")
|
||||
expect(create_template_button).to_be_visible()
|
||||
create_template_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
new_template_button = page.get_by_text("New template")
|
||||
expect(new_template_button).to_be_visible()
|
||||
new_template_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
start_with_a_blank_template_radio = page.get_by_text("Start with a blank template")
|
||||
expect(start_with_a_blank_template_radio).to_be_visible()
|
||||
start_with_a_blank_template_radio.click()
|
||||
|
||||
continue_button = page.get_by_role("button", name="Continue")
|
||||
|
||||
# continue_button = page.get_by_text("Continue")
|
||||
expect(continue_button).to_be_visible()
|
||||
continue_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
template_name_input = page.get_by_text("Template name")
|
||||
expect(template_name_input).to_be_visible()
|
||||
template_name = str(uuid.uuid4())
|
||||
template_name_input.fill(template_name)
|
||||
message_input = page.get_by_role("textbox", name="Message")
|
||||
expect(message_input).to_be_visible()
|
||||
message = "Test message"
|
||||
message_input.fill(message)
|
||||
|
||||
save_button = page.get_by_text("Save")
|
||||
expect(save_button).to_be_visible()
|
||||
save_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
use_this_template_button = page.get_by_text("Use this template")
|
||||
expect(use_this_template_button).to_be_visible()
|
||||
use_this_template_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
use_my_phone_number_link = page.get_by_text("Use my phone number")
|
||||
expect(use_my_phone_number_link).to_be_visible()
|
||||
use_my_phone_number_link.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
preview_button = page.get_by_text("Preview")
|
||||
expect(preview_button).to_be_visible()
|
||||
preview_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
send_button = page.get_by_role("button", name="Send")
|
||||
expect(send_button).to_be_visible()
|
||||
send_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
dashboard_button = page.get_by_text("Dashboard")
|
||||
expect(dashboard_button).to_be_visible()
|
||||
dashboard_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
download_link = page.get_by_text("Download")
|
||||
expect(download_link).to_be_visible()
|
||||
|
||||
# Start waiting for the download
|
||||
with page.expect_download() as download_info:
|
||||
# Perform the action that initiates download
|
||||
download_link.click()
|
||||
download = download_info.value
|
||||
# Wait for the download process to complete and save the downloaded file somewhere
|
||||
download.save_as("download_test_file")
|
||||
f = open("download_test_file", "r")
|
||||
|
||||
content = f.read()
|
||||
f.close()
|
||||
# We don't want to wait 5 minutes to get a response from AWS about the message we sent
|
||||
# So we are using this invalid phone number the e2e_test_user signed up with (12025555555)
|
||||
# to shortcircuit the sending process. Our phone number validator will insta-fail the
|
||||
# message and it won't be sent, but the report will still be generated, which is all
|
||||
# we care about here.
|
||||
assert (
|
||||
"Phone Number,Template,Sent by,Batch File,Carrier Response,Status,Time"
|
||||
in content
|
||||
)
|
||||
assert "12025555555" in content
|
||||
assert "one-off-e2e_test_user" in content
|
||||
os.remove("download_test_file")
|
||||
|
||||
|
||||
def handle_existing_template_case(page):
|
||||
"""
|
||||
This is the test path used in the Github action. Right now the e2e tests
|
||||
are not connected to AWS, so we can't actually send messages. Hence, the
|
||||
test stops when it verifies that the 'Send' button exists on the page. In
|
||||
the future we would like to change the way e2e tests run so they run against
|
||||
staging, in which case either the code in this method can be uncommented,
|
||||
or perhaps this path will be unnecessary (because staging is not completely clean)
|
||||
and we will just use the same path as for local development.
|
||||
"""
|
||||
existing_template_link = page.get_by_text("Example text message template")
|
||||
expect(existing_template_link).to_be_visible()
|
||||
existing_template_link.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
continue_button = page.get_by_role("button", name="Continue")
|
||||
|
||||
# continue_button = page.get_by_text("Continue")
|
||||
expect(continue_button).to_be_visible()
|
||||
continue_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
continue_button = page.get_by_role("button", name="Continue")
|
||||
|
||||
# continue_button = page.get_by_text("Continue")
|
||||
expect(continue_button).to_be_visible()
|
||||
continue_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# day_of_week_input = page.locator('xpath=//input[@name="day of week"]')
|
||||
# day_of_week_input = page.get_by_text("day of week")
|
||||
day_of_week_input = page.get_by_role("textbox", name="day of week")
|
||||
expect(day_of_week_input).to_be_visible()
|
||||
day_of_week_input.fill("Monday")
|
||||
|
||||
continue_button = page.get_by_role("button", name="Continue")
|
||||
|
||||
# continue_button = page.get_by_text("Continue")
|
||||
expect(continue_button).to_be_visible()
|
||||
continue_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
color_input = page.get_by_role("textbox", name="color")
|
||||
expect(color_input).to_be_visible()
|
||||
color_input.fill("Green")
|
||||
|
||||
# continue_button = page.get_by_text("Continue")
|
||||
expect(continue_button).to_be_visible()
|
||||
continue_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
preview_button = page.get_by_text("Preview")
|
||||
expect(preview_button).to_be_visible()
|
||||
preview_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
send_button = page.get_by_role("button", name="Send")
|
||||
expect(send_button).to_be_visible()
|
||||
# send_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
# page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# dashboard_button = page.get_by_text("Dashboard")
|
||||
# expect(dashboard_button).to_be_visible()
|
||||
# dashboard_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
# page.wait_for_load_state("domcontentloaded")
|
||||
|
||||
# download_link = page.get_by_text("Download")
|
||||
# expect(download_link).to_be_visible()
|
||||
|
||||
# Start waiting for the download
|
||||
# with page.expect_download() as download_info:
|
||||
# Perform the action that initiates download
|
||||
# download_link.click()
|
||||
# download = download_info.value
|
||||
# Wait for the download process to complete and save the downloaded file somewhere
|
||||
# download.save_as("download_test_file")
|
||||
# f = open("download_test_file", "r")
|
||||
|
||||
# content = f.read()
|
||||
# f.close()
|
||||
# We don't want to wait 5 minutes to get a response from AWS about the message we sent
|
||||
# So we are using this invalid phone number the e2e_test_user signed up with (12025555555)
|
||||
# to shortcircuit the sending process. Our phone number validator will insta-fail the
|
||||
# message and it won't be sent, but the report will still be generated, which is all
|
||||
# we care about here.
|
||||
# assert (
|
||||
# "Phone Number,Template,Sent by,Batch File,Carrier Response,Status,Time"
|
||||
# in content
|
||||
# )
|
||||
# assert "12025555555" in content
|
||||
# assert "one-off-e2e_test_user" in content
|
||||
# os.remove("download_test_file")
|
||||
|
||||
|
||||
def test_send_message_from_existing_template(authenticated_page):
|
||||
page = authenticated_page
|
||||
|
||||
_setup(page)
|
||||
|
||||
if page.get_by_text("Create your first template").count() > 0:
|
||||
handle_no_existing_template_case(page)
|
||||
else:
|
||||
handle_existing_template_case(page)
|
||||
|
||||
_teardown(page)
|
||||
|
||||
|
||||
def _teardown(page):
|
||||
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"))
|
||||
Reference in New Issue
Block a user