Skip to content

Commit c0cf66e

Browse files
committed
WIP updates to Playwirght test
1 parent 02274b3 commit c0cf66e

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

tests/functional/test_project_creation.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from datetime import date
22

33
import pytest
4+
from django.utils.text import slugify
45
from playwright.sync_api import expect
56

67
from jobserver.authorization.roles import (
@@ -13,7 +14,9 @@
1314
pytestmark = pytest.mark.functional
1415

1516

16-
def test_can_create_a_project(login_context_for_user, page, live_server):
17+
def test_can_create_a_project(
18+
login_context_for_user, page, live_server, slack_messages
19+
):
1720
"""
1821
Test that a user with permission can successfully create a new project.
1922
@@ -37,7 +40,7 @@ def test_can_create_a_project(login_context_for_user, page, live_server):
3740

3841
page = browser_context.new_page()
3942

40-
# create the form data before we load the page, so the org and
43+
# Create the form data before we load the page, so the org and
4144
# copilot exist when Django renders the form later int he test
4245
form_data = CreateProjectFormDataFactory()
4346

@@ -53,7 +56,6 @@ def test_can_create_a_project(login_context_for_user, page, live_server):
5356

5457
# See correct meta data for new project in text above the form
5558
# (status is always set to Ongoing so we don't check this)
56-
# Created by: < user > | Created at: <today's date>
5759
metadata = page.locator("section").filter(
5860
has_text="When created, this project will automatically be saved with the following data:"
5961
)
@@ -68,10 +70,10 @@ def test_can_create_a_project(login_context_for_user, page, live_server):
6870
org_select = form.get_by_label("Link project to an organisation")
6971
copilot_select = form.get_by_label("Project Co-pilot")
7072

71-
expect(number_input).to_contain_text("")
72-
expect(name_input).to_contain_text("")
73+
expect(number_input).to_have_text("")
74+
expect(name_input).to_have_text("")
7375
expect(form.get_by_role("link", name="add a new org")).to_be_visible()
74-
expect(org_select).to_contain_text("")
76+
expect(org_select.locator("option:checked")).to_have_text("---------")
7577
expect(copilot_select.locator("option:checked")).to_have_text("---------")
7678

7779
# Insert valid data into form and submit
@@ -80,3 +82,19 @@ def test_can_create_a_project(login_context_for_user, page, live_server):
8082
org_select.select_option(value=form_data["orgs"])
8183
copilot_select.select_option(value=form_data["copilot"])
8284
form.get_by_role("button", name="Save").click()
85+
86+
# Successful redirect to the Project Created page
87+
expect(page).to_have_url(
88+
f"{live_server.url}/staff/projects/{slugify(form_data['name'])}/created/"
89+
)
90+
91+
# Check Project Created page displays the new project name and number,
92+
# the links to the new project, and a button to add project members
93+
expect(page.get_by_role("heading", name="Project created", level=1)).to_be_visible()
94+
expect(page.get_by_role("link", name="View project on Job Server")).to_be_visible()
95+
expect(
96+
page.get_by_role("link", name="View project in the Staff Area")
97+
).to_be_visible()
98+
expect(page.get_by_role("link", name="Add members to project →")).to_be_visible()
99+
100+
# Go to Audit Log and view entry for the new project

0 commit comments

Comments
 (0)