@@ -57,6 +57,8 @@ class ContentPagesNavigationTest < ActionDispatch::IntegrationTest
57
57
58
58
test "shows the Services section title and documents with tracking" do
59
59
stub_rummager
60
+ stub_empty_guidance
61
+ stub_empty_policies
60
62
setup_variant_b
61
63
62
64
taxons = SINGLE_TAXON
@@ -85,6 +87,74 @@ class ContentPagesNavigationTest < ActionDispatch::IntegrationTest
85
87
refute page . has_css? ( 'h3' , text : "Services" )
86
88
end
87
89
90
+ test "shows the Policy section title and documents with tracking" do
91
+ stub_rummager
92
+ stub_empty_services
93
+ stub_empty_guidance
94
+ setup_variant_b
95
+
96
+ taxons = SINGLE_TAXON
97
+
98
+ setup_and_visit_content_item_with_taxons ( 'guide' , taxons )
99
+
100
+ assert page . has_css? ( 'h3' , text : "Policy and engagement" )
101
+
102
+ assert page . has_css? ( '.gem-c-document-list__item a[data-track-category="policyAndEngagementDocumentListClicked"]' , text : 'Free school meals form' )
103
+ assert page . has_css? ( '.gem-c-document-list__item a[data-track-action="1"]' , text : 'Free school meals form' )
104
+ assert page . has_css? ( '.gem-c-document-list__item a[data-track-label="/government/publications/meals"]' , text : 'Free school meals form' )
105
+ end
106
+
107
+ test "does not show the Policy section if there is no tagged content" do
108
+ stub_empty_rummager
109
+ setup_variant_b
110
+
111
+ taxons = SINGLE_TAXON
112
+
113
+ setup_and_visit_content_item_with_taxons ( 'guide' , taxons )
114
+
115
+ refute page . has_css? ( 'h3' , text : "Policy and engagement" )
116
+ end
117
+
118
+ test "shows the Guidance section title and documents with tracking" do
119
+ stub_rummager
120
+ stub_empty_services
121
+ stub_empty_policies
122
+ setup_variant_b
123
+
124
+ taxons = SINGLE_TAXON
125
+
126
+ setup_and_visit_content_item_with_taxons ( 'guide' , taxons )
127
+
128
+ assert page . has_css? ( 'h3' , text : "Guidance and regulation" )
129
+
130
+ assert page . has_css? ( '.gem-c-document-list__item a[data-track-category="guidanceAndRegulationDocumentListClicked"]' , text : 'Free school meals form' )
131
+ assert page . has_css? ( '.gem-c-document-list__item a[data-track-action="1"]' , text : 'Free school meals form' )
132
+ assert page . has_css? ( '.gem-c-document-list__item a[data-track-label="/government/publications/meals"]' , text : 'Free school meals form' )
133
+ end
134
+
135
+ test "does not show the Guidance section if there is no tagged content" do
136
+ stub_empty_rummager
137
+ setup_variant_b
138
+
139
+ taxons = SINGLE_TAXON
140
+
141
+ setup_and_visit_content_item_with_taxons ( 'guide' , taxons )
142
+
143
+ refute page . has_css? ( 'h3' , text : "Guidance and regulation" )
144
+ end
145
+
146
+ def stub_empty_services
147
+ Supergroups ::Services . any_instance . stubs ( :all_services ) . returns ( { } )
148
+ end
149
+
150
+ def stub_empty_guidance
151
+ Supergroups ::GuidanceAndRegulation . any_instance . stubs ( :tagged_content ) . returns ( [ ] )
152
+ end
153
+
154
+ def stub_empty_policies
155
+ Supergroups ::PolicyAndEngagement . any_instance . stubs ( :tagged_content ) . returns ( [ ] )
156
+ end
157
+
88
158
def setup_variant_a
89
159
ContentItemsController . any_instance . stubs ( :show_new_navigation? ) . returns ( false )
90
160
end
0 commit comments