From cf60dd7078919c8abe6ac9a2f43e1a43a7dc1e6c Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Wed, 30 Oct 2024 21:04:03 -0700 Subject: [PATCH 01/48] e2e best practice --- .../test_best_practices_content_pages.py | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests/end_to_end/test_best_practices_content_pages.py diff --git a/tests/end_to_end/test_best_practices_content_pages.py b/tests/end_to_end/test_best_practices_content_pages.py new file mode 100644 index 000000000..25893a649 --- /dev/null +++ b/tests/end_to_end/test_best_practices_content_pages.py @@ -0,0 +1,63 @@ +import datetime +import os +import re + +from playwright.sync_api import expect + +from tests.end_to_end.conftest import check_axe_report + +E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") + + +def test_best_practices_side_menu(authenticated_page): + page = authenticated_page + + page.goto(f"{E2E_TEST_URI}/best-practices") + + page.wait_for_load_state("domcontentloaded") + check_axe_report(page) + + page.get_by_role("link", name="Best Practices").click() + expect(page).to_have_title(re.compile("Best Practice")) + + page.get_by_role("link", name="Clear goals", exact=True).click() + expect(page).to_have_title(re.compile("Establish clear goals")) + + page.get_by_role("link", name="Rules and regulations").click() + expect(page).to_have_title(re.compile("Rules and regulations")) + + page.get_by_role("link", name="Establish trust").click() + expect(page).to_have_title(re.compile("Establish trust")) + + page.get_by_role("link", name="Write for action").click() + expect(page).to_have_title(re.compile("Write texts that provoke")) + + page.get_by_role("link", name="Multiple languages").click() + expect(page).to_have_title(re.compile("Text in multiple languages")) + + page.get_by_role("link", name="Benchmark performance").click() + expect(page).to_have_title(re.compile("Measuring performance with")) + + parent_link = page.get_by_role("link", name="Establish trust") + parent_link.hover() + + submenu_item = page.get_by_role("link", name=re.compile("Get the word out")) + submenu_item.click() + + expect(page).to_have_url(re.compile(r"#get-the-word-out")) + + anchor_target = page.locator("#get-the-word-out") + expect(anchor_target).to_be_visible() + anchor_target.click() + +def test_breadcrumbs_best_practices(authenticated_page): + + page = authenticated_page + + page.goto(f"{E2E_TEST_URI}/best-practices") + + page.wait_for_load_state("domcontentloaded") + check_axe_report(page) + + page.get_by_role("link", name="Clear goals", exact=True).click() + page.locator("ol").get_by_role("link", name="Best Practices").click() From 0bb0d3c24d39c903b9f187ea884860ec6b190fd3 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Wed, 30 Oct 2024 21:08:45 -0700 Subject: [PATCH 02/48] e2e best practice --- tests/end_to_end/test_best_practices_content_pages.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/end_to_end/test_best_practices_content_pages.py b/tests/end_to_end/test_best_practices_content_pages.py index 25893a649..fbf5cd280 100644 --- a/tests/end_to_end/test_best_practices_content_pages.py +++ b/tests/end_to_end/test_best_practices_content_pages.py @@ -1,4 +1,3 @@ -import datetime import os import re @@ -50,8 +49,8 @@ def test_best_practices_side_menu(authenticated_page): expect(anchor_target).to_be_visible() anchor_target.click() -def test_breadcrumbs_best_practices(authenticated_page): +def test_breadcrumbs_best_practices(authenticated_page): page = authenticated_page page.goto(f"{E2E_TEST_URI}/best-practices") From 109f3d99929ef84c86a1838b0d8a64f08501a038 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Thu, 31 Oct 2024 12:04:26 -0700 Subject: [PATCH 03/48] feature flag for testing --- app/main/views/index.py | 17 +++++- .../test_best_practices_content_pages.py | 58 +++++++++++-------- 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/app/main/views/index.py b/app/main/views/index.py index 8b965991c..238f2d524 100644 --- a/app/main/views/index.py +++ b/app/main/views/index.py @@ -2,7 +2,15 @@ import secrets from urllib.parse import unquote -from flask import abort, current_app, redirect, render_template, request, url_for +from flask import ( + abort, + current_app, + jsonify, + redirect, + render_template, + request, + url_for, +) from flask_login import current_user from app import redis_client, status_api_client @@ -30,6 +38,13 @@ def check_guidance_feature(): abort(404) +@main.route("/test/feature-flags") +def test_feature_flags(): + return jsonify({ + "FEATURE_BEST_PRACTICES_ENABLED": current_app.config["FEATURE_BEST_PRACTICES_ENABLED"] + }) + + @main.route("/") def index(): if current_user and current_user.is_authenticated: diff --git a/tests/end_to_end/test_best_practices_content_pages.py b/tests/end_to_end/test_best_practices_content_pages.py index fbf5cd280..962100de3 100644 --- a/tests/end_to_end/test_best_practices_content_pages.py +++ b/tests/end_to_end/test_best_practices_content_pages.py @@ -16,38 +16,43 @@ def test_best_practices_side_menu(authenticated_page): page.wait_for_load_state("domcontentloaded") check_axe_report(page) - page.get_by_role("link", name="Best Practices").click() - expect(page).to_have_title(re.compile("Best Practice")) + response = page.request.get(f"{E2E_TEST_URI}/test/feature-flags") + feature_flags = response.json() + feature_best_practices_enabled = feature_flags.get("FEATURE_BEST_PRACTICES_ENABLED") - page.get_by_role("link", name="Clear goals", exact=True).click() - expect(page).to_have_title(re.compile("Establish clear goals")) + if feature_best_practices_enabled: + page.get_by_role("link", name="Best Practices").click() + expect(page).to_have_title(re.compile("Best Practice")) - page.get_by_role("link", name="Rules and regulations").click() - expect(page).to_have_title(re.compile("Rules and regulations")) + page.get_by_role("link", name="Clear goals", exact=True).click() + expect(page).to_have_title(re.compile("Establish clear goals")) - page.get_by_role("link", name="Establish trust").click() - expect(page).to_have_title(re.compile("Establish trust")) + page.get_by_role("link", name="Rules and regulations").click() + expect(page).to_have_title(re.compile("Rules and regulations")) - page.get_by_role("link", name="Write for action").click() - expect(page).to_have_title(re.compile("Write texts that provoke")) + page.get_by_role("link", name="Establish trust").click() + expect(page).to_have_title(re.compile("Establish trust")) - page.get_by_role("link", name="Multiple languages").click() - expect(page).to_have_title(re.compile("Text in multiple languages")) + page.get_by_role("link", name="Write for action").click() + expect(page).to_have_title(re.compile("Write texts that provoke")) - page.get_by_role("link", name="Benchmark performance").click() - expect(page).to_have_title(re.compile("Measuring performance with")) + page.get_by_role("link", name="Multiple languages").click() + expect(page).to_have_title(re.compile("Text in multiple languages")) - parent_link = page.get_by_role("link", name="Establish trust") - parent_link.hover() + page.get_by_role("link", name="Benchmark performance").click() + expect(page).to_have_title(re.compile("Measuring performance with")) - submenu_item = page.get_by_role("link", name=re.compile("Get the word out")) - submenu_item.click() + parent_link = page.get_by_role("link", name="Establish trust") + parent_link.hover() - expect(page).to_have_url(re.compile(r"#get-the-word-out")) + submenu_item = page.get_by_role("link", name=re.compile("Get the word out")) + submenu_item.click() - anchor_target = page.locator("#get-the-word-out") - expect(anchor_target).to_be_visible() - anchor_target.click() + expect(page).to_have_url(re.compile(r"#get-the-word-out")) + + anchor_target = page.locator("#get-the-word-out") + expect(anchor_target).to_be_visible() + anchor_target.click() def test_breadcrumbs_best_practices(authenticated_page): @@ -58,5 +63,10 @@ def test_breadcrumbs_best_practices(authenticated_page): page.wait_for_load_state("domcontentloaded") check_axe_report(page) - page.get_by_role("link", name="Clear goals", exact=True).click() - page.locator("ol").get_by_role("link", name="Best Practices").click() + response = page.request.get(f"{E2E_TEST_URI}/test/feature-flags") + feature_flags = response.json() + feature_best_practices_enabled = feature_flags.get("FEATURE_BEST_PRACTICES_ENABLED") + + if feature_best_practices_enabled: + page.get_by_role("link", name="Clear goals", exact=True).click() + page.locator("ol").get_by_role("link", name="Best Practices").click() From 714be40851521e945199f78472d0debd0e3535e3 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Thu, 31 Oct 2024 12:26:20 -0700 Subject: [PATCH 04/48] fix testing --- app/main/views/index.py | 10 +++++++--- tests/app/test_navigation.py | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/main/views/index.py b/app/main/views/index.py index 238f2d524..baa42d05a 100644 --- a/app/main/views/index.py +++ b/app/main/views/index.py @@ -40,9 +40,13 @@ def check_guidance_feature(): @main.route("/test/feature-flags") def test_feature_flags(): - return jsonify({ - "FEATURE_BEST_PRACTICES_ENABLED": current_app.config["FEATURE_BEST_PRACTICES_ENABLED"] - }) + return jsonify( + { + "FEATURE_BEST_PRACTICES_ENABLED": current_app.config[ + "FEATURE_BEST_PRACTICES_ENABLED" + ] + } + ) @main.route("/") diff --git a/tests/app/test_navigation.py b/tests/app/test_navigation.py index 8bf52d803..99e74f9ed 100644 --- a/tests/app/test_navigation.py +++ b/tests/app/test_navigation.py @@ -217,6 +217,7 @@ "suspend_service", "template_history", "template_usage", + "test_feature_flags", "tour_step", "trial_mode", "trial_mode_new", From 7a63fcfc082e5484a38df794e41721518ed10ffa Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Tue, 5 Nov 2024 14:35:22 -0800 Subject: [PATCH 05/48] fix a11y errors --- app/assets/javascripts/enhancedTextbox.js | 14 ++++++++++---- .../sass/uswds/_uswds-theme-custom-styles.scss | 5 ----- app/templates/components/folder-path.html | 2 +- app/templates/partials/jobs/notifications.html | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/enhancedTextbox.js b/app/assets/javascripts/enhancedTextbox.js index a4965857a..bd1a04882 100644 --- a/app/assets/javascripts/enhancedTextbox.js +++ b/app/assets/javascripts/enhancedTextbox.js @@ -73,10 +73,16 @@ ); this.update = () => { - - this.$background.html( - this.highlightPlaceholders ? this.contentReplaced() : this.contentEscaped() - ); + const isEmpty = this.$textbox.val().trim() === ""; + + if (isEmpty) { + this.$background.html( + this.highlightPlaceholders ? this.contentReplaced() : this.contentEscaped() + ); + this.$background.show(); + } else { + this.$background.hide(); + } this.resize(); diff --git a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss index fe98aed09..570c1082e 100644 --- a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss +++ b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss @@ -604,17 +604,12 @@ details form { } &-background { - position: absolute; - top: 0; - left: 0; pointer-events: none; - color: transparent; white-space: pre-wrap; overflow-wrap: break-word; word-wrap: break-word; border: 2px solid transparent; padding-bottom: units(3); - z-index: 10; // transparent borders become visible in high contrast modes so set to match background @media (-ms-high-contrast: active), (forced-colors: active) { diff --git a/app/templates/components/folder-path.html b/app/templates/components/folder-path.html index c686702ba..b6615a2da 100644 --- a/app/templates/components/folder-path.html +++ b/app/templates/components/folder-path.html @@ -22,7 +22,7 @@ {{ folder.name }} {% endif %} {% else %} - Templates + Templates {% endif %} {% if not loop.last %}{{ folder_path_separator() }}{% endif %} {% endif %} diff --git a/app/templates/partials/jobs/notifications.html b/app/templates/partials/jobs/notifications.html index 379a8efef..6df3085ee 100644 --- a/app/templates/partials/jobs/notifications.html +++ b/app/templates/partials/jobs/notifications.html @@ -2,7 +2,7 @@ {% from "components/page-footer.html" import page_footer %} {% from "components/form.html" import form_wrapper %} -
+
{% if job.scheduled %}

From ca96495e3dd410d19f1bab879c04d7bb550bb0c2 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Tue, 5 Nov 2024 15:47:49 -0800 Subject: [PATCH 06/48] revert changes to color:transparent --- app/assets/javascripts/enhancedTextbox.js | 18 ++++++------------ .../sass/uswds/_uswds-theme-custom-styles.scss | 7 +++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/enhancedTextbox.js b/app/assets/javascripts/enhancedTextbox.js index bd1a04882..f0eabd940 100644 --- a/app/assets/javascripts/enhancedTextbox.js +++ b/app/assets/javascripts/enhancedTextbox.js @@ -23,7 +23,7 @@

`) .after(this.$background = $(` -