From 404ef2c3c37953cf2263b7f871a90e9fa13327df Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 25 Mar 2024 11:38:07 -0700 Subject: [PATCH 01/47] initial --- tests/end_to_end/test_accounts_page.py | 86 +------ ...est_send_message_from_existing_template.py | 225 ++++++++++++++++++ 2 files changed, 226 insertions(+), 85 deletions(-) create mode 100644 tests/end_to_end/test_send_message_from_existing_template.py diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index b6fe8c5ac..e59fe7f9e 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -8,88 +8,4 @@ E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") def test_add_new_service_workflow(authenticated_page, end_to_end_context): - page = authenticated_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=end_to_end_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)) - - 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")) + pass diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py new file mode 100644 index 000000000..266160a6f --- /dev/null +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -0,0 +1,225 @@ +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, end_to_end_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_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 test_add_new_service_workflow(authenticated_page, end_to_end_context): + page = authenticated_page + + new_service_name = _setup(page, end_to_end_context) + + print(page) + + + create_template_button = page.get_by_text("Create your first template") + expect(create_template_button).to_be_visible() + create_template_button.click() + print("GOT TO CREATE TEMPLATE") + + # 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() + print("GOT TO NEW TEMPLATE") + + # 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() + print("GOT TO START WITH A BLANK TEMPLATE") + + 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() + print("GOT TO CONTINUE") + + # 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) + print("GOT TEMPLATE NAME INPUT") + message_input = page.get_by_role("textbox", name="Message") + expect(message_input).to_be_visible() + message = "Test message" + message_input.fill(message) + print("FILLED OUT NEW TEMPLATE") + + save_button = page.get_by_text("Save") + expect(save_button).to_be_visible() + save_button.click() + print("SAVED NEW TEMPLATE") + + # 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") + + _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")) From 54b9d2a5d6c72c7dccc7baba588ad2151198b2db Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 25 Mar 2024 12:06:38 -0700 Subject: [PATCH 02/47] add existing template case --- ...est_send_message_from_existing_template.py | 136 +++++++++++++++--- 1 file changed, 120 insertions(+), 16 deletions(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 266160a6f..644c3cd67 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -78,14 +78,7 @@ def _setup(page, end_to_end_context): return new_service_name -def test_add_new_service_workflow(authenticated_page, end_to_end_context): - page = authenticated_page - - new_service_name = _setup(page, end_to_end_context) - - print(page) - - +def handle_no_existing_template_case(page): create_template_button = page.get_by_text("Create your first template") expect(create_template_button).to_be_visible() create_template_button.click() @@ -136,7 +129,6 @@ def test_add_new_service_workflow(authenticated_page, end_to_end_context): # 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() @@ -144,7 +136,6 @@ def test_add_new_service_workflow(authenticated_page, end_to_end_context): # 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() @@ -152,7 +143,6 @@ def test_add_new_service_workflow(authenticated_page, end_to_end_context): # 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() @@ -160,7 +150,6 @@ def test_add_new_service_workflow(authenticated_page, end_to_end_context): # 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() @@ -168,7 +157,6 @@ def test_add_new_service_workflow(authenticated_page, end_to_end_context): # 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() @@ -176,13 +164,12 @@ def test_add_new_service_workflow(authenticated_page, end_to_end_context): # 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 + # 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 @@ -196,11 +183,128 @@ def test_add_new_service_workflow(authenticated_page, end_to_end_context): # 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 ( + "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): + existing_template_link = page.get_by_text("Existing text message template") + expect(existing_template_link).to_be_visible() + existing_template_link.click() + print("GOT TO EXISTING TEMPLATE") + + # 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_role("button", name="Use this template") + expect(use_this_template_button).to_be_visible() + use_this_template_button.click() + print("GOT TO USE THIS TEMPLATE") + + # 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") + + day_of_week_input = page.get_by_text("day of week") + expect(day_of_week_input).to_be_visible() + day_of_week_input.fill("Monday") + print("GOT DAY OF WEEK INPUT") + + 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() + print("GOT TO CONTINUE") + + # Check to make sure that we've arrived at the next page. + page.wait_for_load_state("domcontentloaded") + + color_input = page.get_by_text("color") + expect(day_of_week_input).to_be_visible() + day_of_week_input.fill("Green") + print("GOT COLOR INPUT") + + 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() + print("GOT TO CONTINUE") + + # 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, end_to_end_context): + page = authenticated_page + + new_service_name = _setup(page, end_to_end_context) + + if page.get_by_text("Create your first template"): + handle_no_existing_template_case(page) + else: + handle_existing_template_case(page) + _teardown(page) From e1c2a6a2fd735bcde8bac0658ef57520850ad825 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 25 Mar 2024 12:23:53 -0700 Subject: [PATCH 03/47] add existing template case --- .../test_send_message_from_existing_template.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 644c3cd67..cd4e3deb0 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -300,10 +300,10 @@ def test_send_message_from_existing_template(authenticated_page, end_to_end_cont new_service_name = _setup(page, end_to_end_context) - if page.get_by_text("Create your first template"): - handle_no_existing_template_case(page) - else: - handle_existing_template_case(page) + #if page.get_by_text("Create your first template"): + # handle_no_existing_template_case(page) + #else: + handle_existing_template_case(page) _teardown(page) From 6367b2ce7608950fbd35c7363a1274f4c32c918c Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 25 Mar 2024 13:09:32 -0700 Subject: [PATCH 04/47] add existing template case --- tests/end_to_end/test_send_message_from_existing_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index cd4e3deb0..e0b0be8b2 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -193,7 +193,7 @@ def handle_no_existing_template_case(page): def handle_existing_template_case(page): - existing_template_link = page.get_by_text("Existing text message template") + existing_template_link = page.get_by_text("Example text message template") expect(existing_template_link).to_be_visible() existing_template_link.click() print("GOT TO EXISTING TEMPLATE") From dbb60fc9635976d37731e16b5109f272ba9e5bf0 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 25 Mar 2024 13:15:41 -0700 Subject: [PATCH 05/47] add existing template case --- tests/end_to_end/test_send_message_from_existing_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index e0b0be8b2..3b2702c28 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -201,7 +201,7 @@ def handle_existing_template_case(page): # 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_role("button", name="Use this template") + use_this_template_button = page.get_by_text("Use this template") expect(use_this_template_button).to_be_visible() use_this_template_button.click() print("GOT TO USE THIS TEMPLATE") From 3660dce9f5fc1a261bb6ac4f8099043fefcf6cd4 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 25 Mar 2024 13:21:07 -0700 Subject: [PATCH 06/47] add existing template case --- .../test_send_message_from_existing_template.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 3b2702c28..307db7f91 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -300,10 +300,10 @@ def test_send_message_from_existing_template(authenticated_page, end_to_end_cont new_service_name = _setup(page, end_to_end_context) - #if page.get_by_text("Create your first template"): - # handle_no_existing_template_case(page) - #else: - handle_existing_template_case(page) + if page.get_by_text("Create your first template"): + handle_no_existing_template_case(page) + else: + handle_existing_template_case(page) _teardown(page) From 9dcf157ccbbdcf8bee0bd711599fac23819fe8bc Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 25 Mar 2024 13:29:59 -0700 Subject: [PATCH 07/47] add existing template case --- .../end_to_end/test_send_message_from_existing_template.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 307db7f91..0f7ac0051 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -132,6 +132,7 @@ def handle_no_existing_template_case(page): use_this_template_button = page.get_by_text("Use this template") expect(use_this_template_button).to_be_visible() use_this_template_button.click() + print("DID USE THIS TEMPLATE") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -139,6 +140,7 @@ def handle_no_existing_template_case(page): 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() + print("DID USE MY PHONE NUBMER") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -146,6 +148,7 @@ def handle_no_existing_template_case(page): preview_button = page.get_by_text("Preview") expect(preview_button).to_be_visible() preview_button.click() + print("DID PREVIEW") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -153,10 +156,13 @@ def handle_no_existing_template_case(page): send_button = page.get_by_role("button", name="Send") expect(send_button).to_be_visible() send_button.click() + print("DID SEND") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") + print(f"PAGE!!! {page}") + dashboard_button = page.get_by_text("Dashboard") expect(dashboard_button).to_be_visible() dashboard_button.click() From c4cce69f719739ae2b61c50d142c60b5aa1cdf0e Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 25 Mar 2024 13:52:51 -0700 Subject: [PATCH 08/47] try button instead of text --- tests/end_to_end/test_send_message_from_existing_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 0f7ac0051..bc7bc5eac 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -163,7 +163,7 @@ def handle_no_existing_template_case(page): print(f"PAGE!!! {page}") - dashboard_button = page.get_by_text("Dashboard") + dashboard_button = page.get_by_role("button", name="Dashboard") expect(dashboard_button).to_be_visible() dashboard_button.click() From 86efe62b22f7b6cdaff146f6579a7170297c7c05 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 25 Mar 2024 14:07:33 -0700 Subject: [PATCH 09/47] try button instead of text --- tests/end_to_end/test_send_message_from_existing_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index bc7bc5eac..c9ae7970f 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -161,7 +161,7 @@ def handle_no_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - print(f"PAGE!!! {page}") + print(f"PAGE!!! {page.content}") dashboard_button = page.get_by_role("button", name="Dashboard") expect(dashboard_button).to_be_visible() From 8bc41c59dca78c67eecb4af7de1031e815878bc1 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 25 Mar 2024 14:12:31 -0700 Subject: [PATCH 10/47] try button instead of text --- tests/end_to_end/test_send_message_from_existing_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index c9ae7970f..ae98784d4 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -161,7 +161,7 @@ def handle_no_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - print(f"PAGE!!! {page.content}") + print(f"PAGE!!! {page.content()}") dashboard_button = page.get_by_role("button", name="Dashboard") expect(dashboard_button).to_be_visible() From e1be811ed5bc5bc5ba1fe76f14ebd3d9aaaa207b Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 07:57:45 -0700 Subject: [PATCH 11/47] only test chromium right now --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index aa9b404af..14fedc411 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,7 @@ dead-code: .PHONY: e2e-test e2e-test: export NEW_RELIC_ENVIRONMENT=test e2e-test: ## Run end-to-end integration tests; note that --browser webkit isn't currently working - poetry run pytest -v --browser chromium --browser firefox tests/end_to_end + poetry run pytest -vv --browser chromium tests/end_to_end .PHONY: js-lint js-lint: ## Run javascript linting scanners From 7ebc337bb0ba78e320280f56f96d4da837e7691d Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 08:06:39 -0700 Subject: [PATCH 12/47] only test chromium right now --- tests/end_to_end/test_send_message_from_existing_template.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index ae98784d4..825fbf3c4 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -79,6 +79,8 @@ def _setup(page, end_to_end_context): def handle_no_existing_template_case(page): + print(f"ENTER HANDLE_NO_EXISTING_TEMPLATE_CASE") + print(page.content()) create_template_button = page.get_by_text("Create your first template") expect(create_template_button).to_be_visible() create_template_button.click() @@ -303,6 +305,8 @@ def handle_existing_template_case(page): def test_send_message_from_existing_template(authenticated_page, end_to_end_context): page = authenticated_page + print(f"START OF TEST") + print(page.content()) new_service_name = _setup(page, end_to_end_context) From 1ecb617eac46ea7546e394265b332fb8c76a6891 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 08:14:49 -0700 Subject: [PATCH 13/47] only test chromium right now --- tests/end_to_end/test_send_message_from_existing_template.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 825fbf3c4..a138b4db2 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -306,9 +306,10 @@ def handle_existing_template_case(page): def test_send_message_from_existing_template(authenticated_page, end_to_end_context): page = authenticated_page print(f"START OF TEST") - print(page.content()) + new_service_name = _setup(page, end_to_end_context) + print(page.content()) if page.get_by_text("Create your first template"): handle_no_existing_template_case(page) From 6700f85784e7fbd82f3ff9fab3699e864adac137 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 08:22:11 -0700 Subject: [PATCH 14/47] only test chromium right now --- .../test_send_message_from_existing_template.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index a138b4db2..83c3015b4 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -309,12 +309,12 @@ def test_send_message_from_existing_template(authenticated_page, end_to_end_cont new_service_name = _setup(page, end_to_end_context) - print(page.content()) + #print(page.content()) - if page.get_by_text("Create your first template"): - handle_no_existing_template_case(page) - else: - handle_existing_template_case(page) + # if page.get_by_text("Create your first template"): + # handle_no_existing_template_case(page) + #else: + handle_existing_template_case(page) _teardown(page) From 5e16f210d8ca00fa8d97e3e4420d5fb0654d0df3 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 08:32:37 -0700 Subject: [PATCH 15/47] only test chromium right now --- tests/end_to_end/test_send_message_from_existing_template.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 83c3015b4..f65059059 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -209,6 +209,8 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") + print(page.content()) + use_this_template_button = page.get_by_text("Use this template") expect(use_this_template_button).to_be_visible() use_this_template_button.click() From 25f217514765b976caa1b3399966cf0ab8e3e8fd Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 08:45:30 -0700 Subject: [PATCH 16/47] only test chromium right now --- ...est_send_message_from_existing_template.py | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index f65059059..bdad89e7d 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -209,27 +209,27 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - print(page.content()) - use_this_template_button = page.get_by_text("Use this template") - expect(use_this_template_button).to_be_visible() - use_this_template_button.click() - print("GOT TO USE THIS TEMPLATE") + + # use_this_template_button = page.get_by_text("Use this template") + # expect(use_this_template_button).to_be_visible() + # use_this_template_button.click() + # print("GOT TO USE THIS TEMPLATE") # Check to make sure that we've arrived at the next page. - page.wait_for_load_state("domcontentloaded") + # 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() + # 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") + # page.wait_for_load_state("domcontentloaded") - day_of_week_input = page.get_by_text("day of week") - expect(day_of_week_input).to_be_visible() - day_of_week_input.fill("Monday") - print("GOT DAY OF WEEK INPUT") + # day_of_week_input = page.get_by_text("day of week") + # expect(day_of_week_input).to_be_visible() + # day_of_week_input.fill("Monday") + # print("GOT DAY OF WEEK INPUT") continue_button = page.get_by_role("button", name="Continue") From afefa092ed3e03b004efc6b02f447ae996173812 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 08:56:50 -0700 Subject: [PATCH 17/47] only test chromium right now --- .../test_send_message_from_existing_template.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index bdad89e7d..faa0e796d 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -241,10 +241,12 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - color_input = page.get_by_text("color") - expect(day_of_week_input).to_be_visible() - day_of_week_input.fill("Green") - print("GOT COLOR INPUT") + print(page.content()) + + #color_input = page.get_by_text("color") + #expect(day_of_week_input).to_be_visible() + #day_of_week_input.fill("Green") + #print("GOT COLOR INPUT") continue_button = page.get_by_role("button", name="Continue") From 8b33fcc1f5cb9c8df5efb40111a6a0610ef2a48c Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 09:03:30 -0700 Subject: [PATCH 18/47] only test chromium right now --- tests/end_to_end/test_send_message_from_existing_template.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index faa0e796d..08fe913e9 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -241,7 +241,7 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - print(page.content()) + #color_input = page.get_by_text("color") #expect(day_of_week_input).to_be_visible() @@ -258,6 +258,8 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") + print(page.content()) + preview_button = page.get_by_text("Preview") expect(preview_button).to_be_visible() preview_button.click() From d6a0e25c38eaa3204089667c0a784aafb376bc69 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 09:10:52 -0700 Subject: [PATCH 19/47] only test chromium right now --- ...est_send_message_from_existing_template.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 08fe913e9..6d05cc95b 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -226,10 +226,6 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. # page.wait_for_load_state("domcontentloaded") - # day_of_week_input = page.get_by_text("day of week") - # expect(day_of_week_input).to_be_visible() - # day_of_week_input.fill("Monday") - # print("GOT DAY OF WEEK INPUT") continue_button = page.get_by_role("button", name="Continue") @@ -258,6 +254,21 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") + day_of_week_input = page.get_by_text("day of week") + expect(day_of_week_input).to_be_visible() + day_of_week_input.fill("Monday") + print("GOT DAY OF WEEK INPUT") + + 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() + print("GOT TO CONTINUE") + + # Check to make sure that we've arrived at the next page. + page.wait_for_load_state("domcontentloaded") + print(page.content()) preview_button = page.get_by_text("Preview") From 578d00a9ee6dd053bf902a7cd259623088aa697b Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 09:18:32 -0700 Subject: [PATCH 20/47] only test chromium right now --- tests/end_to_end/test_send_message_from_existing_template.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 6d05cc95b..7d887df89 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -254,7 +254,9 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - day_of_week_input = page.get_by_text("day of week") + + day_of_week_input = page.locator('xpath=//input[@name="day of week"]') + # day_of_week_input = page.get_by_text("day of week") expect(day_of_week_input).to_be_visible() day_of_week_input.fill("Monday") print("GOT DAY OF WEEK INPUT") From 08603c993ccafc0d21a3e1b2b151692e00323602 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 09:24:31 -0700 Subject: [PATCH 21/47] only test chromium right now --- tests/end_to_end/test_send_message_from_existing_template.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 7d887df89..8ccc61dc7 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -253,10 +253,11 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") + print(page.content()) - - day_of_week_input = page.locator('xpath=//input[@name="day of week"]') + # 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") print("GOT DAY OF WEEK INPUT") From 96c1a2b59f1c8dab253f0db51471acf7875f4fac Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 09:33:07 -0700 Subject: [PATCH 22/47] only test chromium right now --- ...est_send_message_from_existing_template.py | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 8ccc61dc7..f5390c408 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -80,7 +80,7 @@ def _setup(page, end_to_end_context): def handle_no_existing_template_case(page): print(f"ENTER HANDLE_NO_EXISTING_TEMPLATE_CASE") - print(page.content()) + create_template_button = page.get_by_text("Create your first template") expect(create_template_button).to_be_visible() create_template_button.click() @@ -163,7 +163,7 @@ def handle_no_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - print(f"PAGE!!! {page.content()}") + dashboard_button = page.get_by_role("button", name="Dashboard") expect(dashboard_button).to_be_visible() @@ -239,10 +239,6 @@ def handle_existing_template_case(page): - #color_input = page.get_by_text("color") - #expect(day_of_week_input).to_be_visible() - #day_of_week_input.fill("Green") - #print("GOT COLOR INPUT") continue_button = page.get_by_role("button", name="Continue") @@ -253,7 +249,6 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - print(page.content()) # day_of_week_input = page.locator('xpath=//input[@name="day of week"]') # day_of_week_input = page.get_by_text("day of week") @@ -272,7 +267,21 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - print(page.content()) + color_input = page.get_by_text("color") + expect(day_of_week_input).to_be_visible() + day_of_week_input.fill("Green") + print("GOT COLOR INPUT") + + + # continue_button = page.get_by_text("Continue") + expect(continue_button).to_be_visible() + continue_button.click() + print("GOT TO CONTINUE") + + + # 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() @@ -281,6 +290,9 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") + print(page.content()) + + send_button = page.get_by_role("button", name="Send") expect(send_button).to_be_visible() send_button.click() @@ -329,7 +341,7 @@ def test_send_message_from_existing_template(authenticated_page, end_to_end_cont new_service_name = _setup(page, end_to_end_context) - #print(page.content()) + # if page.get_by_text("Create your first template"): # handle_no_existing_template_case(page) From 4874c91f0a664860be593ff9467595154160b845 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 09:38:41 -0700 Subject: [PATCH 23/47] only test chromium right now --- .../end_to_end/test_send_message_from_existing_template.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index f5390c408..45f848c3b 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -267,9 +267,9 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - color_input = page.get_by_text("color") - expect(day_of_week_input).to_be_visible() - day_of_week_input.fill("Green") + color_input = page.get_by_role("textbox", name="color") + expect(color_input).to_be_visible() + color_input.fill("Green") print("GOT COLOR INPUT") From 790c274a6e29d1efa63adcdb1f9b68d1bef5cc0d Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 09:43:54 -0700 Subject: [PATCH 24/47] only test chromium right now --- .../end_to_end/test_send_message_from_existing_template.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 45f848c3b..cf270c3ac 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -290,8 +290,6 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - print(page.content()) - send_button = page.get_by_role("button", name="Send") expect(send_button).to_be_visible() @@ -300,6 +298,10 @@ def handle_existing_template_case(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") + + print(page.content()) + + dashboard_button = page.get_by_text("Dashboard") expect(dashboard_button).to_be_visible() dashboard_button.click() From c4a594663bf586507d4b4f3f2aa01241505db0de Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 09:57:16 -0700 Subject: [PATCH 25/47] put back firefox tests --- Makefile | 2 +- ...est_send_message_from_existing_template.py | 45 +++++++++---------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 14fedc411..0e4ff6a23 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,7 @@ dead-code: .PHONY: e2e-test e2e-test: export NEW_RELIC_ENVIRONMENT=test e2e-test: ## Run end-to-end integration tests; note that --browser webkit isn't currently working - poetry run pytest -vv --browser chromium tests/end_to_end + poetry run pytest -vv --browser chromium --browser firefox tests/end_to_end .PHONY: js-lint js-lint: ## Run javascript linting scanners diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index cf270c3ac..7f7da53dc 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -293,48 +293,47 @@ def handle_existing_template_case(page): send_button = page.get_by_role("button", name="Send") expect(send_button).to_be_visible() - send_button.click() + # send_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") - print(page.content()) - dashboard_button = page.get_by_text("Dashboard") - expect(dashboard_button).to_be_visible() - dashboard_button.click() + # 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") + # page.wait_for_load_state("domcontentloaded") - download_link = page.get_by_text("Download") - expect(download_link).to_be_visible() + # 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: + # with page.expect_download() as download_info: # Perform the action that initiates download - download_link.click() - download = download_info.value + # 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") + #download.save_as("download_test_file") + #f = open("download_test_file", "r") - content = f.read() - f.close() + #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") + #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, end_to_end_context): From edf3961f0d5ce244725d798a6d406e8d00b1659a Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 10:30:11 -0700 Subject: [PATCH 26/47] works locally and maybe on github as well --- Makefile | 2 +- .../test_send_message_from_existing_template.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 0e4ff6a23..255a7351d 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,7 @@ dead-code: .PHONY: e2e-test e2e-test: export NEW_RELIC_ENVIRONMENT=test e2e-test: ## Run end-to-end integration tests; note that --browser webkit isn't currently working - poetry run pytest -vv --browser chromium --browser firefox tests/end_to_end + poetry run pytest -vv --browser chromium --browser firefox --headed tests/end_to_end .PHONY: js-lint js-lint: ## Run javascript linting scanners diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 7f7da53dc..920dee488 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -165,7 +165,7 @@ def handle_no_existing_template_case(page): - dashboard_button = page.get_by_role("button", name="Dashboard") + dashboard_button = page.get_by_text("Dashboard") expect(dashboard_button).to_be_visible() dashboard_button.click() @@ -343,11 +343,11 @@ def test_send_message_from_existing_template(authenticated_page, end_to_end_cont new_service_name = _setup(page, end_to_end_context) - - # if page.get_by_text("Create your first template"): - # handle_no_existing_template_case(page) - #else: - handle_existing_template_case(page) + print(page.content()) + if page.get_by_text("Create your first template"): + handle_no_existing_template_case(page) + else: + handle_existing_template_case(page) _teardown(page) From 11bfc829e7b879f222bde16e90817a4a0d4a5236 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 10:45:17 -0700 Subject: [PATCH 27/47] works locally and maybe on github as well --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 255a7351d..ed508745a 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,7 @@ dead-code: .PHONY: e2e-test e2e-test: export NEW_RELIC_ENVIRONMENT=test e2e-test: ## Run end-to-end integration tests; note that --browser webkit isn't currently working - poetry run pytest -vv --browser chromium --browser firefox --headed tests/end_to_end + poetry run pytest -vv --browser chromium --browser firefox tests/end_to_end .PHONY: js-lint js-lint: ## Run javascript linting scanners From b9b59ea453d7f0f12f6e64de780f043057e256e6 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 10:59:16 -0700 Subject: [PATCH 28/47] works locally and maybe on github as well --- tests/end_to_end/test_send_message_from_existing_template.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 920dee488..848a7ec84 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -344,7 +344,9 @@ def test_send_message_from_existing_template(authenticated_page, end_to_end_cont new_service_name = _setup(page, end_to_end_context) print(page.content()) - if page.get_by_text("Create your first template"): + x = page.get_by_text("Create your first template") + print(f"X = {x.count()}") + if page.get_by_text("Create your first template").count() > 0: handle_no_existing_template_case(page) else: handle_existing_template_case(page) From 6f56123eeaac312b4e9a7bc65839900aa657e982 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 11:13:54 -0700 Subject: [PATCH 29/47] works locally and maybe on github as well --- ...est_send_message_from_existing_template.py | 93 ++++++------------- 1 file changed, 29 insertions(+), 64 deletions(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 848a7ec84..f8793c27f 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -79,12 +79,19 @@ def _setup(page, end_to_end_context): def handle_no_existing_template_case(page): - print(f"ENTER HANDLE_NO_EXISTING_TEMPLATE_CASE") + """ + 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() - print("GOT TO CREATE TEMPLATE") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -92,7 +99,6 @@ def handle_no_existing_template_case(page): new_template_button = page.get_by_text("New template") expect(new_template_button).to_be_visible() new_template_button.click() - print("GOT TO NEW TEMPLATE") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -100,14 +106,12 @@ def handle_no_existing_template_case(page): 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() - print("GOT TO START WITH A BLANK TEMPLATE") 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() - print("GOT TO CONTINUE") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -116,17 +120,14 @@ def handle_no_existing_template_case(page): expect(template_name_input).to_be_visible() template_name = str(uuid.uuid4()) template_name_input.fill(template_name) - print("GOT TEMPLATE NAME INPUT") message_input = page.get_by_role("textbox", name="Message") expect(message_input).to_be_visible() message = "Test message" message_input.fill(message) - print("FILLED OUT NEW TEMPLATE") save_button = page.get_by_text("Save") expect(save_button).to_be_visible() save_button.click() - print("SAVED NEW TEMPLATE") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -134,7 +135,6 @@ def handle_no_existing_template_case(page): use_this_template_button = page.get_by_text("Use this template") expect(use_this_template_button).to_be_visible() use_this_template_button.click() - print("DID USE THIS TEMPLATE") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -142,7 +142,6 @@ def handle_no_existing_template_case(page): 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() - print("DID USE MY PHONE NUBMER") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -150,7 +149,6 @@ def handle_no_existing_template_case(page): preview_button = page.get_by_text("Preview") expect(preview_button).to_be_visible() preview_button.click() - print("DID PREVIEW") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -158,13 +156,10 @@ def handle_no_existing_template_case(page): send_button = page.get_by_role("button", name="Send") expect(send_button).to_be_visible() send_button.click() - print("DID SEND") # 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() @@ -201,51 +196,37 @@ def handle_no_existing_template_case(page): 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() - print("GOT TO EXISTING TEMPLATE") # 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() - # print("GOT TO USE THIS TEMPLATE") - - # 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") - - 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() - print("GOT TO CONTINUE") # 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() - print("GOT TO CONTINUE") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -255,14 +236,12 @@ def handle_existing_template_case(page): 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") - print("GOT DAY OF WEEK INPUT") 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() - print("GOT TO CONTINUE") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -270,19 +249,14 @@ def handle_existing_template_case(page): color_input = page.get_by_role("textbox", name="color") expect(color_input).to_be_visible() color_input.fill("Green") - print("GOT COLOR INPUT") - # continue_button = page.get_by_text("Continue") expect(continue_button).to_be_visible() continue_button.click() - print("GOT TO CONTINUE") - # 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() @@ -290,7 +264,6 @@ def handle_existing_template_case(page): # 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() @@ -298,9 +271,6 @@ def handle_existing_template_case(page): # 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() @@ -313,39 +283,34 @@ def handle_existing_template_case(page): # Start waiting for the download # with page.expect_download() as download_info: - # Perform the action that initiates download + # Perform the action that initiates download # download_link.click() - #download = download_info.value + # 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") + # download.save_as("download_test_file") + # f = open("download_test_file", "r") - #content = f.read() - #f.close() + # 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 ( + # 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") + # ) + # 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, end_to_end_context): page = authenticated_page - print(f"START OF TEST") - new_service_name = _setup(page, end_to_end_context) - print(page.content()) - x = page.get_by_text("Create your first template") - print(f"X = {x.count()}") if page.get_by_text("Create your first template").count() > 0: handle_no_existing_template_case(page) else: From abef1230b8c36aa7f2f34f760fa8c4eb81489aa5 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 26 Mar 2024 11:22:22 -0700 Subject: [PATCH 30/47] final? --- tests/end_to_end/test_accounts_page.py | 86 ++++++++++++++++++- ...est_send_message_from_existing_template.py | 3 +- 2 files changed, 86 insertions(+), 3 deletions(-) diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index e59fe7f9e..b6fe8c5ac 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -8,4 +8,88 @@ E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") def test_add_new_service_workflow(authenticated_page, end_to_end_context): - pass + page = authenticated_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=end_to_end_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)) + + 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")) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index f8793c27f..d09ecf73f 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -212,7 +212,6 @@ def handle_existing_template_case(page): # 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") @@ -309,7 +308,7 @@ def handle_existing_template_case(page): def test_send_message_from_existing_template(authenticated_page, end_to_end_context): page = authenticated_page - new_service_name = _setup(page, end_to_end_context) + _setup(page, end_to_end_context) if page.get_by_text("Create your first template").count() > 0: handle_no_existing_template_case(page) From 624a89a54606616cc9903501234640d7fcd6121b Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 27 Mar 2024 10:21:01 -0700 Subject: [PATCH 31/47] create new template test --- tests/end_to_end/test_create_new_template.py | 180 +++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 tests/end_to_end/test_create_new_template.py diff --git a/tests/end_to_end/test_create_new_template.py b/tests/end_to_end/test_create_new_template.py new file mode 100644 index 000000000..5bdd1546a --- /dev/null +++ b/tests/end_to_end/test_create_new_template.py @@ -0,0 +1,180 @@ +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, end_to_end_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_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): + + 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") + print(page.content()) + + + + +def test_create_new_template(authenticated_page, end_to_end_context): + page = authenticated_page + + _setup(page, end_to_end_context) + + 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")) From bbb351861dcb50215e10783cb4d4a8d894c505c5 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 27 Mar 2024 10:26:56 -0700 Subject: [PATCH 32/47] create new template test --- tests/end_to_end/test_create_new_template.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/end_to_end/test_create_new_template.py b/tests/end_to_end/test_create_new_template.py index 5bdd1546a..d7a0a06ce 100644 --- a/tests/end_to_end/test_create_new_template.py +++ b/tests/end_to_end/test_create_new_template.py @@ -80,6 +80,7 @@ def _setup(page, end_to_end_context): def create_new_template(page): + print(page.content()) create_template_button = page.get_by_text("Create your first template") expect(create_template_button).to_be_visible() create_template_button.click() From 939c1c978e86890665349f943b2dc57e1cfeab85 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 27 Mar 2024 10:35:09 -0700 Subject: [PATCH 33/47] try current service link --- tests/end_to_end/test_create_new_template.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/end_to_end/test_create_new_template.py b/tests/end_to_end/test_create_new_template.py index d7a0a06ce..645811b10 100644 --- a/tests/end_to_end/test_create_new_template.py +++ b/tests/end_to_end/test_create_new_template.py @@ -80,7 +80,14 @@ def _setup(page, end_to_end_context): 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") print(page.content()) + create_template_button = page.get_by_text("Create your first template") expect(create_template_button).to_be_visible() create_template_button.click() From 70c3457dbd2ac3d7245fec37a4995c529809e1b0 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 27 Mar 2024 10:52:22 -0700 Subject: [PATCH 34/47] try current service link --- tests/end_to_end/test_create_new_template.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/end_to_end/test_create_new_template.py b/tests/end_to_end/test_create_new_template.py index 645811b10..a30722a57 100644 --- a/tests/end_to_end/test_create_new_template.py +++ b/tests/end_to_end/test_create_new_template.py @@ -88,6 +88,15 @@ def create_new_template(page): page.wait_for_load_state("domcontentloaded") print(page.content()) + send_messages_button = page.get_by_text("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_text("Create your first template") expect(create_template_button).to_be_visible() create_template_button.click() From f6f750e5d01c07f6d15a24c8dfa6733ef1e22efb Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 27 Mar 2024 11:02:53 -0700 Subject: [PATCH 35/47] try current service link --- tests/end_to_end/test_create_new_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/end_to_end/test_create_new_template.py b/tests/end_to_end/test_create_new_template.py index a30722a57..43d35ec25 100644 --- a/tests/end_to_end/test_create_new_template.py +++ b/tests/end_to_end/test_create_new_template.py @@ -88,7 +88,7 @@ def create_new_template(page): page.wait_for_load_state("domcontentloaded") print(page.content()) - send_messages_button = page.get_by_text("Send messages") + send_messages_button = page.get_by_role("button", name="Send messages") expect(send_messages_button).to_be_visible() send_messages_button.click() From a85681252f00ff733177f688c1978d4aae03883a Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 27 Mar 2024 12:15:44 -0700 Subject: [PATCH 36/47] fix --- tests/end_to_end/test_create_new_template.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tests/end_to_end/test_create_new_template.py b/tests/end_to_end/test_create_new_template.py index 43d35ec25..4b436d0a9 100644 --- a/tests/end_to_end/test_create_new_template.py +++ b/tests/end_to_end/test_create_new_template.py @@ -86,31 +86,24 @@ def create_new_template(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - print(page.content()) - send_messages_button = page.get_by_role("button", name="Send messages") - expect(send_messages_button).to_be_visible() + + 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") + print(page.content()) - - create_template_button = page.get_by_text("Create your first template") + 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") - 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() From 81412ddd1e98430618a291e344a76ae315c581d8 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 27 Mar 2024 12:32:29 -0700 Subject: [PATCH 37/47] fix --- tests/end_to_end/test_create_new_template.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/end_to_end/test_create_new_template.py b/tests/end_to_end/test_create_new_template.py index 4b436d0a9..23836ea49 100644 --- a/tests/end_to_end/test_create_new_template.py +++ b/tests/end_to_end/test_create_new_template.py @@ -87,15 +87,12 @@ def create_new_template(page): # 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") - print(page.content()) - create_template_button = page.get_by_role("button", name="New template") expect(create_template_button).to_be_visible() @@ -123,7 +120,7 @@ def create_new_template(page): 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 = "Test message for e2e test" message_input.fill(message) save_button = page.get_by_text("Save") @@ -153,9 +150,8 @@ def create_new_template(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - print(page.content()) - + assert "Test message for e2e test" in page.content() def test_create_new_template(authenticated_page, end_to_end_context): @@ -165,7 +161,6 @@ def test_create_new_template(authenticated_page, end_to_end_context): create_new_template(page) - _teardown(page) From 5a81c11348225de211b9f4c133d9b10a831f7d56 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 27 Mar 2024 12:40:45 -0700 Subject: [PATCH 38/47] add comment --- tests/end_to_end/test_create_new_template.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/end_to_end/test_create_new_template.py b/tests/end_to_end/test_create_new_template.py index 23836ea49..936ce3a2f 100644 --- a/tests/end_to_end/test_create_new_template.py +++ b/tests/end_to_end/test_create_new_template.py @@ -151,6 +151,9 @@ def create_new_template(page): # 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() From acdd2806fc8553e08565f6ef42366de3dbda5b12 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Mon, 1 Apr 2024 18:03:38 -0700 Subject: [PATCH 39/47] added force_hide_sender --- app/main/views/send.py | 29 +++++-------------- app/templates/views/check/preview.html | 2 +- .../views/notifications/preview.html | 2 +- app/utils/templates.py | 3 +- 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/app/main/views/send.py b/app/main/views/send.py index 3aa5bd830..78395d243 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -470,7 +470,7 @@ def send_one_off_step(service_id, template_id, step_index): ) -def _check_messages(service_id, template_id, upload_id, preview_row): +def _check_messages(service_id, template_id, upload_id, preview_row, **kwargs): try: # The happy path is that the job doesn’t already exist, so the # API will return a 404 and the client will raise HTTPError. @@ -510,11 +510,7 @@ def _check_messages(service_id, template_id, upload_id, preview_row): show_recipient=False, email_reply_to=email_reply_to, sms_sender=sms_sender, - ) - simplifed_template = get_template( - db_template, - current_service, - show_recipient=False, + **kwargs, ) allow_list = [] @@ -535,7 +531,7 @@ def _check_messages(service_id, template_id, upload_id, preview_row): allow_list = None recipients = RecipientCSV( contents, - template=template or simplifed_template, + template=template, max_initial_rows_shown=50, max_errors_shown=50, guestlist=allow_list, @@ -569,9 +565,6 @@ def _check_messages(service_id, template_id, upload_id, preview_row): if preview_row < len(recipients) + 2: template.values = recipients[preview_row - 2].recipient_and_personalisation - simplifed_template.values = recipients[ - preview_row - 2 - ].recipient_and_personalisation elif preview_row > 2: abort(404) @@ -599,7 +592,6 @@ def _check_messages(service_id, template_id, upload_id, preview_row): service_id, template.id, db_template["version"], original_file_name ), template_id=template_id, - simplifed_template=simplifed_template, ) @@ -658,7 +650,7 @@ def check_messages(service_id, template_id, upload_id, row_index=2): @user_has_permissions("send_messages", restrict_admin_usage=True) def preview_job(service_id, template_id, upload_id, row_index=2): session["scheduled_for"] = request.form.get("scheduled_for", "") - data = _check_messages(service_id, template_id, upload_id, row_index) + data = _check_messages(service_id, template_id, upload_id, row_index, force_hide_sender=True) return render_template( "views/check/preview.html", @@ -825,11 +817,11 @@ def send_one_off_to_myself(service_id, template_id): def check_notification(service_id, template_id): return render_template( "views/notifications/check.html", - **_check_notification(service_id, template_id), + **_check_notification(service_id, template_id, show_recipient=True), ) -def _check_notification(service_id, template_id, exception=None): +def _check_notification(service_id, template_id, exception=None, **kwargs): db_template = current_service.get_template_with_user_permission_or_403( template_id, current_user ) @@ -842,13 +834,9 @@ def _check_notification(service_id, template_id, exception=None): template = get_template( db_template, current_service, - show_recipient=True, email_reply_to=email_reply_to, sms_sender=sms_sender, - ) - simplifed_template = get_template( - db_template, - current_service, + **kwargs, ) placeholders = fields_to_fill_in(template) @@ -874,7 +862,6 @@ def _check_notification(service_id, template_id, exception=None): back_link_from_preview=back_link_from_preview, choose_time_form=choose_time_form, **(get_template_error_dict(exception) if exception else {}), - simplifed_template=simplifed_template, ) @@ -924,7 +911,7 @@ def preview_notification(service_id, template_id): return render_template( "views/notifications/preview.html", - **_check_notification(service_id, template_id), + **_check_notification(service_id, template_id, show_recipient=False, force_hide_sender=True), scheduled_for=session["scheduled_for"], recipient=recipient, ) diff --git a/app/templates/views/check/preview.html b/app/templates/views/check/preview.html index 7398a7fd9..0aa17a3a9 100644 --- a/app/templates/views/check/preview.html +++ b/app/templates/views/check/preview.html @@ -28,7 +28,7 @@

