From 88cb49e2bfd22165628d999fae9816ec51dfc715 Mon Sep 17 00:00:00 2001 From: Cameron Lamb Date: Thu, 8 Feb 2024 12:09:54 +0000 Subject: [PATCH] Fix the end to end tests (#542) Update to use nodejs 20 --- Dockerfile.test | 2 +- .../management/commands/create_section_homepages.py | 2 +- src/core/templates/menus/main_menu.html | 5 ++++- src/e2e_tests/test_homepage.py | 7 +++++-- src/e2e_tests/test_wagtail_admin.py | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Dockerfile.test b/Dockerfile.test index 463bd7e41..70525ba41 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -1,7 +1,7 @@ FROM digital_workspace/wagtail:latest ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright -ENV NODE_MAJOR=18 +ENV NODE_MAJOR=20 RUN adduser pwuser diff --git a/src/content/management/commands/create_section_homepages.py b/src/content/management/commands/create_section_homepages.py index ec2e5ec1b..14be0a6c0 100644 --- a/src/content/management/commands/create_section_homepages.py +++ b/src/content/management/commands/create_section_homepages.py @@ -48,7 +48,7 @@ def handle(self, *args, **options): Page.objects.get(slug="news-and-views") except Page.DoesNotExist: news_home = NewsHome( - title="News and views", + title="News", slug="news-and-views", live=True, first_published_at=datetime.now(), diff --git a/src/core/templates/menus/main_menu.html b/src/core/templates/menus/main_menu.html index 681d14376..89b77c849 100644 --- a/src/core/templates/menus/main_menu.html +++ b/src/core/templates/menus/main_menu.html @@ -2,9 +2,12 @@ {% for item in menu_items %}
  • {% if item.active_class %} - {{ item.text }} + {{ item.text }} {% else %} {{ item.text }} {% endif %}
  • diff --git a/src/e2e_tests/test_homepage.py b/src/e2e_tests/test_homepage.py index a2ba1967d..00715ce5d 100644 --- a/src/e2e_tests/test_homepage.py +++ b/src/e2e_tests/test_homepage.py @@ -5,11 +5,14 @@ from news.factories import NewsPageFactory +from .utils import login + @pytest.mark.e2e -def test_homepage(page: Page): +def test_homepage(superuser, user, page: Page): NewsPageFactory.create_batch(5) + login(page, user) page.goto("/") expect(page).to_have_title(re.compile(r"Home.*")) @@ -24,7 +27,7 @@ def test_homepage(page: Page): page.get_by_role("heading", name="How do I?").click() page.get_by_role("heading", name="DBT news from GOV.UK").click() - news = page.get_by_role("link", name="News and views") + news = page.get_by_test_id("main-menu-news") expect(news).to_have_attribute("href", "/news-and-views/") news.click() page.get_by_role("heading", name="All news categories").click() diff --git a/src/e2e_tests/test_wagtail_admin.py b/src/e2e_tests/test_wagtail_admin.py index 4bd94e7c2..3869eae7b 100644 --- a/src/e2e_tests/test_wagtail_admin.py +++ b/src/e2e_tests/test_wagtail_admin.py @@ -20,7 +20,7 @@ def test_add_news_page(superuser, page: Page): page.get_by_role("button", name="Pages").click() page.get_by_role("link", name="Home", exact=True).click() - page.get_by_role("link", name="Explore child pages of 'News and views'").click() + page.get_by_role("link", name="Explore child pages of 'News'").click() page.get_by_role("button", name="Actions").click() page.get_by_role("link", name="Add child page").click()