-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PP-13377 show test payment notification on card payment screens #3945
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% from "govuk/components/notification-banner/macro.njk" import govukNotificationBanner %} | ||
{% if isTestPayment === true %} | ||
{% set html %} | ||
<p class="govuk-notification-banner__heading"> | ||
This is a test page. No money will be taken. | ||
</p> | ||
<p class="govuk-body"> | ||
Contact the service you’re trying to pay for if you are trying to make a payment. | ||
</p> | ||
{% endset %} | ||
{{ govukNotificationBanner({ | ||
html: html | ||
}) }} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
test/cypress/integration/card/test-payment-notification.test.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
const cardPaymentStubs = require('../../utils/card-payment-stubs') | ||
const { adminUsersGetService } = require('../../utils/stub-builders/service-stubs') | ||
const { | ||
connectorMultipleSubsequentChargeDetails, | ||
connectorValidPatchConfirmedChargeDetails | ||
} = require('../../utils/stub-builders/charge-stubs') | ||
const { cardIdValidCardDetails } = require('../../utils/stub-builders/card-id-stubs') | ||
|
||
const tokenId = 'be88a908-3b99-4254-9807-c855d53f6b2b' | ||
const chargeId = 'ub8de8r5mh4pb49rgm1ismaqfv' | ||
const validPayment = { | ||
cardNumber: '4444333322221111', | ||
expiryMonth: '01', | ||
expiryYear: '30', | ||
name: 'S. McDuck', | ||
securityCode: '012', | ||
addressLine1: 'McDuck Manor', | ||
city: 'Duckburg', | ||
postcode: 'SW1A 1AA', | ||
email: '[email protected]' | ||
} | ||
const createPaymentChargeStubsEnglish = (isLive) => { | ||
return cardPaymentStubs.buildCreatePaymentChargeStubs(tokenId, chargeId, 'en', 42, {}, {}, { | ||
gatewayAccountType: isLive ? 'live' : 'test' | ||
}) | ||
} | ||
const checkCardDetailsStubs = (isLive) => { | ||
return cardPaymentStubs.checkCardDetailsStubs(chargeId, 42, { | ||
gatewayAccountType: isLive ? 'live' : 'test' | ||
}) | ||
} | ||
const confirmPaymentDetailsStubs = (isLive) => { | ||
const gatewayAccountType = isLive ? 'live' : 'test' | ||
return [ | ||
adminUsersGetService(), | ||
connectorMultipleSubsequentChargeDetails([ | ||
{ | ||
chargeId, | ||
status: 'AUTHORISATION READY', | ||
state: { finished: false, status: 'started' }, | ||
gatewayAccountType | ||
}, | ||
{ | ||
chargeId, | ||
paymentDetails: validPayment, | ||
status: 'AUTHORISATION READY', | ||
state: { finished: false, status: 'submitted' }, | ||
gatewayAccountType | ||
}, | ||
{ | ||
chargeId, | ||
paymentDetails: validPayment, | ||
status: 'AUTHORISATION SUCCESS', | ||
state: { finished: false, status: 'submitted' }, | ||
gatewayAccountType | ||
}, | ||
{ | ||
chargeId, | ||
paymentDetails: validPayment, | ||
status: 'AUTHORISATION SUCCESS', | ||
state: { finished: false, status: 'submitted' }, | ||
gatewayAccountType | ||
} | ||
]), | ||
cardIdValidCardDetails(), | ||
connectorValidPatchConfirmedChargeDetails(chargeId) | ||
] | ||
} | ||
|
||
|
||
|
||
describe('Card payment page', () => { | ||
describe('A test payment', () => { | ||
it('should show phase and notification banners', () => { | ||
cy.task('setupStubs', createPaymentChargeStubsEnglish(false)) | ||
cy.visit(`/secure/${tokenId}`) | ||
cy.location('pathname').should('eq', `/card_details/${chargeId}`) | ||
shouldCheckPhaseBanner() | ||
shouldCheckNotificationBanner() | ||
cy.task('clearStubs') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be easier to follow if there was a line break each time the stubs are cleared, but that may be a personal thing so I wouldn't hold it back for that reason |
||
cy.task('setupStubs', checkCardDetailsStubs(false)) | ||
shouldEnterCardDetails() | ||
cy.task('clearStubs') | ||
cy.task('setupStubs', confirmPaymentDetailsStubs(false)) | ||
cy.get('#card-details').submit() | ||
cy.location('pathname').should('eq', `/card_details/${chargeId}/auth_waiting`) | ||
shouldCheckPhaseBanner() | ||
cy.get('p.lede').should('exist') | ||
cy.location('pathname').should('eq', `/card_details/${chargeId}/confirm`) | ||
shouldCheckPhaseBanner() | ||
shouldCheckNotificationBanner() | ||
cy.get('#expiry-date').should(($td) => expect($td).to.contain(`${validPayment.expiryMonth}/${validPayment.expiryYear}`)) | ||
cy.get('#cardholder-name').should(($td) => expect($td).to.contain(validPayment.name)) | ||
}) | ||
}) | ||
describe('A live payment', () => { | ||
it('should not show phase and notification banners', () => { | ||
cy.task('setupStubs', createPaymentChargeStubsEnglish(true)) | ||
cy.visit(`/secure/${tokenId}`) | ||
cy.location('pathname').should('eq', `/card_details/${chargeId}`) | ||
cy.get('.govuk-phase-banner') | ||
.should('not.exist') | ||
cy.get('.govuk-notification-banner') | ||
.should('not.exist') | ||
cy.task('clearStubs') | ||
cy.task('setupStubs', checkCardDetailsStubs(true)) | ||
shouldEnterCardDetails() | ||
cy.task('clearStubs') | ||
cy.task('setupStubs', confirmPaymentDetailsStubs(true)) | ||
cy.get('#card-details').submit() | ||
cy.location('pathname').should('eq', `/card_details/${chargeId}/auth_waiting`) | ||
cy.get('.govuk-phase-banner') | ||
.should('not.exist') | ||
cy.get('p.lede').should('exist') | ||
cy.location('pathname').should('eq', `/card_details/${chargeId}/confirm`) | ||
cy.get('.govuk-phase-banner') | ||
.should('not.exist') | ||
cy.get('.govuk-notification-banner') | ||
.should('not.exist') | ||
cy.get('#expiry-date').should(($td) => expect($td).to.contain(`${validPayment.expiryMonth}/${validPayment.expiryYear}`)) | ||
cy.get('#cardholder-name').should(($td) => expect($td).to.contain(validPayment.name)) | ||
}) | ||
}) | ||
}) | ||
|
||
function shouldCheckPhaseBanner () { | ||
cy.get('.govuk-phase-banner') | ||
.should('exist') | ||
.should('contain.text', 'Test service') | ||
.should('contain.text', 'This is a test payment service.') | ||
} | ||
|
||
function shouldCheckNotificationBanner () { | ||
cy.get('.govuk-notification-banner') | ||
.should('exist') | ||
.find('p.govuk-notification-banner__heading') | ||
.should('contain.text', 'This is a test page. No money will be taken.') | ||
.parent() | ||
.find('p.govuk-body') | ||
.should('contain.text', 'Contact the service you’re trying to pay for if you are trying to make a payment.') | ||
} | ||
|
||
function shouldEnterCardDetails () { | ||
cy.intercept('POST', `/check_card/${chargeId}`).as('checkCard') | ||
cy.log('Should enter card details') | ||
cy.get('#card-no').type(validPayment.cardNumber) | ||
cy.get('#card-no').blur() | ||
cy.wait('@checkCard') | ||
cy.get('#expiry-month').type(validPayment.expiryMonth) | ||
cy.get('#expiry-year').type(validPayment.expiryYear) | ||
cy.get('#cardholder-name').type(validPayment.name) | ||
cy.get('#cvc').type(validPayment.securityCode) | ||
cy.get('#address-line-1').type(validPayment.addressLine1) | ||
cy.get('#address-city').type(validPayment.city) | ||
cy.get('#address-postcode').type(validPayment.postcode) | ||
cy.get('#email').type(validPayment.email) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you've added a div here but you haven't added a closing tag - is that deliberate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this div is just moved, not removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha, yes clearly it is.