Message

-
{{ simplifed_template|string }}
+
{{ template|string }}
{% if not request.args.from_test %}

Recipients list

diff --git a/app/templates/views/notifications/preview.html b/app/templates/views/notifications/preview.html index a22fda5bb..bd518dc18 100644 --- a/app/templates/views/notifications/preview.html +++ b/app/templates/views/notifications/preview.html @@ -50,7 +50,7 @@

Message

-
{{ simplifed_template|string }}
+
{{ template|string }}
Date: Tue, 2 Apr 2024 14:11:44 -0700 Subject: [PATCH 40/47] updated css to placeholder --- app/assets/sass/uswds/_uswds-theme-custom-styles.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss index 74441f092..ce21de941 100644 --- a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss +++ b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss @@ -595,3 +595,9 @@ details form { #countdown-container { display: none; // Hide the countdown timer } + +.placeholder, .placeholder-conditional { + background-color: #face00; + border: 1px solid #face00; + border-radius: 7px; +} From 745532e6570ea5d289325133d14812129b96c8ab Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Tue, 2 Apr 2024 16:30:40 -0700 Subject: [PATCH 41/47] added template for personalisation --- app/main/views/jobs.py | 16 ++++++++++++++++ app/templates/partials/jobs/status.html | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index 0c0848e46..0c222972f 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -34,6 +34,7 @@ from app.utils.pagination import ( generate_previous_dict, get_page_from_request, ) +from app.utils.templates import get_template from app.utils.user import user_has_permissions @@ -381,6 +382,20 @@ def get_job_partials(job): arrived_from_preview_page_url = session.get("arrived_from_preview_page", False) + template_id = job.template.get('id') + + db_template = current_service.get_template_with_user_permission_or_403( + template_id, current_user + ) + if db_template["template_type"] not in ("sms", "email"): + abort(404) + + template = get_template( + db_template, + current_service, + redact_missing_personalisation=True, + ) + return { "counts": counts, "notifications": render_template( @@ -405,6 +420,7 @@ def get_job_partials(job): "partials/jobs/status.html", job=job, arrived_from_preview_page_url=arrived_from_preview_page_url, + template=template, ), } diff --git a/app/templates/partials/jobs/status.html b/app/templates/partials/jobs/status.html index 99b5768e8..4d681c338 100644 --- a/app/templates/partials/jobs/status.html +++ b/app/templates/partials/jobs/status.html @@ -1,8 +1,8 @@ {% set display_message_status %} {% if job.template.content %}

Message

-
{{ current_service.name }}: {{job.template.content}}
-{% endif %} + {{template|string}} + {% endif %} {% if job.original_file_name %}

Recipient list

From 6acbce085846a3909fb00923ec47df4302279442 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Fri, 5 Apr 2024 12:14:56 -0700 Subject: [PATCH 42/47] removed jobs template --- app/main/views/jobs.py | 16 ---------------- app/templates/partials/jobs/status.html | 4 ++-- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index 0c222972f..0c0848e46 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -34,7 +34,6 @@ from app.utils.pagination import ( generate_previous_dict, get_page_from_request, ) -from app.utils.templates import get_template from app.utils.user import user_has_permissions @@ -382,20 +381,6 @@ def get_job_partials(job): arrived_from_preview_page_url = session.get("arrived_from_preview_page", False) - template_id = job.template.get('id') - - db_template = current_service.get_template_with_user_permission_or_403( - template_id, current_user - ) - if db_template["template_type"] not in ("sms", "email"): - abort(404) - - template = get_template( - db_template, - current_service, - redact_missing_personalisation=True, - ) - return { "counts": counts, "notifications": render_template( @@ -420,7 +405,6 @@ def get_job_partials(job): "partials/jobs/status.html", job=job, arrived_from_preview_page_url=arrived_from_preview_page_url, - template=template, ), } diff --git a/app/templates/partials/jobs/status.html b/app/templates/partials/jobs/status.html index 4d681c338..99b5768e8 100644 --- a/app/templates/partials/jobs/status.html +++ b/app/templates/partials/jobs/status.html @@ -1,8 +1,8 @@ {% set display_message_status %} {% if job.template.content %}

Message

- {{template|string}} - {% endif %} +
{{ current_service.name }}: {{job.template.content}}
+{% endif %} {% if job.original_file_name %}

Recipient list

From d5d5a45138e4902e46339a09a9f71c18559f0f37 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Mon, 8 Apr 2024 11:41:39 -0400 Subject: [PATCH 43/47] Update utils to 0.4.5 This changeset updates notifications-utils to 0.4.5, which includes a few minor fixes and several dependency updates. Signed-off-by: Carlo Costino --- poetry.lock | 72 +++++++++++++++++++++++++------------------------- pyproject.toml | 4 +-- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/poetry.lock b/poetry.lock index 930c20232..96e56ec54 100644 --- a/poetry.lock +++ b/poetry.lock @@ -171,41 +171,41 @@ files = [ [[package]] name = "boto3" -version = "1.29.6" +version = "1.34.79" description = "The AWS SDK for Python" optional = false -python-versions = ">= 3.7" +python-versions = ">=3.8" files = [ - {file = "boto3-1.29.6-py3-none-any.whl", hash = "sha256:f4d19e01d176c3a5a05e4af733185ff1891b08a3c38d4a439800fa132aa6e9be"}, - {file = "boto3-1.29.6.tar.gz", hash = "sha256:d1d0d979a70bf9b0b13ae3b017f8523708ad953f62d16f39a602d67ee9b25554"}, + {file = "boto3-1.34.79-py3-none-any.whl", hash = "sha256:265b0b4865e8c07e27abb32a31d2bd9129bb009b1d89ca0783776ec084886123"}, + {file = "boto3-1.34.79.tar.gz", hash = "sha256:139dd2d94eaa0e3213ff37ba7cf4cb2e3823269178fe8f3e33c965f680a9ddde"}, ] [package.dependencies] -botocore = ">=1.32.6,<1.33.0" +botocore = ">=1.34.79,<1.35.0" jmespath = ">=0.7.1,<2.0.0" -s3transfer = ">=0.7.0,<0.8.0" +s3transfer = ">=0.10.0,<0.11.0" [package.extras] crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.32.7" +version = "1.34.79" description = "Low-level, data-driven core of boto 3." optional = false -python-versions = ">= 3.7" +python-versions = ">=3.8" files = [ - {file = "botocore-1.32.7-py3-none-any.whl", hash = "sha256:58b33d02cafa23461c8a9d211b30e8cded992380a84de409379fd02811fa3e11"}, - {file = "botocore-1.32.7.tar.gz", hash = "sha256:c6795c731b04c8e3635588c44cfd1a4462fc5987859195522c96812cf3eceff9"}, + {file = "botocore-1.34.79-py3-none-any.whl", hash = "sha256:a42a014d3dbaa9ef123810592af69f9e55b456c5be3ac9efc037325685519e83"}, + {file = "botocore-1.34.79.tar.gz", hash = "sha256:6b59b0f7de219d383a2a633f6718c2600642ebcb707749dc6c67a6a436474b7a"}, ] [package.dependencies] jmespath = ">=0.7.1,<2.0.0" python-dateutil = ">=2.1,<3.0.0" -urllib3 = {version = ">=1.25.4,<2.1", markers = "python_version >= \"3.10\""} +urllib3 = {version = ">=1.25.4,<2.2.0 || >2.2.0,<3", markers = "python_version >= \"3.10\""} [package.extras] -crt = ["awscrt (==0.19.17)"] +crt = ["awscrt (==0.19.19)"] [[package]] name = "cachecontrol" @@ -925,13 +925,13 @@ files = [ [[package]] name = "govuk-bank-holidays" -version = "0.13" +version = "0.14" description = "Tool to load UK bank holidays from GOV.UK" optional = false python-versions = ">=3.6" files = [ - {file = "govuk-bank-holidays-0.13.tar.gz", hash = "sha256:ffb6ac050701cb850fd2f08eb9c7c91753090f00525e69cebec4f869f6f0de41"}, - {file = "govuk_bank_holidays-0.13-py3-none-any.whl", hash = "sha256:2b91901be492235c4160a64d56d4d1945f6ca7f11c1ea4277395981866c35bef"}, + {file = "govuk-bank-holidays-0.14.tar.gz", hash = "sha256:ce85102423b72908957d25981f616494729686515d5d66c09a1d35a354ce20a6"}, + {file = "govuk_bank_holidays-0.14-py3-none-any.whl", hash = "sha256:da485c4a40c6c874c925916e492e3f20b807cffba7eed5f07fb69327aef6b10b"}, ] [package.dependencies] @@ -1598,7 +1598,7 @@ requests = ">=2.0.0" [[package]] name = "notifications-utils" -version = "0.4.0" +version = "0.4.5" description = "" optional = false python-versions = "^3.12.2" @@ -1609,8 +1609,8 @@ develop = false async-timeout = "^4.0.2" bleach = "^6.1.0" blinker = "^1.6.2" -boto3 = "^1.28.66" -botocore = "^1.31.66" +boto3 = "^1.34.77" +botocore = "^1.34.79" cachetools = "^5.3.0" certifi = "^2024.2.2" cffi = "^1.16.0" @@ -1620,7 +1620,7 @@ cryptography = "^42.0.4" flask = "^2.3.2" flask-redis = "^0.4.0" geojson = "^3.0.1" -govuk-bank-holidays = "^0.13" +govuk-bank-holidays = "^0.14" idna = "^3.6" itsdangerous = "^2.1.2" jinja2 = "^3.1.3" @@ -1629,16 +1629,16 @@ markupsafe = "^2.1.5" mistune = "==0.8.4" numpy = "^1.24.2" ordered-set = "^4.1.0" -phonenumbers = "^8.13.32" +phonenumbers = "^8.13.34" pycparser = "^2.21" python-dateutil = "^2.8.2" python-json-logger = "^2.0.7" -pytz = "^2023.3" +pytz = "^2024.1" pyyaml = "^6.0" redis = "^5.0.3" regex = "^2023.12.25" requests = "^2.31.0" -s3transfer = "^0.7.0" +s3transfer = "^0.10.1" shapely = "^2.0.1" six = "^1.16.0" smartypants = "^2.0.1" @@ -1650,7 +1650,7 @@ werkzeug = "^3.0.1" type = "git" url = "https://github.com/GSA/notifications-utils.git" reference = "HEAD" -resolved_reference = "4cf526bc1fd9532507936c174418dbd3be52c925" +resolved_reference = "7d1d2e9bb3791316231e97433c71da6a70c4d2ab" [[package]] name = "numpy" @@ -1777,13 +1777,13 @@ files = [ [[package]] name = "phonenumbers" -version = "8.13.33" +version = "8.13.34" description = "Python version of Google's common library for parsing, formatting, storing and validating international phone numbers." optional = false python-versions = "*" files = [ - {file = "phonenumbers-8.13.33-py2.py3-none-any.whl", hash = "sha256:f2d653268ece55a4f3752d9cda4be6f7465f298e6d028d522aedda13cf057201"}, - {file = "phonenumbers-8.13.33.tar.gz", hash = "sha256:991f2619f0593b36b674c345af47944ec4bae526b353cf53d707e662087be63b"}, + {file = "phonenumbers-8.13.34-py2.py3-none-any.whl", hash = "sha256:bc0bb5d3bab29e28549194f6bf57cb3ca03c3dd84238af12674fe24031631bda"}, + {file = "phonenumbers-8.13.34.tar.gz", hash = "sha256:7c2676be07b7d0f74411e275e0660380a0ec3ee0d359f070d719424bd2c5f62e"}, ] [[package]] @@ -2344,13 +2344,13 @@ unidecode = ["Unidecode (>=1.1.1)"] [[package]] name = "pytz" -version = "2023.4" +version = "2024.1" description = "World timezone definitions, modern and historical" optional = false python-versions = "*" files = [ - {file = "pytz-2023.4-py2.py3-none-any.whl", hash = "sha256:f90ef520d95e7c46951105338d918664ebfd6f1d995bd7d153127ce90efafa6a"}, - {file = "pytz-2023.4.tar.gz", hash = "sha256:31d4583c4ed539cd037956140d695e42c033a19e984bfce9964a3f7d59bc2b40"}, + {file = "pytz-2024.1-py2.py3-none-any.whl", hash = "sha256:328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319"}, + {file = "pytz-2024.1.tar.gz", hash = "sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812"}, ] [[package]] @@ -2619,20 +2619,20 @@ diagram = ["matplotlib (>=3.0.0)", "pydot (>=1.3.0)", "tqdm (>=v4.31.0)"] [[package]] name = "s3transfer" -version = "0.7.0" +version = "0.10.1" description = "An Amazon S3 Transfer Manager" optional = false -python-versions = ">= 3.7" +python-versions = ">= 3.8" files = [ - {file = "s3transfer-0.7.0-py3-none-any.whl", hash = "sha256:10d6923c6359175f264811ef4bf6161a3156ce8e350e705396a7557d6293c33a"}, - {file = "s3transfer-0.7.0.tar.gz", hash = "sha256:fd3889a66f5fe17299fe75b82eae6cf722554edca744ca5d5fe308b104883d2e"}, + {file = "s3transfer-0.10.1-py3-none-any.whl", hash = "sha256:ceb252b11bcf87080fb7850a224fb6e05c8a776bab8f2b64b7f25b969464839d"}, + {file = "s3transfer-0.10.1.tar.gz", hash = "sha256:5683916b4c724f799e600f41dd9e10a9ff19871bf87623cc8f491cb4f5fa0a19"}, ] [package.dependencies] -botocore = ">=1.12.36,<2.0a.0" +botocore = ">=1.33.2,<2.0a.0" [package.extras] -crt = ["botocore[crt] (>=1.20.29,<2.0a.0)"] +crt = ["botocore[crt] (>=1.33.2,<2.0a.0)"] [[package]] name = "setuptools" @@ -2930,4 +2930,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.12.2" -content-hash = "fb81af6421e07a1640bd784f2e1934237a064b30705a0c02e6f06415493e05ff" +content-hash = "55d894a50ac58f68283ea1428a7c721e54bdb1d78839756d57a1dd705c728c09" diff --git a/pyproject.toml b/pyproject.toml index 40a1aac24..bb3bf43e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ flask-basicauth = "~=0.2" flask-login = "^0.6" flask-talisman = "*" flask-wtf = "^1.2" -govuk-bank-holidays = "==0.13" +govuk-bank-holidays = "^0.14" gunicorn = {version = "==21.2.0", extras = ["eventlet"]} humanize = "~=4.9" itsdangerous = "~=2.1" @@ -33,7 +33,7 @@ pyexcel-xlsx = "==0.6.0" openpyxl = "==3.0.10" pyproj = "==3.6.1" python-dotenv = "==1.0.1" -pytz = "~=2023.4" +pytz = "^2024.1" rtreelib = "==0.2.0" werkzeug = "^3.0.1" wtforms = "~=3.1" From 6a29d2c81459655133f67ec686b8ffe560e9b73b Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 9 Apr 2024 09:07:19 -0700 Subject: [PATCH 44/47] code review feedback --- tests/end_to_end/test_create_new_template.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/end_to_end/test_create_new_template.py b/tests/end_to_end/test_create_new_template.py index 936ce3a2f..6d344a94f 100644 --- a/tests/end_to_end/test_create_new_template.py +++ b/tests/end_to_end/test_create_new_template.py @@ -8,12 +8,12 @@ from playwright.sync_api import expect E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") -def _setup(page, end_to_end_context): +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=end_to_end_context.browser.browser_type.name, + browser_type=page.context.browser.browser_type.name, ) page.goto(f"{E2E_TEST_URI}/accounts") @@ -157,10 +157,10 @@ def create_new_template(page): assert "Test message for e2e test" in page.content() -def test_create_new_template(authenticated_page, end_to_end_context): +def test_create_new_template(authenticated_page): page = authenticated_page - _setup(page, end_to_end_context) + _setup(page) create_new_template(page) From 931d5f4fed96bd112b5cbb692b8c21ee8d3ce24f Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 9 Apr 2024 09:10:02 -0700 Subject: [PATCH 45/47] remove end-to-end context --- .../test_send_message_from_existing_template.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index d09ecf73f..535ad6c5f 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -8,12 +8,12 @@ from playwright.sync_api import expect E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") -def _setup(page, end_to_end_context): +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=end_to_end_context.browser.browser_type.name, + browser_type=page.context.browser.browser_type.name, ) page.goto(f"{E2E_TEST_URI}/accounts") @@ -305,10 +305,10 @@ def handle_existing_template_case(page): # os.remove("download_test_file") -def test_send_message_from_existing_template(authenticated_page, end_to_end_context): +def test_send_message_from_existing_template(authenticated_page): page = authenticated_page - _setup(page, end_to_end_context) + _setup(page) if page.get_by_text("Create your first template").count() > 0: handle_no_existing_template_case(page) From f28bbd77a4c50197ffd5aa1da0d9f31440b6ecaf Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 9 Apr 2024 10:41:54 -0700 Subject: [PATCH 46/47] code review feedback --- tests/end_to_end/test_create_new_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/end_to_end/test_create_new_template.py b/tests/end_to_end/test_create_new_template.py index 6d344a94f..293931785 100644 --- a/tests/end_to_end/test_create_new_template.py +++ b/tests/end_to_end/test_create_new_template.py @@ -88,7 +88,7 @@ def create_new_template(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() + expect(send_messages_button).to_be_visible() send_messages_button.click() # Check to make sure that we've arrived at the next page. From 63bc85d8d4c477e4e49c5e546e56067a159c49d0 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Tue, 9 Apr 2024 12:52:45 -0700 Subject: [PATCH 47/47] added format_datetime_scheduled_notification to formatters and removed unneccesary format changes --- app/__init__.py | 2 ++ app/formatters.py | 24 ++++++++++++++++--- app/main/views/send.py | 8 +++++-- app/templates/views/check/preview.html | 2 +- .../views/notifications/preview.html | 2 +- app/utils/templates.py | 2 +- app/utils/time.py | 5 ---- tests/app/main/views/test_send.py | 6 ++--- 8 files changed, 35 insertions(+), 16 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 5292c767b..d2c61d0a0 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -52,6 +52,7 @@ from app.formatters import ( format_datetime_human, format_datetime_normal, format_datetime_relative, + format_datetime_scheduled_notification, format_datetime_table, format_day_of_week, format_delta, @@ -551,6 +552,7 @@ def add_template_filters(application): format_datetime, format_datetime_24h, format_datetime_normal, + format_datetime_scheduled_notification, format_datetime_table, valid_phone_number, linkable_name, diff --git a/app/formatters.py b/app/formatters.py index 2bb8854f3..397cbbc10 100644 --- a/app/formatters.py +++ b/app/formatters.py @@ -22,7 +22,7 @@ from notifications_utils.recipients import InvalidPhoneError, validate_phone_num from notifications_utils.take import Take from app.utils.csv import get_user_preferred_timezone -from app.utils.time import parse_dt, parse_naive_dt +from app.utils.time import parse_naive_dt def apply_html_class(tags, html_file): @@ -93,16 +93,34 @@ def format_datetime_normal(date): ) +def format_datetime_scheduled_notification(date): + # e.g. April 09, 2024 at 04:00 PM US/Eastern. + # Everything except scheduled notifications, the time is always "now". + # Scheduled notifications are the exception to the rule. + # Here we are formating and displaying the datetime without converting datetime to a different timezone. + + datetime_obj = parse_naive_dt(date) + + format_time_without_tz = datetime_obj.replace(tzinfo=timezone.utc).strftime( + "%I:%M %p" + ) + return "{} at {} {}".format( + format_date_normal(date), format_time_without_tz, get_user_preferred_timezone() + ) + + def format_datetime_table(date): # example: 03-18-2024 at 04:53 PM, intended for datetimes in tables return "{} at {}".format(format_date_numeric(date), format_time_12h(date)) def format_time_12h(date): - date = parse_dt(date) + date = parse_naive_dt(date) preferred_tz = pytz.timezone(get_user_preferred_timezone()) - return date.astimezone(preferred_tz).strftime("%I:%M %p") + return ( + date.replace(tzinfo=timezone.utc).astimezone(preferred_tz).strftime("%I:%M %p") + ) def format_datetime_relative(date): diff --git a/app/main/views/send.py b/app/main/views/send.py index 78395d243..02f7d2121 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -650,7 +650,9 @@ def check_messages(service_id, template_id, upload_id, row_index=2): @user_has_permissions("send_messages", restrict_admin_usage=True) def preview_job(service_id, template_id, upload_id, row_index=2): session["scheduled_for"] = request.form.get("scheduled_for", "") - data = _check_messages(service_id, template_id, upload_id, row_index, force_hide_sender=True) + data = _check_messages( + service_id, template_id, upload_id, row_index, force_hide_sender=True + ) return render_template( "views/check/preview.html", @@ -911,7 +913,9 @@ def preview_notification(service_id, template_id): return render_template( "views/notifications/preview.html", - **_check_notification(service_id, template_id, show_recipient=False, force_hide_sender=True), + **_check_notification( + service_id, template_id, show_recipient=False, force_hide_sender=True + ), scheduled_for=session["scheduled_for"], recipient=recipient, ) diff --git a/app/templates/views/check/preview.html b/app/templates/views/check/preview.html index b0f58157d..32b158013 100644 --- a/app/templates/views/check/preview.html +++ b/app/templates/views/check/preview.html @@ -21,7 +21,7 @@ {{ page_header('Preview') }}
-

Scheduled: {{ scheduled_for |format_datetime_normal if scheduled_for else 'Now'}}

+

Scheduled: {{ scheduled_for |format_datetime_scheduled_notification if scheduled_for else 'Now'}}

File: {{original_file_name}}

Template: {{template.name}}

From: {{ template.sender }}

diff --git a/app/templates/views/notifications/preview.html b/app/templates/views/notifications/preview.html index c1fec9e20..ce94a606f 100644 --- a/app/templates/views/notifications/preview.html +++ b/app/templates/views/notifications/preview.html @@ -43,7 +43,7 @@ {{ page_header('Preview') }} {% endif %}
-

Scheduled: {{ scheduled_for |format_datetime_normal if scheduled_for else 'Now'}}

+

Scheduled: {{ scheduled_for |format_datetime_scheduled_notification if scheduled_for else 'Now'}}

Template: {{template.name}}

From: {{ template.sender }}

To: {{ recipient }}

diff --git a/app/utils/templates.py b/app/utils/templates.py index 355f658c0..f610398b7 100644 --- a/app/utils/templates.py +++ b/app/utils/templates.py @@ -17,7 +17,7 @@ def get_template( redact_missing_personalisation=False, email_reply_to=None, sms_sender=None, - force_hide_sender=False + force_hide_sender=False, ): if "email" == template["template_type"]: return EmailPreviewTemplate( diff --git a/app/utils/time.py b/app/utils/time.py index 05f190f15..9ae24b1bd 100644 --- a/app/utils/time.py +++ b/app/utils/time.py @@ -22,8 +22,3 @@ def is_less_than_days_ago(date_from_db, number_of_days): def parse_naive_dt(dt): return parser.parse(dt, ignoretz=True) - - -def parse_dt(dt): - # Parse datetime without ignoring the timezone - return parser.parse(dt) diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index e15772833..ab35dd29b 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -979,7 +979,7 @@ def test_upload_valid_csv_shows_preview_and_table( '
A
', ( ' ' - '
' + "
" "
    " "
  • foo
  • foo
  • foo
  • " "
" @@ -992,7 +992,7 @@ def test_upload_valid_csv_shows_preview_and_table( '
B
', ( ' ' - '
' + "
" "
    " "
  • foo
  • foo
  • foo
  • " "
" @@ -1005,7 +1005,7 @@ def test_upload_valid_csv_shows_preview_and_table( '
C
', ( ' ' - '
' + "
" "
    " "
  • foo
  • foo
  • " "
"