Skip to content

Commit

Permalink
Merge pull request #2074 from GSA/2073---new-best-practice-side-nav-e…
Browse files Browse the repository at this point in the history
…nd2end

e2e test for best practice content pages
  • Loading branch information
heyitsmebev authored Nov 20, 2024
2 parents 99d934c + 714be40 commit 93587f5
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 1 deletion.
21 changes: 20 additions & 1 deletion app/main/views/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -35,6 +43,17 @@ def check_feature_flags():
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:
Expand Down
1 change: 1 addition & 0 deletions tests/app/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
"suspend_service",
"template_history",
"template_usage",
"test_feature_flags",
"tour_step",
"trial_mode",
"trial_mode_new",
Expand Down
72 changes: 72 additions & 0 deletions tests/end_to_end/test_best_practices_content_pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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)

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="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)

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()

0 comments on commit 93587f5

Please sign in to comment.