Skip to content

Commit

Permalink
Fix the end to end tests (#542)
Browse files Browse the repository at this point in the history
Update to use nodejs 20
  • Loading branch information
CamLamb authored Feb 8, 2024
1 parent a594f33 commit 88cb49e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
5 changes: 4 additions & 1 deletion src/core/templates/menus/main_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
{% for item in menu_items %}
<li class="govuk-header__navigation-item {{ item.active_class }}">
{% if item.active_class %}
<a class="{{ item.active_class }}" href="{{ item.href }}">{{ item.text }}</a>
<a class="{{ item.active_class }}"
data-testid="main-menu-{{ item.text|lower }}"
href="{{ item.href }}">{{ item.text }}</a>
{% else %}
<a class="govuk-header__link govuk-header__link--ws"
data-testid="main-menu-{{ item.text|lower }}"
href="{{ item.href }}">{{ item.text }}</a>
{% endif %}
</li>
Expand Down
7 changes: 5 additions & 2 deletions src/e2e_tests/test_homepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.*"))

Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/e2e_tests/test_wagtail_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 88cb49e

Please sign in to comment.