This repository has been archived by the owner on Mar 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
guide_test.rb
138 lines (111 loc) · 4.09 KB
/
guide_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
require "test_helper"
require "pry"
class GuideTest < ActionDispatch::IntegrationTest
test "shows the time it was saved if it hasn't been published yet" do
now = "2015-10-10T09:00:00+00:00"
last_saved_at = "2015-10-10T08:55:00+00:00"
travel_to(now) do
example = simulate_example_as_first_edition_on_draft_stack(
govuk_content_schema_example(
"service_manual_guide",
"service_manual_guide",
updated_at: last_saved_at,
),
)
base_path = example.fetch("base_path")
stub_content_store_has_item(base_path, example)
visit base_path
within(".app-change-history") do
assert page.has_content?("5 minutes ago")
end
end
end
test "shows the time it was published if it has been published" do
travel_to Time.zone.local(2015, 10, 10, 0, 0, 0) do
setup_and_visit_example("service_manual_guide", "service_manual_guide")
within(".app-change-history") do
assert page.has_content?("about 16 hours ago")
end
end
end
test "service manual guide shows content owners" do
setup_and_visit_example("service_manual_guide", "service_manual_guide")
within(".app-metadata--heading") do
assert page.has_link?("Agile delivery community")
end
end
test "the breadcrumb contains the topic" do
setup_and_visit_example("service_manual_guide", "service_manual_guide")
within(".gem-c-breadcrumbs") do
assert page.has_link?("Service manual")
assert page.has_link?("Agile")
end
end
test "service manual guide does not show published by" do
setup_and_visit_example("service_manual_guide", "service_manual_guide_community")
within(".gem-c-metadata") do
assert_not page.has_content?("Published by")
end
end
test "displays the description for a point" do
setup_and_visit_example("service_manual_guide", "point_page")
within(".app-page-header__summary") do
assert page.has_content?("Research to develop a deep knowledge of who the service users are")
end
end
test "does not display the description for a normal guide" do
setup_and_visit_example("service_manual_guide", "service_manual_guide")
assert_not page.has_css?(".app-page-header__summary")
end
test "displays a link to give feedback" do
setup_and_visit_example("service_manual_guide", "service_manual_guide")
assert page.has_link?("Give feedback about this page")
end
test "displays the published date of the most recent change" do
setup_and_visit_example("service_manual_guide", "service_manual_guide")
within(".app-change-history") do
assert page.has_content? "Last update: 9 October 2015"
end
end
test "displays the most recent change history for a guide" do
setup_and_visit_example("service_manual_guide", "service_manual_guide")
within(".app-change-history") do
assert page.has_content? "This is our latest change"
end
end
test "displays the change history for a guide" do
setup_and_visit_example("service_manual_guide", "service_manual_guide")
within(".app-change-history__past") do
assert page.has_content? "This is another change"
assert page.has_content? "Guidance first published"
end
end
test "omits the previous history if there is only one change" do
setup_and_visit_example(
"service_manual_guide",
"service_manual_guide",
"details" => {
"change_history" => [
{
"public_timestamp" => "2015-09-01T08:17:10+00:00",
"note" => "Guidance first published",
},
],
},
)
assert_not page.has_content? "Show all page updates"
assert_not page.has_css? ".app-change-history__past"
end
test "omits the latest change and previous change if the guide has no history" do
setup_and_visit_example(
"service_manual_guide",
"service_manual_guide",
"details" => {
"change_history" => [],
},
)
assert_not page.has_content? "Last update:"
assert_not page.has_content? "Show all page updates"
assert_not page.has_css? ".app-change-history__past"
end
end