-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
178 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
When upgrading wagtail, check the: | ||
# Testing | ||
|
||
- front page | ||
- news showing | ||
- content search | ||
- people finder search | ||
- people finder | ||
- view profile | ||
- edit profile | ||
- view team | ||
- edit team | ||
- django admin | ||
- wagtail admin | ||
- home news order | ||
- drag to sort | ||
- add a news page | ||
- upload and add an image | ||
- publish and view live | ||
- appears on home page | ||
- appears on news page | ||
## E2E codegen tests | ||
|
||
When writing playwright tests it might be useful to use the `make e2e-codegen` tool to help generate code. | ||
If you need to log into the admin side of the site then you can add the following to `config/urls.py`: | ||
|
||
```python | ||
# Test admin login | ||
def login_as_admin(request): | ||
from django.contrib.auth import login | ||
|
||
from user.models import User | ||
|
||
user = User.objects.filter(is_superuser=True).first() | ||
login( | ||
request, | ||
user, | ||
backend="django.contrib.auth.backends.ModelBackend", | ||
) | ||
return RedirectView.as_view(url="/")(request) | ||
|
||
urlpatterns = [ | ||
path("login-as-admin/", login_as_admin), | ||
] + urlpatterns | ||
``` | ||
|
||
Then when you are browsing the site you can go to `/login-as-admin/` to which will find a superuser and log you in as them. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## Upgrading the site | ||
When upgrading wagtail, check the: | ||
|
||
- front page | ||
- news showing | ||
- content search | ||
- people finder search | ||
- people finder | ||
- view profile | ||
- edit profile | ||
- view team | ||
- edit team | ||
- django admin | ||
- wagtail admin | ||
- home news order | ||
- drag to sort | ||
- add a news page | ||
- upload and add an image | ||
- publish and view live | ||
- appears on home page | ||
- appears on news page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import re | ||
|
||
import pytest | ||
from playwright.sync_api import Page, expect | ||
|
||
from news.factories import NewsPageFactory | ||
from news.models import NewsHome | ||
|
||
from .utils import login | ||
|
||
|
||
@pytest.mark.e2e | ||
def test_add_news_page(superuser, page: Page): | ||
news_home = NewsHome.objects.first() | ||
NewsPageFactory.create_batch(5, parent=news_home) | ||
|
||
login(page, superuser) | ||
page.goto("/admin") | ||
expect(page).to_have_title(re.compile(r".*DBT Digital Workspace")) | ||
|
||
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("button", name="Actions").click() | ||
page.get_by_role("link", name="Add child page").click() | ||
|
||
# Create a news page. | ||
page.get_by_role("textbox", name="title").fill("Test news page") | ||
page.get_by_role("button", name="Insert a block").click() | ||
page.get_by_placeholder("Search options…").fill("Heading 2") | ||
page.keyboard.press("Enter") | ||
page.locator("#body-0-value").fill("Test news page heading") | ||
|
||
# TODO: The choose an image modal doesn't seem to be appearing. | ||
# page.get_by_role("button", name="Choose an image").click() | ||
# page.locator(".image-choice").nth(0).click() | ||
|
||
# Save draft | ||
page.get_by_role("button", name="Save draft").click() | ||
|
||
# Publish | ||
page.locator("li.footer__container nav .dropdown-toggle").click() | ||
page.get_by_role("button", name="Publish").click() | ||
|
||
# Check the page is visible in the admin. | ||
page.get_by_text("Test news page") | ||
|
||
|
||
@pytest.mark.e2e | ||
def test_home_page_news_order(superuser, page: Page): | ||
news_home = NewsHome.objects.first() | ||
news_pages = NewsPageFactory.create_batch(5, parent=news_home) | ||
|
||
login(page, superuser) | ||
page.goto("/admin") | ||
expect(page).to_have_title(re.compile(r".*DBT Digital Workspace")) | ||
page.get_by_text("Home news order").click() | ||
|
||
# Add the news pages to define their order on the home page. | ||
for news_page in news_pages: | ||
page.get_by_text("Add Home page news order").click() | ||
page.get_by_text("Choose a page (News Page)").click() | ||
page.get_by_text(news_page.title).click() | ||
page.get_by_role("button", name="Save").click() | ||
|
||
# Visit the home page to see the news order | ||
page.goto("/") | ||
home_news_items = [ | ||
i.inner_text() for i in page.get_by_test_id("home-news-item").all() | ||
] | ||
|
||
# Drag the news pages to change their order. | ||
page.goto("/admin") | ||
page.get_by_text("Home news order").click() | ||
news_page_1 = page.get_by_role("link", name=news_pages[0].title) | ||
news_page_5 = page.get_by_role("link", name=news_pages[4].title) | ||
news_page_1.drag_to(news_page_5) | ||
|
||
# Visit the home page to see the updated news order | ||
page.goto("/") | ||
updated_home_news_items = [ | ||
i.inner_text() for i in page.get_by_test_id("home-news-item").all() | ||
] | ||
|
||
# Make sure the new order isn't the same as the old order. | ||
assert home_news_items != updated_home_news_items |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import factory | ||
import wagtail_factories | ||
|
||
from news import models | ||
|
||
|
||
class NewsPageFactory(wagtail_factories.PageFactory): | ||
title = factory.Sequence(lambda n: f"News page {n+1}") | ||
|
||
class Meta: | ||
model = models.NewsPage |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters