Skip to content

Commit 2e8c10b

Browse files
committed
add to playwright test. check more of consideration updates/edits
1 parent 60f9a5a commit 2e8c10b

File tree

2 files changed

+121
-3
lines changed

2 files changed

+121
-3
lines changed

application/blueprints/planning_consideration/views.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def change_stage(slug):
431431
reason = {
432432
"reason": form.data["reason"],
433433
"date": datetime.datetime.today().strftime("%Y-%m-%d"),
434-
"user": session["user"]["name"],
434+
"user": session.get("user", {}).get("name", None),
435435
"changes": {
436436
"stage": {
437437
"added": consideration.stage.value,
@@ -532,7 +532,10 @@ def add_note(slug):
532532
form = NoteForm()
533533

534534
if form.validate_on_submit():
535-
note = Note(text=form.text.data, author=session["user"]["name"])
535+
note = Note(
536+
text=form.text.data,
537+
author=session.get("user", {}).get("name", "User not logged in"),
538+
)
536539
if consideration.notes is None:
537540
consideration.notes = []
538541
consideration.notes.append(note)

tests/test_app.py

+116-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,122 @@
22
from playwright.sync_api import expect
33

44

5-
def test_add_consideration(live_server, page, questions):
5+
def test_add_and_update_planning_consideration(live_server, page):
6+
page.goto(url_for("planning_consideration.considerations", _external=True))
7+
page.get_by_role("link", name="+Add planning consideration").click()
8+
page.get_by_label("Name").click()
9+
page.get_by_label("Name").fill("This is a test consideration")
10+
page.get_by_label("Github disucssion number").click()
11+
page.get_by_label("Github disucssion number").fill("22")
12+
page.get_by_label("Description").click()
13+
page.get_by_label("Description").fill("This is the description")
14+
page.get_by_role("button", name="Create").click()
15+
expect(
16+
page.locator("#details").get_by_text("This is a test consideration")
17+
).to_be_visible()
18+
expect(page.get_by_text("This is the description")).to_be_visible()
19+
expect(page.get_by_role("link", name="22")).to_be_visible()
20+
21+
page.locator("#details").get_by_role(
22+
"link", name="Change planning consideration name"
23+
).click()
24+
page.get_by_label("Name").click()
25+
page.get_by_label("Name").fill("This is a test consideration that is being updated")
26+
page.get_by_role("button", name="Save changes").click()
27+
expect(
28+
page.locator("#details").get_by_text("This is a test consideration")
29+
).to_be_visible()
30+
31+
page.locator("#details").get_by_text("This is a test consideration").click()
32+
page.get_by_role("link", name="Change planning consideration description").click()
33+
page.get_by_label("Description").click()
34+
page.get_by_label("Description").fill(
35+
"This is the description that has been updated"
36+
)
37+
page.get_by_role("button", name="Save changes").click()
38+
expect(page.get_by_text("This is the description that")).to_be_visible()
39+
40+
page.get_by_role("link", name="Add link to applicable specification").click()
41+
page.get_by_label("Title").click()
42+
page.get_by_label("Title").fill("this is the specification")
43+
page.get_by_label("URL").fill("http://specification.com")
44+
page.get_by_role("button", name="Save changes").click()
45+
expect(page.get_by_role("link", name="this is the specification")).to_be_visible()
46+
assert (
47+
page.get_by_role("link", name="this is the specification").get_attribute("href")
48+
== "http://specification.com"
49+
)
50+
51+
page.get_by_role("link", name="Add link to applicable schemas").click()
52+
page.get_by_label("Schema name").click()
53+
page.get_by_label("Schema name").fill("this is the schema")
54+
page.get_by_label("URL").click()
55+
page.get_by_label("URL").fill("http://schema.com")
56+
page.get_by_role("button", name="Save schema").click()
57+
expect(page.get_by_role("link", name="this is the schema")).to_be_visible()
58+
assert (
59+
page.get_by_role("link", name="this is the schema").get_attribute("href")
60+
== "http://schema.com"
61+
)
62+
expect(page.get_by_role("link", name="Remove")).to_be_visible()
63+
64+
page.get_by_role("link", name="Remove").click()
65+
expect(
66+
page.locator("#data-related dl div")
67+
.filter(has_text="Schemas Add link to")
68+
.get_by_role("definition")
69+
.first
70+
).to_be_visible()
71+
72+
page.get_by_role("link", name="Change expected number of").click()
73+
page.get_by_label("Expected number of records").click()
74+
page.get_by_label("Expected number of records").fill("10000")
75+
page.get_by_role("button", name="Save changes").click()
76+
expect(page.get_by_text("10,000")).to_be_visible()
77+
page.get_by_role("link", name="Change frequency of updates").click()
78+
page.get_by_label("Annually").check()
79+
page.get_by_role("button", name="Save").click()
80+
expect(page.locator("#data-related")).to_contain_text("Annually")
81+
page.get_by_role("link", name="Change frequency of updates").click()
82+
page.get_by_label("Daily").check()
83+
page.get_by_role("button", name="Save").click()
84+
expect(page.locator("#data-related")).to_contain_text("Daily")
85+
86+
page.get_by_role("link", name="Change planning consideration stage").click()
87+
page.get_by_label("Research").check()
88+
page.get_by_role("button", name="Update").click()
89+
expect(page.locator("#flags")).to_contain_text("Research")
90+
page.locator("dt").filter(has_text="Prioritised Change planning").get_by_role(
91+
"link"
92+
).click()
93+
page.get_by_label("Yes").check()
94+
page.get_by_role("button", name="Set prioritisation").click()
95+
expect(page.locator("#flags")).to_contain_text("True")
96+
page.locator("dt").filter(has_text="Public Change planning").get_by_role(
97+
"link"
98+
).click()
99+
page.get_by_label("No").check()
100+
page.get_by_role("button", name="Set").click()
101+
expect(page.locator("#flags")).to_contain_text("False")
102+
page.locator("dt").filter(has_text="Public Change planning").get_by_role(
103+
"link"
104+
).click()
105+
page.get_by_label("Yes").check()
106+
page.get_by_role("button", name="Set").click()
107+
expect(page.locator("#flags")).to_contain_text("True")
108+
109+
page.get_by_role("link", name="+Add note").click()
110+
page.get_by_label("Note").click()
111+
page.get_by_label("Note").fill(
112+
"This is a test of a note that should appear on the page."
113+
)
114+
page.get_by_role("button", name="Save note").click()
115+
expect(page.locator("#notes")).to_contain_text(
116+
"This is a test of a note that should appear on the page."
117+
)
118+
119+
120+
def test_add_answer_backlog_questions(live_server, page, questions):
6121

7122
page.goto(url_for("planning_consideration.considerations", _external=True))
8123
page.get_by_role("link", name="+Add planning consideration").click()

0 commit comments

Comments
 (0)