@@ -157,6 +157,54 @@ class PaymentFailedControllerSpec extends ItSpec {
157
157
158
158
}
159
159
160
+ " GET /payment-failed with No Open Banking as a Payment Method" - {
161
+
162
+ val fakeGetRequest : FakeRequest [AnyContentAsFormUrlEncoded ] = FakeRequest (" POST" , " /payment-failed" ).withSessionId().withFormUrlEncodedBody((" payment_method" , ChooseAPaymentMethodFormValues .TryAgain .entryName))
163
+ val fakeGetRequestInWelsh : FakeRequest [AnyContentAsEmpty .type ] = FakeRequest (" GET" , " /payment-failed" ).withSessionId().withLangWelsh()
164
+
165
+ " should return 200 OK" in {
166
+ PayApiStub .stubForFindBySessionId2xx(TestJourneys .ItSa .journeyAfterFailWebPayment)
167
+ val result = systemUnderTest.renderPage()(fakeGetRequest)
168
+ status(result) shouldBe Status .OK
169
+ }
170
+
171
+ " render the page with the correct sub heading in English" in {
172
+ PayApiStub .stubForFindBySessionId2xx(TestJourneys .ItSa .journeyAfterFailWebPayment)
173
+ val result = systemUnderTest.renderPage(fakeGetRequest)
174
+ val document = Jsoup .parse(contentAsString(result))
175
+ document.selectXpath(" //*[@id=\" main-content\" ]/div/div/p[1]" ).text() shouldBe " No payment has been taken from your card."
176
+ }
177
+
178
+ " render the page with the correct sub heading in Welsh" in {
179
+ PayApiStub .stubForFindBySessionId2xx(TestJourneys .ItSa .journeyAfterFailWebPayment)
180
+ val result = systemUnderTest.renderPage()(fakeGetRequestInWelsh)
181
+ val document = Jsoup .parse(contentAsString(result))
182
+ document.selectXpath(" //*[@id=\" main-content\" ]/div/div/p[1]" ).text() shouldBe " Nid oes taliad wedi’i dynnu o’ch cerdyn."
183
+ }
184
+
185
+ " render the page with the correct button content in English" in {
186
+ PayApiStub .stubForFindBySessionId2xx(TestJourneys .ItSa .journeyAfterFailWebPayment)
187
+ val result = systemUnderTest.renderPage(fakeGetRequest)
188
+ val document = Jsoup .parse(contentAsString(result))
189
+ println(document)
190
+ document.select(" .govuk-button" ).first().text() shouldBe " Check details and try again"
191
+ }
192
+
193
+ " render the page with the correct button content in Welsh" in {
194
+ PayApiStub .stubForFindBySessionId2xx(TestJourneys .ItSa .journeyAfterFailWebPayment)
195
+ val result = systemUnderTest.renderPage(fakeGetRequestInWelsh)
196
+ val document = Jsoup .parse(contentAsString(result))
197
+ document.select(" .govuk-button" ).first().text() shouldBe " Gwiriwch y manylion a rhowch gynnig arall arni"
198
+ }
199
+
200
+ " Button should redirect to TryAgain - Enter Email Address page" in {
201
+ PayApiStub .stubForFindBySessionId2xx(TestJourneys .ItSa .journeyAfterFailWebPayment)
202
+ val result = systemUnderTest.submit(fakeGetRequest)
203
+ redirectLocation(result) shouldBe Some (" /pay-by-card/email-address" )
204
+ }
205
+
206
+ }
207
+
160
208
" When Open Banking is selected" - {
161
209
val fakeGetRequest : FakeRequest [AnyContentAsFormUrlEncoded ] = FakeRequest (" POST" , " /payment-failed" ).withSessionId().withFormUrlEncodedBody((" payment_method" , ChooseAPaymentMethodFormValues .OpenBanking .entryName))
162
210
@@ -172,7 +220,7 @@ class PaymentFailedControllerSpec extends ItSpec {
172
220
val fakeGetRequest : FakeRequest [AnyContentAsFormUrlEncoded ] = FakeRequest (" POST" , " /payment-failed" ).withSessionId().withFormUrlEncodedBody((" payment_method" , ChooseAPaymentMethodFormValues .TryAgain .entryName))
173
221
174
222
" Should redirect to the Enter Email Address page" in {
175
- PayApiStub .stubForFindBySessionId2xx(TestJourneys .PfSa .journeyAfterFailWebPayment)
223
+ PayApiStub .stubForFindBySessionId2xx(TestJourneys .ItSa .journeyAfterFailWebPayment)
176
224
val result = systemUnderTest.submit(fakeGetRequest)
177
225
redirectLocation(result) shouldBe Some (" /pay-by-card/email-address" )
178
226
}
0 commit comments