@@ -51,7 +51,7 @@
})
}}
-
Cancel
+
Cancel
{% endblock %}
diff --git a/test/cypress/integration/payment-links/create-payment-link.cy.test.js b/test/cypress/integration/payment-links/create-payment-link.cy.test.js
index 0402d2aaf2..c95b922593 100644
--- a/test/cypress/integration/payment-links/create-payment-link.cy.test.js
+++ b/test/cypress/integration/payment-links/create-payment-link.cy.test.js
@@ -4,6 +4,7 @@ const tokenStubs = require('../../stubs/token-stubs')
const productStubs = require('../../stubs/products-stubs')
const userExternalId = 'a-user-id'
const gatewayAccountId = 42
+const gatewayAccountExternalId = 'a-valid-account-id'
const serviceName = {
en: 'pay for something',
cy: 'talu am rywbeth'
@@ -13,7 +14,7 @@ describe('The create payment link flow', () => {
beforeEach(() => {
cy.task('setupStubs', [
userStubs.getUserSuccess({ userExternalId: userExternalId, gatewayAccountId, serviceName }),
- gatewayAccountStubs.getGatewayAccountSuccess({ gatewayAccountId, type: 'test', paymentProvider: 'worldpay' }),
+ gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId, type: 'test', paymentProvider: 'worldpay' }),
tokenStubs.postCreateTokenForAccountSuccess({ gatewayAccountId }),
productStubs.postCreateProductSuccess(),
productStubs.getProductsStub([{ name: 'A payment link' }], gatewayAccountId)
@@ -31,22 +32,22 @@ describe('The create payment link flow', () => {
describe('The create payment link start page', () => {
it('Should display page content', () => {
cy.setEncryptedCookies(userExternalId, gatewayAccountId)
- cy.visit('/create-payment-link')
+ cy.visit(`/account/${gatewayAccountExternalId}/create-payment-link`)
cy.get('h1').should('contain', 'Create a payment link')
cy.get('a#create-payment-link').should('exist')
- cy.get('a[href="/create-payment-link/information?language=cy"]').should('exist')
+ cy.get(`a[href="/account/${gatewayAccountExternalId}/create-payment-link/information?language=cy"]`).should('exist')
.should('contain', 'Create a payment link in Welsh')
})
it('Should navigate to create payment link in English information page', () => {
cy.setEncryptedCookies(userExternalId, gatewayAccountId)
- cy.visit('/create-payment-link')
+ cy.visit(`/account/${gatewayAccountExternalId}/create-payment-link`)
cy.get('a#create-payment-link').click()
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/information`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/information`)
})
})
})
@@ -55,7 +56,7 @@ describe('The create payment link flow', () => {
it('Should display instructions for an English payment link', () => {
cy.get('h1').should('contain', 'Set payment link information')
- cy.get('form[method=post][action="/create-payment-link/information"]').should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/information"]`).should('exist')
.within(() => {
cy.get('input#payment-link-title').should('exist')
cy.get('input#payment-link-title').should('have.attr', 'lang', 'en')
@@ -81,7 +82,7 @@ describe('The create payment link flow', () => {
})
it('Should display URL when title is entered', () => {
- cy.get('form[method=post][action="/create-payment-link/information"]').within(() => {
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/information"]`).within(() => {
cy.get('input#payment-link-title').type(name)
cy.get('textarea#payment-link-description').type(description)
@@ -93,12 +94,12 @@ describe('The create payment link flow', () => {
})
it('Should continue to the reference page', () => {
- cy.get('form[method=post][action="/create-payment-link/information"]').within(() => {
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/information"]`).within(() => {
cy.get('button').click()
})
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/reference`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/reference`)
})
})
})
@@ -108,7 +109,7 @@ describe('The create payment link flow', () => {
cy.get('h1').should('contain', 'Do your users already have a payment reference?')
cy.get('#reference-type-group-hint').should('contain', `You can use numbers or words in your payment reference. For example, you can include the applicant’s name or an existing reference number.`)
- cy.get('form[method=post][action="/create-payment-link/reference"]').should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/reference"]`).should('exist')
.within(() => {
cy.get('input[type=radio]#reference-type-custom').should('exist')
cy.get('input[type=radio]#reference-type-standard').should('exist')
@@ -134,7 +135,7 @@ describe('The create payment link flow', () => {
})
it('should continue to the amount page', () => {
- cy.get('form[method=post][action="/create-payment-link/reference"]').should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/reference"]`).should('exist')
.within(() => {
cy.get('input#reference-label').type(referenceName)
cy.get('textarea#reference-hint-text').type(referenceHint)
@@ -142,14 +143,14 @@ describe('The create payment link flow', () => {
})
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/amount`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/amount`)
})
})
})
describe('Amount page', () => {
it('should display content', () => {
- cy.get('form[method=post][action="/create-payment-link/amount"]').should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/amount"]`).should('exist')
.within(() => {
cy.get('input[type=radio]#amount-type-fixed').should('exist')
cy.get('input[type=radio]#amount-type-variable').should('exist')
@@ -164,7 +165,7 @@ describe('The create payment link flow', () => {
})
it('should continue to the confirm page', () => {
- cy.get('form[method=post][action="/create-payment-link/amount"]').should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/amount"]`).should('exist')
.within(() => {
cy.get('input[type=radio]#amount-type-fixed').click()
cy.get('input#payment-amount').type(amount)
@@ -172,7 +173,7 @@ describe('The create payment link flow', () => {
})
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/review`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/review`)
})
})
})
@@ -182,23 +183,23 @@ describe('The create payment link flow', () => {
cy.get('.govuk-summary-list').find('.govuk-summary-list__row').eq(0).should('exist').within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Title')
cy.get('.govuk-summary-list__value').should('contain', name)
- cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', '/create-payment-link/information?field=payment-link-title')
+ cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/account/${gatewayAccountExternalId}/create-payment-link/information?field=payment-link-title`)
})
cy.get('.govuk-summary-list').find('.govuk-summary-list__row').eq(1).should('exist').within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'More details')
cy.get('.govuk-summary-list__value').should('contain', description)
- cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', '/create-payment-link/information?field=payment-link-description')
+ cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/account/${gatewayAccountExternalId}/create-payment-link/information?field=payment-link-description`)
})
cy.get('.govuk-summary-list').find('.govuk-summary-list__row').eq(2).should('exist').within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Reference number')
cy.get('.govuk-summary-list__value').should('contain', referenceName)
cy.get('.govuk-summary-list__value').get('span').should('contain', referenceHint)
- cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', '/create-payment-link/reference?change=true')
+ cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/account/${gatewayAccountExternalId}/create-payment-link/reference?change=true`)
})
cy.get('.govuk-summary-list').find('.govuk-summary-list__row').eq(3).should('exist').within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Payment amount')
cy.get('.govuk-summary-list__value').should('contain', '£10.00')
- cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', '/create-payment-link/amount')
+ cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/account/${gatewayAccountExternalId}/create-payment-link/amount`)
})
cy.get('button').should('exist').should('contain', 'Create payment link')
@@ -207,12 +208,12 @@ describe('The create payment link flow', () => {
it('should show reporting column component', () => {
cy.get('a#add-reporting-column').should('exist').should('contain', 'Add a reporting column')
cy.get('a#add-reporting-column').click()
- cy.location().should((location) => expect(location.pathname).to.eq('/create-payment-link/add-reporting-column'))
+ cy.location().should((location) => expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/add-reporting-column`))
})
it('should reject empty values and accept valid input', () => {
cy.get('button#submit-reporting-column').click()
- cy.location().should((location) => expect(location.pathname).to.eq('/create-payment-link/add-reporting-column'))
+ cy.location().should((location) => expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/add-reporting-column`))
cy.get('div.govuk-error-summary').should('exist')
})
@@ -220,7 +221,7 @@ describe('The create payment link flow', () => {
cy.get('input#metadata-column-header').type('key')
cy.get('input#metadata-cell-value').type('value')
cy.get('button#submit-reporting-column').click()
- cy.location().should((location) => expect(location.pathname).to.eq('/create-payment-link/review'))
+ cy.location().should((location) => expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/review`))
})
it('should list added reporting columns', () => {
@@ -229,7 +230,7 @@ describe('The create payment link flow', () => {
cy.get('#reporting-columns-summary').find('.govuk-summary-list__row').eq(0).should('exist').within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'key')
cy.get('.govuk-summary-list__value').should('contain', 'value')
- cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', '/create-payment-link/add-reporting-column/key')
+ cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/account/${gatewayAccountExternalId}/create-payment-link/add-reporting-column/key`)
})
})
@@ -237,7 +238,7 @@ describe('The create payment link flow', () => {
cy.get('dl').find('.govuk-summary-list__row').eq(0).find('.govuk-summary-list__actions a').click()
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/information`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/information`)
})
})
@@ -252,13 +253,13 @@ describe('The create payment link flow', () => {
})
it('should go back to the review page', () => {
- cy.get('form[method=post][action="/create-payment-link/information"]').should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/information"]`).should('exist')
.within(() => {
cy.get('button').click()
})
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/review`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/review`)
})
cy.get('.govuk-notification-banner--success').should('contain', 'The details have been updated')
@@ -267,7 +268,7 @@ describe('The create payment link flow', () => {
it('should redirect to the manage payment link page with a success message', () => {
cy.get('button').contains('Create payment link').click()
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/manage`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/manage`)
})
cy.get('.govuk-notification-banner--success').should('contain', 'Your Payment link is ready to test')
@@ -285,12 +286,12 @@ describe('The create payment link flow', () => {
describe('The create payment link start page', () => {
it('Should navigate to create payment link in Welsh information page', () => {
cy.setEncryptedCookies(userExternalId, gatewayAccountId)
- cy.visit('/create-payment-link')
+ cy.visit(`/account/${gatewayAccountExternalId}/create-payment-link`)
- cy.get('a[href="/create-payment-link/information?language=cy"]').click()
+ cy.get(`a[href="/account/${gatewayAccountExternalId}/create-payment-link/information?language=cy"]`).click()
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/information`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/information`)
})
})
})
@@ -299,7 +300,7 @@ describe('The create payment link flow', () => {
it('Should display Welsh-specific instructions', () => {
cy.get('h1').should('contain', 'Set Welsh payment link information')
- cy.get('form[method=post][action="/create-payment-link/information"]').should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/information"]`).should('exist')
.within(() => {
cy.get('input#payment-link-title').should('exist')
cy.get('input#payment-link-title').should('have.attr', 'lang', 'cy')
@@ -320,7 +321,7 @@ describe('The create payment link flow', () => {
})
it('Should display URL with Welsh service name when title is entered', () => {
- cy.get('form[method=post][action="/create-payment-link/information"]').within(() => {
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/information"]`).within(() => {
cy.get('input#payment-link-title').type(name)
cy.get('textarea#payment-link-description').type(description)
@@ -332,12 +333,12 @@ describe('The create payment link flow', () => {
})
it('Should continue to the reference page', () => {
- cy.get('form[method=post][action="/create-payment-link/information"]').within(() => {
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/information"]`).within(() => {
cy.get('button').click()
})
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/reference`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/reference`)
})
})
})
@@ -347,7 +348,7 @@ describe('The create payment link flow', () => {
cy.get('h1').should('contain', 'Do your users already have a payment reference?')
cy.get('#reference-type-group-hint').should('contain', `You can use numbers or words in your payment reference. For example, you can include the applicant’s name or an existing reference number.`)
- cy.get('form[method=post][action="/create-payment-link/reference"]').should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/reference"]`).should('exist')
.within(() => {
cy.get('input[type=radio]#reference-type-custom').should('exist')
cy.get('input[type=radio]#reference-type-custom').click()
@@ -369,7 +370,7 @@ describe('The create payment link flow', () => {
})
it('should continue to the amount page', () => {
- cy.get('form[method=post][action="/create-payment-link/reference"]').should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/reference"]`).should('exist')
.within(() => {
cy.get('input#reference-label').type(referenceName)
cy.get('textarea#reference-hint-text').type(referenceHint)
@@ -377,14 +378,14 @@ describe('The create payment link flow', () => {
})
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/amount`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/amount`)
})
})
})
describe('Amount page', () => {
it('should display content', () => {
- cy.get('form[method=post][action="/create-payment-link/amount"]').should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/amount"]`).should('exist')
.within(() => {
cy.get('input[type=radio]#amount-type-fixed').should('exist')
cy.get('input[type=radio]#amount-type-variable').should('exist')
@@ -396,7 +397,7 @@ describe('The create payment link flow', () => {
})
it('should continue to the confirm page', () => {
- cy.get('form[method=post][action="/create-payment-link/amount"]').should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/amount"]`).should('exist')
.within(() => {
cy.get('input[type=radio]#amount-type-fixed').click()
cy.get('input#payment-amount').type(amount)
@@ -404,7 +405,7 @@ describe('The create payment link flow', () => {
})
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/review`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/review`)
})
})
})
@@ -419,7 +420,7 @@ describe('The create payment link flow', () => {
it('should return to the start page', () => {
cy.get('nav').contains('Create a payment link').click()
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link`)
})
})
@@ -427,14 +428,14 @@ describe('The create payment link flow', () => {
cy.get('a#create-payment-link').click()
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/information`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/information`)
})
cy.get('h1').should('contain', 'Set payment link information')
})
it('should have empty inputs', () => {
- cy.get('form[method=post][action="/create-payment-link/information"]').should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/information"]`).should('exist')
.within(() => {
cy.get('input#payment-link-title').should('be.empty')
cy.get('textarea#payment-link-description').should('be.empty')
diff --git a/test/cypress/integration/payment-links/delete-payment-links.cy.test.js b/test/cypress/integration/payment-links/delete-payment-links.cy.test.js
index acea78bfb4..2e2383d9d8 100644
--- a/test/cypress/integration/payment-links/delete-payment-links.cy.test.js
+++ b/test/cypress/integration/payment-links/delete-payment-links.cy.test.js
@@ -2,6 +2,7 @@ const gatewayAccountStubs = require('../../stubs/gateway-account-stubs')
const userStubs = require('../../stubs/user-stubs')
const { getProductsStub, getProductByExternalIdStub, deleteProductStub } = require('../../stubs/products-stubs')
const userExternalId = 'a-user-id'
+const gatewayAccountExternalId = 'a-valid-account-id'
const gatewayAccountId = 42
const productExternalId = 'a-product-id'
@@ -14,7 +15,7 @@ describe('Should delete payment link', () => {
cy.setEncryptedCookies(userExternalId, gatewayAccountId)
cy.task('setupStubs', [
userStubs.getUserSuccess({ userExternalId, gatewayAccountId }),
- gatewayAccountStubs.getGatewayAccountSuccess({ gatewayAccountId, type: 'test', paymentProvider: 'worldpay' }),
+ gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId, type: 'test', paymentProvider: 'worldpay' }),
getProductsStub([product], gatewayAccountId),
getProductByExternalIdStub(product, gatewayAccountId),
deleteProductStub(product, gatewayAccountId, 1)
@@ -22,7 +23,7 @@ describe('Should delete payment link', () => {
})
it('should list a single English payment links and have no Welsh payment links section', () => {
- cy.visit('/create-payment-link/manage')
+ cy.visit(`/account/${gatewayAccountExternalId}/create-payment-link/manage`)
cy.get('h1').should('contain', 'Manage payment links')
cy.get('.payment-links-list--header').should('contain',
diff --git a/test/cypress/integration/payment-links/edit-payment-link.cy.test.js b/test/cypress/integration/payment-links/edit-payment-link.cy.test.js
index ac859aa320..bfaba910e0 100644
--- a/test/cypress/integration/payment-links/edit-payment-link.cy.test.js
+++ b/test/cypress/integration/payment-links/edit-payment-link.cy.test.js
@@ -3,6 +3,7 @@ const gatewayAccountStubs = require('../../stubs/gateway-account-stubs')
const { getProductsStub, getProductByExternalIdStub } = require('../../stubs/products-stubs')
const userExternalId = 'a-user-id'
const gatewayAccountId = 42
+const gatewayAccountExternalId = 'a-valid-account-id'
const buildPaymentLinkOpts = function buildPaymentLinkOpts (externalId, name, language, description, price, referenceEnabled, referenceLabel, referenceHint, metadata = null) {
return {
@@ -22,7 +23,7 @@ const buildPaymentLinkOpts = function buildPaymentLinkOpts (externalId, name, la
function setupStubs (product) {
cy.task('setupStubs', [
userStubs.getUserSuccess({ userExternalId, gatewayAccountId }),
- gatewayAccountStubs.getGatewayAccountSuccess({ gatewayAccountId, type: 'test', paymentProvider: 'worldpay' }),
+ gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId, type: 'test', paymentProvider: 'worldpay' }),
getProductsStub([product], gatewayAccountId),
getProductByExternalIdStub(product, gatewayAccountId)
])
@@ -49,12 +50,12 @@ describe('Editing a payment link', () => {
it('should navigate to the edit page', () => {
cy.setEncryptedCookies(userExternalId, gatewayAccountId)
- cy.visit('/create-payment-link/manage')
+ cy.visit(`/account/${gatewayAccountExternalId}/create-payment-link/manage`)
cy.get('ul.payment-links-list > li > div > a').contains('Edit').click()
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/manage/edit/${productId}`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/${productId}`)
})
})
@@ -64,23 +65,23 @@ describe('Editing a payment link', () => {
cy.get('#payment-link-summary').find('.govuk-summary-list__row').eq(0).should('exist').within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Title')
cy.get('.govuk-summary-list__value').should('contain', name)
- cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/create-payment-link/manage/edit/information/${productId}?field=payment-link-title`)
+ cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/information/${productId}?field=payment-link-title`)
})
cy.get('#payment-link-summary').find('.govuk-summary-list__row').eq(1).should('exist').within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'More details')
cy.get('.govuk-summary-list__value').should('contain', description)
- cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/create-payment-link/manage/edit/information/${productId}?field=payment-link-description`)
+ cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/information/${productId}?field=payment-link-description`)
})
cy.get('#payment-link-summary').find('.govuk-summary-list__row').eq(2).should('exist').within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Reference number')
cy.get('.govuk-summary-list__value').should('contain', referenceLabel)
cy.get('.govuk-summary-list__value').should('contain', referenceHint)
- cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/create-payment-link/manage/edit/reference/${productId}?change=true`)
+ cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/reference/${productId}?change=true`)
})
cy.get('#payment-link-summary').find('.govuk-summary-list__row').eq(3).should('exist').within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Payment amount')
cy.get('.govuk-summary-list__value').should('contain', '£10.00')
- cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/create-payment-link/manage/edit/amount/${productId}`)
+ cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/amount/${productId}`)
})
cy.get('button').should('exist').should('contain', 'Save changes')
})
@@ -91,17 +92,17 @@ describe('Editing a payment link', () => {
cy.get('#reporting-columns-summary').find('.govuk-summary-list__row').eq(0).should('exist').within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'cost_code')
cy.get('.govuk-summary-list__value').should('contain', '12345')
- cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/create-payment-link/manage/${productId}/add-reporting-column/cost_code`)
+ cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/account/${gatewayAccountExternalId}/create-payment-link/manage/${productId}/add-reporting-column/cost_code`)
})
cy.get('#reporting-columns-summary').find('.govuk-summary-list__row').eq(1).should('exist').within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Finance team')
cy.get('.govuk-summary-list__value').should('contain', 'Licensing')
- cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/create-payment-link/manage/${productId}/add-reporting-column/Finance%20team`)
+ cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/account/${gatewayAccountExternalId}/create-payment-link/manage/${productId}/add-reporting-column/Finance%20team`)
})
cy.get('#reporting-columns-summary').find('.govuk-summary-list__row').eq(2).should('exist').within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'group')
cy.get('.govuk-summary-list__value').should('contain', 'A')
- cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/create-payment-link/manage/${productId}/add-reporting-column/group`)
+ cy.get('.govuk-summary-list__actions a').should('have.attr', 'href', `/account/${gatewayAccountExternalId}/create-payment-link/manage/${productId}/add-reporting-column/group`)
})
cy.get('a.govuk-button--secondary').should('exist').should('contain', 'Add another reporting column')
})
@@ -110,14 +111,14 @@ describe('Editing a payment link', () => {
cy.get('.govuk-summary-list__row').eq(0).find('.govuk-summary-list__actions a').click()
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/manage/edit/information/${productId}`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/information/${productId}`)
})
})
it('should have English instructions', () => {
cy.get('h1').should('contain', 'Edit payment link information')
- cy.get(`form[method=post][action="/create-payment-link/manage/edit/information/${productId}"]`).should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/information/${productId}"]`).should('exist')
.within(() => {
cy.get('input#payment-link-title').should('exist')
cy.get('input#payment-link-title').should('have.attr', 'lang', 'en')
@@ -148,12 +149,12 @@ describe('Editing a payment link', () => {
})
it('should navigate to edit details page when "Save changes" clicked', () => {
- cy.get(`form[method=post][action="/create-payment-link/manage/edit/information/${productId}"]`).within(() => {
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/information/${productId}"]`).within(() => {
cy.get('button').click()
})
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/manage/edit/${productId}`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/${productId}`)
})
})
@@ -161,12 +162,12 @@ describe('Editing a payment link', () => {
cy.get('.govuk-summary-list__row').eq(2).find('.govuk-summary-list__actions a').click()
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/manage/edit/reference/${productId}`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/reference/${productId}`)
})
})
it('should have English instructions', () => {
- cy.get(`form[method=post][action="/create-payment-link/manage/edit/reference/${productId}"]`).should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/reference/${productId}"]`).should('exist')
.within(() => {
cy.get('input[type="radio"]').should('have.length', 2)
@@ -198,12 +199,12 @@ describe('Editing a payment link', () => {
})
it('should navigate to edit details page when "Save changes" clicked', () => {
- cy.get(`form[method=post][action="/create-payment-link/manage/edit/reference/${productId}"]`).within(() => {
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/reference/${productId}"]`).within(() => {
cy.get('button').click()
})
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/manage/edit/${productId}`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/${productId}`)
})
})
@@ -211,12 +212,12 @@ describe('Editing a payment link', () => {
cy.get('.govuk-summary-list__row').eq(3).find('.govuk-summary-list__actions a').click()
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/manage/edit/amount/${productId}`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/amount/${productId}`)
})
})
it('should display content', () => {
- cy.get(`form[method=post][action="/create-payment-link/manage/edit/amount/${productId}"]`).should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/amount/${productId}"]`).should('exist')
.within(() => {
cy.get('input[type=radio]#amount-type-fixed').should('exist')
cy.get('input[type=radio]#amount-type-variable').should('exist')
@@ -231,19 +232,19 @@ describe('Editing a payment link', () => {
})
it('should have amount pre-filled', () => {
- cy.get(`form[method=post][action="/create-payment-link/manage/edit/amount/${productId}"]`).should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/amount/${productId}"]`).should('exist')
.within(() => {
cy.get('input#payment-amount').should('have.value', '10.00')
})
})
it('should navigate to edit details page when "Save changes" clicked', () => {
- cy.get(`form[method=post][action="/create-payment-link/manage/edit/amount/${productId}"]`).within(() => {
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/amount/${productId}"]`).within(() => {
cy.get('button').click()
})
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/manage/edit/${productId}`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/${productId}`)
})
})
})
@@ -260,12 +261,12 @@ describe('Editing a payment link', () => {
it('should navigate to the edit page', () => {
cy.setEncryptedCookies(userExternalId, gatewayAccountId)
- cy.visit('/create-payment-link/manage')
+ cy.visit(`/account/${gatewayAccountExternalId}/create-payment-link/manage`)
cy.get('ul.payment-links-list > li > div > a').contains('Edit').click()
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/manage/edit/${productId}`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/${productId}`)
})
})
@@ -273,14 +274,14 @@ describe('Editing a payment link', () => {
cy.get('.govuk-summary-list__row').eq(0).find('.govuk-summary-list__actions a').click()
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/manage/edit/information/${productId}`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/information/${productId}`)
})
})
it('should have Welsh instructions', () => {
cy.get('h1').should('contain', 'Edit payment link information')
- cy.get(`form[method=post][action="/create-payment-link/manage/edit/information/${productId}"]`).should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/information/${productId}"]`).should('exist')
.within(() => {
cy.get('input#payment-link-title').should('exist')
cy.get('input#payment-link-title').should('have.attr', 'lang', 'cy')
@@ -303,12 +304,12 @@ describe('Editing a payment link', () => {
})
it('should navigate to edit details page when "Save changes" clicked', () => {
- cy.get(`form[method=post][action="/create-payment-link/manage/edit/information/${productId}"]`).within(() => {
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/information/${productId}"]`).within(() => {
cy.get('button').click()
})
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/manage/edit/${productId}`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/${productId}`)
})
})
@@ -316,12 +317,12 @@ describe('Editing a payment link', () => {
cy.get('.govuk-summary-list__row').eq(2).find('.govuk-summary-list__actions a').click()
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/manage/edit/reference/${productId}`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/reference/${productId}`)
})
})
it('should have Welsh instructions', () => {
- cy.get(`form[method=post][action="/create-payment-link/manage/edit/reference/${productId}"]`).should('exist')
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/reference/${productId}"]`).should('exist')
.within(() => {
cy.get('input[type="radio"]').should('have.length', 2)
@@ -343,12 +344,12 @@ describe('Editing a payment link', () => {
})
it('should navigate to edit details page when "Save changes" clicked', () => {
- cy.get(`form[method=post][action="/create-payment-link/manage/edit/reference/${productId}"]`).within(() => {
+ cy.get(`form[method=post][action="/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/reference/${productId}"]`).within(() => {
cy.get('button').click()
})
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/manage/edit/${productId}`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/${productId}`)
})
})
@@ -356,7 +357,7 @@ describe('Editing a payment link', () => {
cy.get('.govuk-summary-list__row').eq(3).find('.govuk-summary-list__actions a').click()
cy.location().should((location) => {
- expect(location.pathname).to.eq(`/create-payment-link/manage/edit/amount/${productId}`)
+ expect(location.pathname).to.eq(`/account/${gatewayAccountExternalId}/create-payment-link/manage/edit/amount/${productId}`)
})
})
diff --git a/test/cypress/integration/payment-links/manage-payment-links.cy.test.js b/test/cypress/integration/payment-links/manage-payment-links.cy.test.js
index 14f4d2552e..d2256294a3 100644
--- a/test/cypress/integration/payment-links/manage-payment-links.cy.test.js
+++ b/test/cypress/integration/payment-links/manage-payment-links.cy.test.js
@@ -4,6 +4,7 @@ const gatewayAccountStubs = require('../../stubs/gateway-account-stubs')
const productStubs = require('../../stubs/products-stubs')
const userExternalId = 'a-user-id'
const gatewayAccountId = 42
+const gatewayAccountExternalId = 'a-valid-account-id'
const buildPaymentLinkOpts = function buildPaymentLinkOpts (name, href, language) {
return {
@@ -39,7 +40,7 @@ const buildPaymentLinkWithMetadataOpts = function buildPaymentLinkWithMetadataOp
function setupStubs (products) {
cy.task('setupStubs', [
userStubs.getUserSuccess({ userExternalId, gatewayAccountId }),
- gatewayAccountStubs.getGatewayAccountSuccess({ gatewayAccountId, type: 'test', paymentProvider: 'worldpay' }),
+ gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId, type: 'test', paymentProvider: 'worldpay' }),
productStubs.getProductsStub(products, gatewayAccountId)
])
}
@@ -55,12 +56,12 @@ describe('The manage payment links page', () => {
})
it('should state that there are no payment links', () => {
- cy.visit('/create-payment-link/manage')
+ cy.visit(`/account/${gatewayAccountExternalId}/create-payment-link/manage`)
cy.get('h1').should('contain', 'Manage payment links')
cy.get('.payment-links-list--header').should('contain',
'There are no payment links, you can create one now')
- cy.get('.payment-links-list--header > a').should('have.attr', 'href', '/create-payment-link')
+ cy.get('.payment-links-list--header > a').should('have.attr', 'href', `/account/${gatewayAccountExternalId}/create-payment-link`)
})
})
@@ -77,7 +78,7 @@ describe('The manage payment links page', () => {
})
it('should list English payment links and have no Welsh payment links section', () => {
- cy.visit('/create-payment-link/manage')
+ cy.visit(`/account/${gatewayAccountExternalId}/create-payment-link/manage`)
cy.get('h1').should('contain', 'Manage payment links')
cy.get('.payment-links-list--header').should('contain',
@@ -114,7 +115,7 @@ describe('The manage payment links page', () => {
})
it('should list English payment links and Welsh payment links separately', () => {
- cy.visit('/create-payment-link/manage')
+ cy.visit(`/account/${gatewayAccountExternalId}/create-payment-link/manage`)
cy.get('h1').should('contain', 'Manage payment links')
cy.get('.payment-links-list--header').should('contain',
@@ -159,7 +160,7 @@ describe('The manage payment links page', () => {
})
it('should list Welsh payment links', () => {
- cy.visit('/create-payment-link/manage')
+ cy.visit(`/account/${gatewayAccountExternalId}/create-payment-link/manage`)
cy.get('h1').should('contain', 'Manage payment links')
cy.get('.payment-links-list--header').should('contain',
@@ -186,13 +187,13 @@ describe('The manage payment links page', () => {
beforeEach(() => {
cy.task('setupStubs', [
userStubs.getUserSuccess({ userExternalId, gatewayAccountId }),
- gatewayAccountStubs.getGatewayAccountSuccess({ gatewayAccountId, type: 'test', paymentProvider: 'worldpay' }),
+ gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId, type: 'test', paymentProvider: 'worldpay' }),
productStubs.getProductsByGatewayAccountIdFailure()
])
})
it('should display an error', () => {
- cy.visit('/create-payment-link/manage', { failOnStatusCode: false })
+ cy.visit(`/account/${gatewayAccountExternalId}/create-payment-link/manage`, { failOnStatusCode: false })
cy.get('h1').should('contain', 'An error occurred:')
})
})
diff --git a/test/unit/controller/payment-links/get-amount.controller.ft.test.js b/test/unit/controller/payment-links/get-amount.controller.ft.test.js
deleted file mode 100644
index c0f1775539..0000000000
--- a/test/unit/controller/payment-links/get-amount.controller.ft.test.js
+++ /dev/null
@@ -1,189 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const cheerio = require('cheerio')
-const nock = require('nock')
-const lodash = require('lodash')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-const { CONNECTOR_URL } = process.env
-const GATEWAY_ACCOUNT_ID = '929'
-const { penceToPounds } = require('../../../../app/utils/currency-formatter')
-
-describe('Create payment link amount controller', () => {
- describe('if landing here for the first time', () => {
- let result, $, session
- before(done => {
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- session = getMockSession(user)
- lodash.set(session, 'pageData.createPaymentLink', {})
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.amount)
- .end((err, res) => {
- result = res
- $ = cheerio.load(res.text)
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should return a statusCode of 200', () => {
- expect(result.statusCode).to.equal(200)
- })
-
- it('should include a cancel link linking to the Create payment link index', () => {
- expect($('.cancel').attr('href')).to.equal(paths.paymentLinks.start)
- })
-
- it('should have itself as the form action', () => {
- expect($('form').attr('action')).to.equal(paths.paymentLinks.amount)
- })
-
- it('should have no checked radio buttons', () =>
- expect($('input[type="radio"]:checked').length).to.equal(0)
- )
-
- it('should have blank value in the amount input', () =>
- expect($('input[name="payment-amount"]').val()).to.equal('')
- )
- })
-
- describe('when returning to the page with validation errors', () => {
- const amountError = 'Something wrong with amount'
- const typeError = 'Something wrong with type'
- let $, session
- before(done => {
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- session = getMockSession(user)
- lodash.set(session, 'pageData.createPaymentLink.amountPageRecovered', {
- type: 'fixed',
- errors: {
- amount: amountError,
- type: typeError
- }
- })
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.amount)
- .end((err, res) => {
- $ = cheerio.load(res.text)
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should set the fixed amount radio to checked', () => {
- expect($('#amount-type-fixed:checked').length).to.equal(1)
- expect($('#amount-type-variable:checked').length).to.equal(0)
- })
-
- it('should have blank value in the amount input', () =>
- expect($('input[name="payment-amount"]').val()).to.equal('')
- )
-
- it('should show an error summary', () => {
- expect($('.govuk-error-summary__list li').length).to.equal(2)
- expect($('.govuk-error-summary__list li a[href$="#payment-amount"]').text()).to.equal(amountError)
- expect($('.govuk-error-summary__list li a[href$="#amount-type-fixed"]').text()).to.equal(typeError)
- })
-
- it('should show inline errors', () => {
- expect($('.govuk-error-message').length).to.equal(2)
- })
- })
-
- describe('if returning here to change fields', () => {
- describe('where an amount was set', () => {
- let $, session
- before(done => {
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- session = getMockSession(user)
- lodash.set(session, 'pageData.createPaymentLink', {
- paymentLinkTitle: 'Pay for an offline service',
- paymentLinkDescription: 'Hello world',
- paymentAmountType: 'fixed',
- paymentLinkAmount: '500'
- })
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.amount)
- .end((err, res) => {
- $ = cheerio.load(res.text)
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should set the fixed amount radio to checked', () =>
- expect($('#amount-type-fixed:checked').length).to.equal(1)
- )
-
- it('should set the value of the amount input to pre-existing data present in the session', () =>
- expect($('input[name="payment-amount"]').val()).to.equal(penceToPounds(session.pageData.createPaymentLink.paymentLinkAmount))
- )
- })
-
- describe('where an amount was not set', () => {
- let $, session
- before(done => {
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- session = getMockSession(user)
- lodash.set(session, 'pageData.createPaymentLink', {
- paymentLinkTitle: 'Pay for an offline service',
- paymentLinkDescription: 'Hello world',
- paymentAmountType: 'variable',
- paymentLinkAmount: ''
- })
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.amount)
- .end((err, res) => {
- $ = cheerio.load(res.text)
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should set the variable amount radio to checked', () => {
- expect($('#amount-type-variable:checked').length).to.equal(1)
- expect($('#amount-type-fixed:checked').length).to.equal(0)
- })
-
- it('should set the value of the amount input to pre-existing data present in the session', () =>
- expect($('input[name="payment-amount"]').val()).to.equal('')
- )
- })
- })
-})
diff --git a/test/unit/controller/payment-links/get-delete.controller.ft.test.js b/test/unit/controller/payment-links/get-delete.controller.ft.test.js
deleted file mode 100644
index 328facd8fe..0000000000
--- a/test/unit/controller/payment-links/get-delete.controller.ft.test.js
+++ /dev/null
@@ -1,200 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const nock = require('nock')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-const { randomUuid } = require('../../../../app/utils/random')
-const { validGatewayAccountResponse } = require('../../../fixtures/gateway-account.fixtures')
-
-const GATEWAY_ACCOUNT_ID = '929'
-const { PRODUCTS_URL, CONNECTOR_URL, PUBLIC_AUTH_URL } = process.env
-const PAYMENT = {
- external_id: 'product-external-id-1',
- gateway_account_id: 'product-gateway-account-id-1',
- description: 'product-description-1',
- name: 'payment-name-1',
- price: '150',
- pay_api_token: 'blatoken',
- type: 'ADHOC',
- return_url: 'http://return.url',
- _links: [{
- rel: 'pay',
- href: 'http://pay.url',
- method: 'GET'
- }]
-}
-
-describe('Manage payment links - delete controller', () => {
- describe('when the payment link and api token are successfully deleted', () => {
- let response, session
- before(done => {
- const productExternalId = randomUuid()
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, validGatewayAccountResponse({ gateway_account_id: GATEWAY_ACCOUNT_ID }))
- nock(PUBLIC_AUTH_URL).delete(`/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- revoked: '07/09/2018'
- })
- nock(PRODUCTS_URL).get(`/v1/api/gateway-account/${GATEWAY_ACCOUNT_ID}/products/${productExternalId}`).reply(200, PAYMENT)
- nock(PRODUCTS_URL).delete(`/v1/api/gateway-account/${GATEWAY_ACCOUNT_ID}/products/${productExternalId}`).reply(204)
- session = getMockSession(user)
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.manage.delete.replace(':productExternalId', productExternalId))
- .end((err, res) => {
- response = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with code 302', () => {
- expect(response.statusCode).to.equal(302)
- })
-
- it('should redirect to the manage page', () => {
- expect(response.header).to.have.property('location').to.equal(paths.paymentLinks.manage.index)
- })
-
- it('should add a relevant generic message to the session \'flash\'', () => {
- expect(session.flash).to.have.property('generic')
- expect(session.flash.generic.length).to.equal(1)
- expect(session.flash.generic[0]).to.equal('The payment link was successfully deleted')
- })
- })
-
- describe('when deleting the payment link fails but deleting token succeeds', () => {
- let response, session
- before(done => {
- const productExternalId = randomUuid()
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- nock(PUBLIC_AUTH_URL).delete(`/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- revoked: '07/09/2018'
- })
- nock(PRODUCTS_URL).get(`/v1/api/gateway-account/${GATEWAY_ACCOUNT_ID}/products/${productExternalId}`).reply(200, PAYMENT)
- nock(PRODUCTS_URL).delete(`/v1/api/gateway-account/${GATEWAY_ACCOUNT_ID}/products/${productExternalId}`)
- .replyWithError('Ruhroh! Something terrible has happened Shaggy!')
- session = getMockSession(user)
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.manage.delete.replace(':productExternalId', productExternalId))
- .end((err, res) => {
- response = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with code 302', () => {
- expect(response.statusCode).to.equal(302)
- })
-
- it('should redirect to the manage page', () => {
- expect(response.header).to.have.property('location').to.equal(paths.paymentLinks.manage.index)
- })
-
- it('should add a relevant error message to the session \'flash\'', () => {
- expect(session.flash).to.have.property('genericError')
- expect(session.flash.genericError.length).to.equal(1)
- expect(session.flash.genericError[0]).to.equal('Something went wrong when deleting the payment link. Please try again or contact support.')
- })
- })
-
- describe('when deleting the payment link succeeds but deleting token fails', () => {
- let response, session
- before(done => {
- const productExternalId = randomUuid()
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- nock(PRODUCTS_URL).get(`/v1/api/gateway-account/${GATEWAY_ACCOUNT_ID}/products/${productExternalId}`).reply(200, PAYMENT)
- nock(PUBLIC_AUTH_URL).delete(`/${GATEWAY_ACCOUNT_ID}`).replyWithError('Ruhroh! Something terrible has happened Shaggy!')
- nock(PRODUCTS_URL).delete(`/v1/api/gateway-account/${GATEWAY_ACCOUNT_ID}/products/${productExternalId}`).reply(204)
- session = getMockSession(user)
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.manage.delete.replace(':productExternalId', productExternalId))
- .end((err, res) => {
- response = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with code 302', () => {
- expect(response.statusCode).to.equal(302)
- })
-
- it('should redirect to the manage page', () => {
- expect(response.header).to.have.property('location').to.equal(paths.paymentLinks.manage.index)
- })
-
- it('should add a relevant error message to the session \'flash\'', () => {
- expect(session.flash).to.have.property('genericError')
- expect(session.flash.genericError.length).to.equal(1)
- expect(session.flash.genericError[0]).to.equal('Something went wrong when deleting the payment link. Please try again or contact support.')
- })
- })
-
- describe('when failing to fetch information about a product', () => {
- let response, session
- before(done => {
- const productExternalId = randomUuid()
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(PRODUCTS_URL).get(`/v1/api/gateway-account/${GATEWAY_ACCOUNT_ID}/products/${productExternalId}`).replyWithError('Ruhroh! Something terrible has happened Shaggy!')
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- nock(PUBLIC_AUTH_URL).delete(`/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- revoked: '07/09/2018'
- })
- nock(PRODUCTS_URL).delete(`/v1/api/gateway-account/${GATEWAY_ACCOUNT_ID}/products/${productExternalId}`).reply(204)
- session = getMockSession(user)
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.manage.delete.replace(':productExternalId', productExternalId))
- .end((err, res) => {
- response = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with code 302', () => {
- expect(response.statusCode).to.equal(302)
- })
-
- it('should redirect to the manage page', () => {
- expect(response.header).to.have.property('location').to.equal(paths.paymentLinks.manage.index)
- })
-
- it('should add a relevant error message to the session \'flash\'', () => {
- expect(session.flash).to.have.property('genericError')
- expect(session.flash.genericError.length).to.equal(1)
- expect(session.flash.genericError[0]).to.equal('Something went wrong when deleting the payment link. Please try again or contact support.')
- })
- })
-})
diff --git a/test/unit/controller/payment-links/get-disable.controller.ft.test.js b/test/unit/controller/payment-links/get-disable.controller.ft.test.js
deleted file mode 100644
index ed48137061..0000000000
--- a/test/unit/controller/payment-links/get-disable.controller.ft.test.js
+++ /dev/null
@@ -1,93 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const nock = require('nock')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-const { randomUuid } = require('../../../../app/utils/random')
-const { validGatewayAccountResponse } = require('../../../fixtures/gateway-account.fixtures')
-
-const GATEWAY_ACCOUNT_ID = '929'
-const { PRODUCTS_URL, CONNECTOR_URL } = process.env
-
-describe('Manage payment links - disable controller', () => {
- describe('when the payment link is successfully disabled', () => {
- let response, session
- before(done => {
- const productExternalId = randomUuid()
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, validGatewayAccountResponse({ gateway_account_id: GATEWAY_ACCOUNT_ID }))
- nock(PRODUCTS_URL).patch(`/v1/api/gateway-account/${GATEWAY_ACCOUNT_ID}/products/${productExternalId}/disable`).reply(200)
- session = getMockSession(user)
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.manage.disable.replace(':productExternalId', productExternalId))
- .end((err, res) => {
- response = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with code 302', () => {
- expect(response.statusCode).to.equal(302)
- })
-
- it('should redirect to the manage page', () => {
- expect(response.header).to.have.property('location').to.equal(paths.paymentLinks.manage.index)
- })
-
- it('should add a relevant generic message to the session \'flash\'', () => {
- expect(session.flash).to.have.property('generic')
- expect(session.flash.generic.length).to.equal(1)
- expect(session.flash.generic[0]).to.equal('The payment link was successfully deleted')
- })
- })
-
- describe('when disabling the payment link fails', () => {
- let response, session
- before(done => {
- const productExternalId = randomUuid()
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- nock(PRODUCTS_URL).patch(`/v1/api/gateway-account/${GATEWAY_ACCOUNT_ID}/products/${productExternalId}/disable`)
- .replyWithError('Ruhroh! Something terrible has happened Shaggy!')
- session = getMockSession(user)
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.manage.disable.replace(':productExternalId', productExternalId))
- .end((err, res) => {
- response = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with code 302', () => {
- expect(response.statusCode).to.equal(302)
- })
-
- it('should redirect to the manage page', () => {
- expect(response.header).to.have.property('location').to.equal(paths.paymentLinks.manage.index)
- })
-
- it('should add a relevant error message to the session \'flash\'', () => {
- expect(session.flash).to.have.property('genericError')
- expect(session.flash.genericError.length).to.equal(1)
- expect(session.flash.genericError[0]).to.equal('Something went wrong when deleting the payment link. Please try again or contact support.')
- })
- })
-})
diff --git a/test/unit/controller/payment-links/get-edit-amount.controller.test.js b/test/unit/controller/payment-links/get-edit-amount.controller.test.js
index fe216315b6..207f58545b 100644
--- a/test/unit/controller/payment-links/get-edit-amount.controller.test.js
+++ b/test/unit/controller/payment-links/get-edit-amount.controller.test.js
@@ -14,6 +14,9 @@ describe('GET edit amount controller', () => {
params: {
productExternalId
},
+ account: {
+ external_id: 'some-external-id'
+ },
flash: sinon.spy()
}
res = {
@@ -27,7 +30,7 @@ describe('GET edit amount controller', () => {
it('should return to "Manage payment links" with an error if session data not found', () => {
getEditAmountController(req, res, next)
- sinon.assert.calledWith(res.redirect, '/create-payment-link/manage')
+ sinon.assert.calledWith(res.redirect, '/account/some-external-id/create-payment-link/manage')
})
it('should return to "Manage payment links" with an error if ID in URL does not match ID in session', () => {
@@ -35,7 +38,7 @@ describe('GET edit amount controller', () => {
externalId: 'a-different-id'
})
getEditAmountController(req, res, next)
- sinon.assert.calledWith(res.redirect, '/create-payment-link/manage')
+ sinon.assert.calledWith(res.redirect, '/account/some-external-id/create-payment-link/manage')
})
it('should send field values from session when rendering page for fixed amount', () => {
diff --git a/test/unit/controller/payment-links/get-edit-information.controller.test.js b/test/unit/controller/payment-links/get-edit-information.controller.test.js
index 651e0767e8..78a2e9d231 100644
--- a/test/unit/controller/payment-links/get-edit-information.controller.test.js
+++ b/test/unit/controller/payment-links/get-edit-information.controller.test.js
@@ -14,6 +14,9 @@ describe('GET edit information controller', () => {
params: {
productExternalId
},
+ account: {
+ external_id: 'some-external-id'
+ },
flash: sinon.spy()
}
res = {
@@ -27,7 +30,7 @@ describe('GET edit information controller', () => {
it('should return to "Manage payment links" with an error if session data not found', () => {
getEditInformationController(req, res, next)
- sinon.assert.calledWith(res.redirect, '/create-payment-link/manage')
+ sinon.assert.calledWith(res.redirect, '/account/some-external-id/create-payment-link/manage')
})
it('should return to "Manage payment links" with an error if ID in URL does not match ID in session', () => {
@@ -35,7 +38,7 @@ describe('GET edit information controller', () => {
externalId: 'a-different-id'
})
getEditInformationController(req, res, next)
- sinon.assert.calledWith(res.redirect, '/create-payment-link/manage')
+ sinon.assert.calledWith(res.redirect, '/account/some-external-id/create-payment-link/manage')
})
it('should send field values from session when rendering page', () => {
diff --git a/test/unit/controller/payment-links/get-edit-reference.controller.test.js b/test/unit/controller/payment-links/get-edit-reference.controller.test.js
index 527fa87c33..f8f270760b 100644
--- a/test/unit/controller/payment-links/get-edit-reference.controller.test.js
+++ b/test/unit/controller/payment-links/get-edit-reference.controller.test.js
@@ -14,6 +14,9 @@ describe('GET edit reference controller', () => {
params: {
productExternalId
},
+ account: {
+ external_id: 'some-external-id'
+ },
flash: sinon.spy()
}
res = {
@@ -27,7 +30,7 @@ describe('GET edit reference controller', () => {
it('should return to "Manage payment links" with an error if session data not found', () => {
getEditReferenceController(req, res, next)
- sinon.assert.calledWith(res.redirect, '/create-payment-link/manage')
+ sinon.assert.calledWith(res.redirect, '/account/some-external-id/create-payment-link/manage')
})
it('should return to "Manage payment links" with an error if ID in URL does not match ID in session', () => {
@@ -35,7 +38,7 @@ describe('GET edit reference controller', () => {
externalId: 'a-different-id'
})
getEditReferenceController(req, res, next)
- sinon.assert.calledWith(res.redirect, '/create-payment-link/manage')
+ sinon.assert.calledWith(res.redirect, '/account/some-external-id/create-payment-link/manage')
})
it('should send field values from session when rendering page', () => {
diff --git a/test/unit/controller/payment-links/get-edit.controller.ft.test.js b/test/unit/controller/payment-links/get-edit.controller.ft.test.js
deleted file mode 100644
index 7627235d96..0000000000
--- a/test/unit/controller/payment-links/get-edit.controller.ft.test.js
+++ /dev/null
@@ -1,141 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const nock = require('nock')
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-const { expect } = require('chai')
-const formattedPathFor = require('../../../../app/utils/replace-params-in-path')
-const lodash = require('lodash')
-const { validGatewayAccountResponse } = require('../../../fixtures/gateway-account.fixtures')
-
-const { PRODUCTS_URL, CONNECTOR_URL } = process.env
-
-const GATEWAY_ACCOUNT_ID = '182364'
-const PRODUCT_EXTERNAL_ID = '2903e4yohi0we9yho2hio'
-const PAYMENT_1 = {
- external_id: 'product-external-id-1',
- gateway_account_id: 'product-gateway-account-id-1',
- description: 'product-description-1',
- name: 'payment-name-1',
- price: '150',
- type: 'ADHOC',
- return_url: 'http://return.url',
- _links: [{
- rel: 'pay',
- href: 'http://pay.url',
- method: 'GET'
- }]
-}
-
-const mockGetByProductExternalIdEndpoint = (gatewayAccountId, productExternalId) => {
- return nock(PRODUCTS_URL).get(`/v1/api/gateway-account/${gatewayAccountId}/products/${productExternalId}`)
-}
-
-describe('Edit a payment link', () => {
- let session
- before(() => {
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- session = getMockSession(user)
- })
-
- describe('when landing here for the first time', () => {
- let response
- before(done => {
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`)
- .reply(200, validGatewayAccountResponse({ gateway_account_id: GATEWAY_ACCOUNT_ID }))
- mockGetByProductExternalIdEndpoint(GATEWAY_ACCOUNT_ID, PRODUCT_EXTERNAL_ID).reply(200, PAYMENT_1)
-
- supertest(createAppWithSession(getApp(), session))
- .get(formattedPathFor(paths.paymentLinks.manage.edit, PRODUCT_EXTERNAL_ID))
- .set('Accept', 'application/json')
- .end((err, res) => {
- response = res
- done(err)
- })
- })
-
- after(() => {
- nock.cleanAll()
- })
-
- it('should display the correct page links', () => {
- expect(response.body).to.have.property('self', formattedPathFor(paths.paymentLinks.manage.edit, PRODUCT_EXTERNAL_ID))
- expect(response.body).to.have.property('editInformation', formattedPathFor(paths.paymentLinks.manage.editInformation, PRODUCT_EXTERNAL_ID))
- expect(response.body).to.have.property('editAmount', formattedPathFor(paths.paymentLinks.manage.editAmount, PRODUCT_EXTERNAL_ID))
- })
-
- it('should pass the product', () => {
- expect(response.body).to.have.deep.property('product', {
- description: 'product-description-1',
- externalId: 'product-external-id-1',
- gatewayAccountId: 'product-gateway-account-id-1',
- name: 'payment-name-1',
- price: '150',
- returnUrl: 'http://return.url',
- links: {
- pay: {
- href: 'http://pay.url',
- method: 'GET'
- }
- },
- type: 'ADHOC'
- })
- })
-
- it('should set changed to false', () => {
- expect(response.body).to.have.property('changed', false)
- })
- })
-
- describe('when landing here after editing the link', () => {
- let response
- before(done => {
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`)
- .reply(200, validGatewayAccountResponse({ gateway_account_id: GATEWAY_ACCOUNT_ID }))
- mockGetByProductExternalIdEndpoint(GATEWAY_ACCOUNT_ID, PRODUCT_EXTERNAL_ID).reply(200, PAYMENT_1)
-
- lodash.set(session, 'editPaymentLinkData', {
- name: 'Pay for an offline service'
- })
-
- supertest(createAppWithSession(getApp(), session))
- .get(formattedPathFor(paths.paymentLinks.manage.edit, PRODUCT_EXTERNAL_ID))
- .set('Accept', 'application/json')
- .end((err, res) => {
- response = res
- done(err)
- })
- })
-
- after(() => {
- nock.cleanAll()
- })
-
- it('should pass the updated product', () => {
- expect(response.body).to.have.deep.property('product', {
- description: 'product-description-1',
- externalId: 'product-external-id-1',
- gatewayAccountId: 'product-gateway-account-id-1',
- name: 'Pay for an offline service',
- price: '150',
- returnUrl: 'http://return.url',
- links: {
- pay: {
- href: 'http://pay.url',
- method: 'GET'
- }
- },
- type: 'ADHOC'
- })
- })
-
- it('should set changed to true', () => {
- expect(response.body).to.have.property('changed', true)
- })
- })
-})
diff --git a/test/unit/controller/payment-links/get-information.controller.ft.test.js b/test/unit/controller/payment-links/get-information.controller.ft.test.js
deleted file mode 100644
index 33147597a5..0000000000
--- a/test/unit/controller/payment-links/get-information.controller.ft.test.js
+++ /dev/null
@@ -1,209 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const cheerio = require('cheerio')
-const nock = require('nock')
-const lodash = require('lodash')
-const sinon = require('sinon')
-const proxyquire = require('proxyquire')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-
-const { CONNECTOR_URL } = process.env
-const GATEWAY_ACCOUNT_ID = '929'
-
-const getController = (mockResponse) => {
- return proxyquire('../../../../app/controllers/payment-links/get-information.controller', {
- '../../utils/response': { response: mockResponse }
- })
-}
-
-describe('Create payment link information controller', () => {
- describe('if landing here for the first time', () => {
- let result, $, session
- before(done => {
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- session = getMockSession(user)
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.information)
- .end((err, res) => {
- result = res
- $ = cheerio.load(res.text)
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should return a statusCode of 200', () => {
- expect(result.statusCode).to.equal(200)
- })
-
- it('should include a cancel link linking to the Create payment link index', () => {
- expect($('.cancel').attr('href')).to.equal(paths.paymentLinks.start)
- })
-
- it('should have itself as the form action', () => {
- expect($('form').attr('action')).to.equal(paths.paymentLinks.information)
- })
-
- it('should have blank value in the Title input', () =>
- expect($('input[name="payment-link-title"]').val()).to.be.undefined
- )
-
- it('should have blank value in the Details textarea', () =>
- expect($('textarea[name="payment-link-description"]').val()).to.equal('')
- )
- })
-
- describe('when returning to the page with validation errors', () => {
- const titleError = 'Something wrong with the title'
- let $, session
- before(done => {
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- session = getMockSession(user)
- lodash.set(session, 'pageData.createPaymentLink.informationPageRecovered', {
- title: 'Title',
- description: 'Hello world',
- errors: {
- title: titleError
- }
- })
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.information)
- .end((err, res) => {
- $ = cheerio.load(res.text)
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should set the value of the Title input to recovered value', () =>
- expect($('input[name="payment-link-title"]').val()).to.equal('Title')
- )
-
- it('should set the value of the Details textarea to recovered value', () =>
- expect($('textarea[name="payment-link-description"]').val()).to.equal('Hello world')
- )
-
- it('should show an error summary', () => {
- expect($('.govuk-error-summary__list li').length).to.equal(1)
- expect($('.govuk-error-summary__list li a[href$="#payment-link-title"]').text()).to.equal(titleError)
- })
-
- it('should show inline errors', () => {
- expect($('.govuk-error-message').length).to.equal(1)
- })
- })
-
- describe('if returning here to change fields', () => {
- let $, session
- before(done => {
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- session = getMockSession(user)
- lodash.set(session, 'pageData.createPaymentLink', {
- paymentLinkTitle: 'Pay for an offline service',
- paymentLinkDescription: 'Hello world'
- })
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.information)
- .end((err, res) => {
- $ = cheerio.load(res.text)
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should pre-set the value of the Title input to pre-existing data if present in the session', () =>
- expect($('input[name="payment-link-title"]').val()).to.equal(session.pageData.createPaymentLink.paymentLinkTitle)
- )
-
- it('should pre-set the value of the Details textarea to pre-existing data if present in the session', () =>
- expect($('textarea[name="payment-link-description"]').val()).to.equal(session.pageData.createPaymentLink.paymentLinkDescription)
- )
- })
-
- describe('service name resolution', () => {
- it('should resolve the English service name when creating an English payment link', () => {
- const req = {
- service: {
- serviceName: {
- en: 'English name',
- cy: 'Welsh name'
- }
- },
- body: {}
- }
-
- const mockResponse = sinon.stub()
- const controller = getController(mockResponse)
- controller(req, {})
- expect(mockResponse.getCall(0).args[3].serviceName).to.equal(req.service.serviceName.en)
- })
-
- it('should resolve the Welsh service name when creating a Welsh payment link and there is a Welsh service name', () => {
- const req = {
- service: {
- serviceName: {
- en: 'English name',
- cy: 'Welsh name'
- }
- },
- query: {
- language: 'cy'
- },
- body: {}
- }
-
- const mockResponse = sinon.stub()
- const controller = getController(mockResponse)
- controller(req, {})
- expect(mockResponse.getCall(0).args[3].serviceName).to.equal(req.service.serviceName.cy)
- })
-
- it('should resolve the English service name when creating a Welsh payment link and there is NOT a Welsh service name', () => {
- const req = {
- service: {
- serviceName: {
- en: 'English name'
- }
- },
- query: {
- language: 'cy'
- },
- body: {}
- }
-
- const mockResponse = sinon.stub()
- const controller = getController(mockResponse)
- controller(req, {})
- expect(mockResponse.getCall(0).args[3].serviceName).to.equal(req.service.serviceName.en)
- })
- })
-})
diff --git a/test/unit/controller/payment-links/get-reference.controller.ft.test.js b/test/unit/controller/payment-links/get-reference.controller.ft.test.js
deleted file mode 100644
index 8acfd8c2c9..0000000000
--- a/test/unit/controller/payment-links/get-reference.controller.ft.test.js
+++ /dev/null
@@ -1,208 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const cheerio = require('cheerio')
-const nock = require('nock')
-const lodash = require('lodash')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-const { CONNECTOR_URL } = process.env
-const GATEWAY_ACCOUNT_ID = '929'
-
-describe('Create payment link reference controller', () => {
- describe('if landing here for the first time', () => {
- let result, $, session
- before(done => {
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- session = getMockSession(user)
- lodash.set(session, 'pageData.createPaymentLink', {
- isWelsh: false
- })
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.reference)
- .end((err, res) => {
- result = res
- $ = cheerio.load(res.text)
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should return a statusCode of 200', () => {
- expect(result.statusCode).to.equal(200)
- })
-
- it('should include a cancel link linking to the Create payment link index', () => {
- expect($('.cancel').attr('href')).to.equal(paths.paymentLinks.start)
- })
-
- it('should have itself as the form action', () => {
- expect($('form').attr('action')).to.equal(paths.paymentLinks.reference)
- })
-
- it('should have no checked radio buttons', () =>
- expect($('input[type="radio"]:checked').length).to.equal(0)
- )
-
- it('should have blank value in the reference input', () =>
- expect($('input[name="reference-label"]').val()).to.be.undefined
- )
-
- it('should have blank value in the reference hint text input', () =>
- expect($('input[name="reference-hint-text"]').val()).to.be.undefined
- )
- })
-
- describe('when returning to the page with validation errors', () => {
- const label = 'Hello world'
- const hint = 'Some words'
- const typeError = 'Something wrong with the type'
- const labelError = 'Something wrong with the label'
- let $, session
- before(done => {
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- session = getMockSession(user)
- lodash.set(session, 'pageData.createPaymentLink.referencePageRecovered', {
- type: 'custom',
- label,
- hint,
- errors: {
- type: typeError,
- label: labelError
- }
- })
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.reference)
- .end((err, res) => {
- $ = cheerio.load(res.text)
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should set the custom reference radio to checked', () =>
- expect($('#reference-type-custom:checked').length).to.equal(1)
- )
-
- it('should set the value of the reference to pre-existing data present in the session', () =>
- expect($('input[name="reference-label"]').val()).to.equal(label)
- )
-
- it('should set the value of the reference hint to pre-existing data present in the session', () =>
- expect($('textarea[name="reference-hint-text"]').val()).to.equal(hint)
- )
-
- it('should show an error summary', () => {
- expect($('.govuk-error-summary__list li').length).to.equal(2)
- expect($('.govuk-error-summary__list li a[href$="#reference-type-custom"]').text()).to.equal(typeError)
- expect($('.govuk-error-summary__list li a[href$="#reference-label"]').text()).to.equal(labelError)
- })
-
- it('should show inline errors', () => {
- expect($('.govuk-error-message').length).to.equal(2)
- })
- })
-
- describe('if returning here to change fields', () => {
- describe('where a custom reference was set', () => {
- let $, session
- before(done => {
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- session = getMockSession(user)
- lodash.set(session, 'pageData.createPaymentLink', {
- paymentReferenceType: 'custom',
- paymentReferenceLabel: 'Hello world',
- paymentReferenceHint: 'Some words',
- isWelsh: false
- })
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.reference)
- .end((err, res) => {
- $ = cheerio.load(res.text)
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should set the custom reference radio to checked', () =>
- expect($('#reference-type-custom:checked').length).to.equal(1)
- )
-
- it('should set the value of the reference to recovered value', () =>
- expect($('input[name="reference-label"]').val()).to.equal(session.pageData.createPaymentLink.paymentReferenceLabel)
- )
-
- it('should set the value of the reference hint to recovered value', () =>
- expect($('textarea[name="reference-hint-text"]').val()).to.equal(session.pageData.createPaymentLink.paymentReferenceHint)
- )
- })
-
- describe('where the standard reference is used', () => {
- let $, session
- before(done => {
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- session = getMockSession(user)
- lodash.set(session, 'pageData.createPaymentLink', {
- paymentReferenceType: 'standard',
- paymentReferenceLabel: '',
- paymentReferenceHint: '',
- isWelsh: false
- })
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.reference)
- .end((err, res) => {
- $ = cheerio.load(res.text)
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should set the standard reference radio to checked', () =>
- expect($('#reference-type-standard:checked').length).to.equal(1)
- )
-
- it('should set the value of the reference to blank', () =>
- expect($('input[name="reference-label"]').val()).to.be.undefined
- )
-
- it('should set the value of the reference hint to blank', () =>
- expect($('input[name="reference-hint-text"]').val()).to.be.undefined
- )
- })
- })
-})
diff --git a/test/unit/controller/payment-links/get-review.controller.ft.test.js b/test/unit/controller/payment-links/get-review.controller.ft.test.js
deleted file mode 100644
index a9ab13d22b..0000000000
--- a/test/unit/controller/payment-links/get-review.controller.ft.test.js
+++ /dev/null
@@ -1,75 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const cheerio = require('cheerio')
-const nock = require('nock')
-const lodash = require('lodash')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-const { CONNECTOR_URL } = process.env
-const GATEWAY_ACCOUNT_ID = '929'
-
-describe('Create payment link review controller', () => {
- describe('when landing here after completing journey', () => {
- let result, $, session
- before(done => {
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{
- name: 'tokens:create'
- }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- session = getMockSession(user)
- lodash.set(session, 'pageData.createPaymentLink', {
- paymentLinkTitle: 'Pay for an offline service',
- paymentLinkDescription: 'Hello world',
- paymentReferenceType: 'custom',
- paymentReferenceLabel: 'A reference'
- })
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.review)
- .end((err, res) => {
- result = res
- $ = cheerio.load(res.text)
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should return a statusCode of 200', () => {
- expect(result.statusCode).to.equal(200)
- })
-
- it(`should include a cancel link linking to the Create payment link index`, () => {
- expect($('.cancel').attr('href')).to.equal(paths.paymentLinks.start)
- })
-
- it(`should include link to change title`, () => {
- expect($('.govuk-summary-list__row:nth-child(1) a').attr('href')).to.equal(`${paths.paymentLinks.information}?field=payment-link-title`)
- })
-
- it(`should include link to change description`, () => {
- expect($('.govuk-summary-list__row:nth-child(2) a').attr('href')).to.equal(`${paths.paymentLinks.information}?field=payment-link-description`)
- })
-
- it(`should display the Title in the definition list`, () =>
- expect($(`.govuk-summary-list__row:nth-child(1) .govuk-summary-list__value`).text()).to.contain(session.pageData.createPaymentLink.paymentLinkTitle)
- )
-
- it(`should display some details in the definition list`, () =>
- expect($(`.govuk-summary-list__row:nth-child(2) .govuk-summary-list__value`).text()).to.contain(session.pageData.createPaymentLink.paymentLinkDescription)
- )
-
- it(`should display the reference in the definition list`, () =>
- expect($(`.govuk-summary-list__row:nth-child(3) .govuk-summary-list__value`).text()).to.contain(session.pageData.createPaymentLink.paymentReferenceLabel)
- )
- })
-})
diff --git a/test/unit/controller/payment-links/get-web-address.controller.ft.test.js b/test/unit/controller/payment-links/get-web-address.controller.ft.test.js
deleted file mode 100644
index 34745e00cc..0000000000
--- a/test/unit/controller/payment-links/get-web-address.controller.ft.test.js
+++ /dev/null
@@ -1,60 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const cheerio = require('cheerio')
-const nock = require('nock')
-const lodash = require('lodash')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-const { CONNECTOR_URL } = process.env
-const GATEWAY_ACCOUNT_ID = '929'
-
-describe('Create payment link web address controller', () => {
- describe('if landing here for the first time', () => {
- let result, $, session
- before(done => {
- const user = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
- })
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, {
- payment_provider: 'sandbox'
- })
- session = getMockSession(user)
- lodash.set(session, 'pageData.createPaymentLink', {
- paymentLinkTitle: 'Pay for an offline service',
- paymentLinkDescription: 'Hello world',
- productNamePath: 'pay-for-offline-service'
- })
- supertest(createAppWithSession(getApp(), session))
- .get(paths.paymentLinks.webAddress)
- .end((err, res) => {
- result = res
- $ = cheerio.load(res.text)
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should return a statusCode of 200', () => {
- expect(result.statusCode).to.equal(200)
- })
-
- it(`should include a cancel link linking to the Create payment link index`, () => {
- expect($('.cancel').attr('href')).to.equal(paths.paymentLinks.start)
- })
-
- it(`should have itself as the form action`, () => {
- expect($('form').attr('action')).to.equal(paths.paymentLinks.webAddress)
- })
-
- it(`should an input containing the product path`, () =>
- expect($(`input[type="text"]`).val()).to.equal(session.pageData.createPaymentLink.productNamePath)
- )
- })
-})
diff --git a/test/unit/controller/payment-links/post-amount.controller.ft.test.js b/test/unit/controller/payment-links/post-amount.controller.ft.test.js
deleted file mode 100644
index 4bd7933071..0000000000
--- a/test/unit/controller/payment-links/post-amount.controller.ft.test.js
+++ /dev/null
@@ -1,191 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const lodash = require('lodash')
-const csrf = require('csrf')
-const nock = require('nock')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-const { safeConvertPoundsStringToPence } = require('../../../../app/utils/currency-formatter')
-const { validGatewayAccountResponse } = require('../../../fixtures/gateway-account.fixtures')
-
-const { CONNECTOR_URL } = process.env
-const GATEWAY_ACCOUNT_ID = '929'
-const VALID_USER = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
-})
-
-function mockConnectorGetAccount () {
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`)
- .reply(200, validGatewayAccountResponse({
- gateway_account_id: GATEWAY_ACCOUNT_ID
- }))
-}
-
-describe('Create payment link amount post controller', () => {
- describe(`when a fixed amount is submitted`, () => {
- let result, session, app
- const VALID_PAYLOAD = {
- 'csrfToken': csrf().create('123'),
- 'amount-type-group': 'fixed',
- 'payment-amount': '5.00'
- }
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {})
- app = createAppWithSession(getApp(), session)
- mockConnectorGetAccount()
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.amount)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- it('should have paymentLinkAmount stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentLinkAmount').to.equal(safeConvertPoundsStringToPence(VALID_PAYLOAD['payment-amount']))
- })
-
- it('should have paymentAmountType stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentAmountType').to.equal(VALID_PAYLOAD['amount-type-group'])
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the review page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.review)
- })
- })
-
- describe(`when no payment amount is entered and variable amount is selected`, () => {
- let result, session, app
- const VALID_PAYLOAD = {
- 'csrfToken': csrf().create('123'),
- 'payment-amount': '',
- 'amount-type-group': 'variable'
- }
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {})
- app = createAppWithSession(getApp(), session)
- mockConnectorGetAccount()
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.amount)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- it('should have no paymentLinkAmount stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentLinkAmount').to.equal('')
- })
-
- it('should have paymentAmountType stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentAmountType').to.equal(VALID_PAYLOAD['amount-type-group'])
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the review page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.review)
- })
- })
-
- describe(`when a payment amount is submitted but variable is selected`, () => {
- let result, session, app
- const VALID_PAYLOAD = {
- 'csrfToken': csrf().create('123'),
- 'payment-amount': '5.00',
- 'amount-type-group': 'variable'
- }
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {})
- app = createAppWithSession(getApp(), session)
- mockConnectorGetAccount()
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.amount)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- it('should have no paymentLinkAmount stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentLinkAmount').to.equal('')
- })
-
- it('should have paymentAmountType stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentAmountType').to.equal(VALID_PAYLOAD['amount-type-group'])
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the review page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.review)
- })
- })
-
- describe(`when neither radio button is chosen`, () => {
- let result, session, app
- const VALID_PAYLOAD = {
- 'csrfToken': csrf().create('123'),
- 'payment-amount': ''
- }
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {})
- app = createAppWithSession(getApp(), session)
- mockConnectorGetAccount()
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.amount)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- it('should have a recovered object stored on the session containing error', () => {
- const recovered = lodash.get(session, 'pageData.createPaymentLink.amountPageRecovered', {})
- expect(recovered.errors).to.have.property('type')
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect back to itself', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.amount)
- })
- })
-})
diff --git a/test/unit/controller/payment-links/post-edit-amount.controller.ft.test.js b/test/unit/controller/payment-links/post-edit-amount.controller.ft.test.js
deleted file mode 100644
index f8d5c559f5..0000000000
--- a/test/unit/controller/payment-links/post-edit-amount.controller.ft.test.js
+++ /dev/null
@@ -1,184 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const nock = require('nock')
-const csrf = require('csrf')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-const formattedPathFor = require('../../../../app/utils/replace-params-in-path')
-
-const GATEWAY_ACCOUNT_ID = '929'
-const PRODUCT_EXTERNAL_ID = '2903e4yohi0we9yho2hio'
-
-const VALID_USER = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
-})
-
-describe('POST payment link edit amount controller', () => {
- describe('if fixed price is set', () => {
- let result, session, app
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- session.editPaymentLinkData = { externalId: PRODUCT_EXTERNAL_ID }
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(formattedPathFor(paths.paymentLinks.manage.editAmount, PRODUCT_EXTERNAL_ID))
- .send({
- csrfToken: csrf().create('123'),
- 'amount-type-group': 'fixed',
- 'payment-amount': '5.00'
- })
- .end((err, res) => {
- result = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to edit page', () => {
- expect(result.headers).to.have.property('location').to.equal(formattedPathFor(paths.paymentLinks.manage.edit, PRODUCT_EXTERNAL_ID))
- })
-
- it('should set price in session', () => {
- expect(session.editPaymentLinkData.price).to.equal(500)
- })
-
- it('should redirect to the edit page', () => {
- expect(result.headers).to.have.property('location').to.equal(formattedPathFor(paths.paymentLinks.manage.edit, PRODUCT_EXTERNAL_ID))
- })
- })
-
- describe('if variable price is set', () => {
- let result, session, app
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- session.editPaymentLinkData = { externalId: PRODUCT_EXTERNAL_ID }
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(formattedPathFor(paths.paymentLinks.manage.editAmount, PRODUCT_EXTERNAL_ID))
- .send({
- csrfToken: csrf().create('123'),
- 'amount-type-group': 'variable',
- 'payment-amount': '5.00'
- })
- .end((err, res) => {
- result = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to edit page', () => {
- expect(result.headers).to.have.property('location').to.equal(formattedPathFor(paths.paymentLinks.manage.edit, PRODUCT_EXTERNAL_ID))
- })
-
- it('should set price in session', () => {
- expect(session.editPaymentLinkData.price).to.equal('')
- })
-
- it('should redirect to the edit page', () => {
- expect(result.headers).to.have.property('location').to.equal(formattedPathFor(paths.paymentLinks.manage.edit, PRODUCT_EXTERNAL_ID))
- })
- })
-
- describe('if no radio is selected', () => {
- let result, session, app
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- session.editPaymentLinkData = { externalId: PRODUCT_EXTERNAL_ID }
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(formattedPathFor(paths.paymentLinks.manage.editAmount, PRODUCT_EXTERNAL_ID))
- .send({
- csrfToken: csrf().create('123'),
- 'amount-type-group': ''
- })
- .end((err, res) => {
- result = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to same page', () => {
- expect(result.headers).to.have.property('location').to.equal(formattedPathFor(paths.paymentLinks.manage.editAmount, PRODUCT_EXTERNAL_ID))
- })
-
- it('should have a recovered object stored on the session containing errors and submitted data', () => {
- const recovered = session.editPaymentLinkData.amountPageRecovered
- expect(recovered).to.have.property('type').to.equal('')
- expect(recovered).to.have.property('amount').to.equal('')
- expect(recovered).to.have.property('errors')
- expect(recovered.errors).to.have.property('type')
- })
- })
-
- describe('if no price set', () => {
- let result, session, app
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- session.editPaymentLinkData = { externalId: PRODUCT_EXTERNAL_ID }
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(formattedPathFor(paths.paymentLinks.manage.editAmount, PRODUCT_EXTERNAL_ID))
- .send({
- csrfToken: csrf().create('123'),
- 'amount-type-group': 'fixed',
- 'payment-amount': 'djhd'
- })
- .end((err, res) => {
- result = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to same page', () => {
- expect(result.headers).to.have.property('location').to.equal(formattedPathFor(paths.paymentLinks.manage.editAmount, PRODUCT_EXTERNAL_ID))
- })
-
- it('should have a recovered object stored on the session containing errors and submitted data', () => {
- const recovered = session.editPaymentLinkData.amountPageRecovered
- expect(recovered).to.have.property('type').to.equal('fixed')
- expect(recovered).to.have.property('amount').to.equal('')
- expect(recovered).to.have.property('errors')
- expect(recovered.errors).to.have.property('amount')
- })
- })
-})
diff --git a/test/unit/controller/payment-links/post-edit-information.controller.ft.test.js b/test/unit/controller/payment-links/post-edit-information.controller.ft.test.js
deleted file mode 100644
index c202c32b35..0000000000
--- a/test/unit/controller/payment-links/post-edit-information.controller.ft.test.js
+++ /dev/null
@@ -1,106 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const nock = require('nock')
-const csrf = require('csrf')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-const formattedPathFor = require('../../../../app/utils/replace-params-in-path')
-
-const GATEWAY_ACCOUNT_ID = '929'
-const PRODUCT_EXTERNAL_ID = '2903e4yohi0we9yho2hio'
-
-const VALID_USER = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
-})
-
-describe('POST payment link edit information controller', () => {
- describe('if values are present', () => {
- let result, session, app
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- session.editPaymentLinkData = { externalId: PRODUCT_EXTERNAL_ID }
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(formattedPathFor(paths.paymentLinks.manage.editInformation, PRODUCT_EXTERNAL_ID))
- .send({
- csrfToken: csrf().create('123'),
- 'payment-link-title': 'hello world',
- 'payment-link-description': 'some words'
- })
- .end((err, res) => {
- result = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to edit page', () => {
- expect(result.headers).to.have.property('location').to.equal(formattedPathFor(paths.paymentLinks.manage.edit, PRODUCT_EXTERNAL_ID))
- })
-
- it('should set title in session', () => {
- expect(session.editPaymentLinkData.name).to.equal('hello world')
- })
-
- it('should set details in session', () => {
- expect(session.editPaymentLinkData.description).to.equal('some words')
- })
-
- it('should redirect to the edit page', () => {
- expect(result.headers).to.have.property('location').to.equal(formattedPathFor(paths.paymentLinks.manage.edit, PRODUCT_EXTERNAL_ID))
- })
- })
- describe('if title is blank', () => {
- let result, session, app
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- session.editPaymentLinkData = { externalId: PRODUCT_EXTERNAL_ID }
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(formattedPathFor(paths.paymentLinks.manage.editInformation, PRODUCT_EXTERNAL_ID))
- .send({
- csrfToken: csrf().create('123'),
- 'payment-link-title': '',
- 'payment-link-description': 'some words'
- })
- .end((err, res) => {
- result = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to same page', () => {
- expect(result.headers).to.have.property('location').to.equal(formattedPathFor(paths.paymentLinks.manage.editInformation, PRODUCT_EXTERNAL_ID))
- })
-
- it('should have a recovered object stored on the session containing errors and submitted data', () => {
- const recovered = session.editPaymentLinkData.informationPageRecovered
- expect(recovered).to.have.property('name').to.equal('')
- expect(recovered).to.have.property('description').to.equal('some words')
- expect(recovered).to.have.property('errors')
- expect(recovered.errors).to.have.property('title')
- })
- })
-})
diff --git a/test/unit/controller/payment-links/post-edit.controller.ft.test.js b/test/unit/controller/payment-links/post-edit.controller.ft.test.js
deleted file mode 100644
index 07cd42433d..0000000000
--- a/test/unit/controller/payment-links/post-edit.controller.ft.test.js
+++ /dev/null
@@ -1,79 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const nock = require('nock')
-const csrf = require('csrf')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-const formattedPathFor = require('../../../../app/utils/replace-params-in-path')
-const { validGatewayAccountResponse } = require('../../../fixtures/gateway-account.fixtures')
-
-const GATEWAY_ACCOUNT_ID = '929'
-const PRODUCT_EXTERNAL_ID = '2903e4yohi0we9yho2hio'
-const PAYMENT_1 = {
- external_id: 'product-external-id-1',
- gateway_account_id: 'product-gateway-account-id-1',
- description: 'product-description-1',
- name: 'payment-name-1',
- price: '150',
- type: 'ADHOC',
- return_url: 'http://return.url',
- _links: [{
- rel: 'pay',
- href: 'http://pay.url',
- method: 'GET'
- }]
-}
-
-const VALID_USER = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
-})
-const VALID_PAYLOAD = {
- csrfToken: csrf().create('123')
-}
-
-const productsMock = nock(process.env.PRODUCTS_URL)
-const connectorMock = nock(process.env.CONNECTOR_URL)
-
-describe('POST edit payment link controller', () => {
- let result, session, app
- before('Arrange', () => {
- connectorMock.get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`)
- .reply(200, validGatewayAccountResponse({ gateway_account_id: GATEWAY_ACCOUNT_ID }))
- productsMock.patch(`/v1/api/gateway-account/${GATEWAY_ACCOUNT_ID}/products/${PRODUCT_EXTERNAL_ID}`).reply(200, PAYMENT_1)
- session = getMockSession(VALID_USER)
- session.editPaymentLinkData = {
- externalId: PRODUCT_EXTERNAL_ID,
- name: 'Pay for an offline service'
- }
-
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(formattedPathFor(paths.paymentLinks.manage.edit, PRODUCT_EXTERNAL_ID))
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the manage page with a success message', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.manage.index)
- expect(session.flash).to.have.property('generic')
- expect(session.flash.generic.length).to.equal(1)
- expect(session.flash.generic[0]).to.equal('Your payment link has been updated')
- })
-})
diff --git a/test/unit/controller/payment-links/post-information.controller.ft.test.js b/test/unit/controller/payment-links/post-information.controller.ft.test.js
deleted file mode 100644
index e18fd1b5a9..0000000000
--- a/test/unit/controller/payment-links/post-information.controller.ft.test.js
+++ /dev/null
@@ -1,207 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const lodash = require('lodash')
-const nock = require('nock')
-const csrf = require('csrf')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-const { validProductResponse } = require('../../../fixtures/product.fixtures')
-
-const { PRODUCTS_URL } = process.env
-let product
-const GATEWAY_ACCOUNT_ID = '929'
-const SERVICE_NAME = 'Pay for an offline service'
-const SERVICE_NAME_SLUGIFIED = 'pay-for-offline-service'
-const PAYMENT_TITLE = 'Payment title'
-const PAYMENT_TITLE_SLUGIFIED = 'payment-title'
-const PAYMENT_DESCRIPTION = 'Payment description'
-const VALID_PAYLOAD = {
- 'csrfToken': csrf().create('123'),
- 'payment-link-title': PAYMENT_TITLE,
- 'service-name-path': SERVICE_NAME,
- 'payment-link-description': PAYMENT_DESCRIPTION
-}
-const VALID_USER = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
-})
-
-describe('Create payment link information controller', () => {
- describe(`when both paymentLinkTitle and paymentLinkDescription are submitted`, () => {
- let result, session, app
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {})
- app = createAppWithSession(getApp(), session)
- product = validProductResponse({
- type: 'ADHOC',
- service_name_path: SERVICE_NAME_SLUGIFIED,
- product_name_path: PAYMENT_TITLE_SLUGIFIED
- })
- })
-
- describe(`and URL isnt taken already`, () => {
- before('Arrange', () => {
- nock(PRODUCTS_URL)
- .get(`/v1/api/products`)
- .query({ 'serviceNamePath': product.service_name_path, 'productNamePath': product.product_name_path })
- .reply(404, product)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.information)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- it('should have paymentLinkTitle and paymentLinkDescription stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentLinkTitle').to.equal(PAYMENT_TITLE)
- expect(sessionPageData).to.have.property('paymentLinkDescription').to.equal(PAYMENT_DESCRIPTION)
- })
-
- it('should have serviceNamePath and productNamePath stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('serviceNamePath').to.equal(SERVICE_NAME_SLUGIFIED)
- expect(sessionPageData).to.have.property('productNamePath').to.equal(PAYMENT_TITLE_SLUGIFIED)
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the amount page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.reference)
- })
- })
-
- describe(`and URL is taken already`, () => {
- before('Arrange', () => {
- nock(PRODUCTS_URL)
- .get(`/v1/api/products`)
- .query({ 'serviceNamePath': product.service_name_path, 'productNamePath': product.product_name_path })
- .reply(200, product)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.information)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- it('should have paymentLinkTitle and paymentLinkDescription stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentLinkTitle').to.equal(PAYMENT_TITLE)
- expect(sessionPageData).to.have.property('paymentLinkDescription').to.equal(PAYMENT_DESCRIPTION)
- })
-
- it('should have serviceNamePath and productNamePath stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('serviceNamePath').to.equal(SERVICE_NAME_SLUGIFIED)
- expect(sessionPageData).to.have.property('productNamePath').to.equal(PAYMENT_TITLE_SLUGIFIED)
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the web address page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.webAddress)
- })
- })
- })
-
- describe(`when no paymentLinkDescription is submitted`, () => {
- let result, session, app
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {})
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.information)
- .send(Object.assign({}, VALID_PAYLOAD, { 'payment-link-description': '' }))
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- it('should have paymentLinkTitle stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentLinkTitle').to.equal(PAYMENT_TITLE)
- })
-
- it('should have no paymentLinkDescription stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentLinkDescription').to.equal('')
- })
-
- it('should have serviceNamePath and productNamePath stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('serviceNamePath').to.equal(SERVICE_NAME_SLUGIFIED)
- expect(sessionPageData).to.have.property('productNamePath').to.equal(PAYMENT_TITLE_SLUGIFIED)
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the amount page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.reference)
- })
- })
- describe(`when no paymentLinkTitle is submitted`, () => {
- let result, session, app
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {})
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.information)
- .send(Object.assign({}, VALID_PAYLOAD, {
- 'payment-link-title': '',
- 'payment-link-description': 'something'
- }))
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- it('should not have title and description stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.not.have.property('paymentLinkTitle')
- expect(sessionPageData).to.not.have.property('paymentLinkDescription')
- })
-
- it('should have a recovered object stored on the session containing errors and submitted data', () => {
- const recovered = lodash.get(session, 'pageData.createPaymentLink.informationPageRecovered', {})
- expect(recovered).to.have.property('title').to.equal('')
- expect(recovered).to.have.property('description').to.equal('something')
- expect(recovered).to.have.property('errors')
- expect(recovered.errors).to.have.property('title')
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the information page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.information)
- })
- })
-})
diff --git a/test/unit/controller/payment-links/post-reference.controller.ft.test.js b/test/unit/controller/payment-links/post-reference.controller.ft.test.js
deleted file mode 100644
index 575bdbf8b8..0000000000
--- a/test/unit/controller/payment-links/post-reference.controller.ft.test.js
+++ /dev/null
@@ -1,189 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const lodash = require('lodash')
-const csrf = require('csrf')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-
-const GATEWAY_ACCOUNT_ID = '929'
-const VALID_USER = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
-})
-
-describe('Create payment link reference post controller', () => {
- describe(`when a custom reference is submitted`, () => {
- let result, session, app
- const VALID_PAYLOAD = {
- 'csrfToken': csrf().create('123'),
- 'reference-type-group': 'custom',
- 'reference-label': 'Some words',
- 'reference-hint-text': 'Some more words'
- }
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {})
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.reference)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- it('should have paymentReferenceType stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentReferenceType').to.equal(VALID_PAYLOAD['reference-type-group'])
- })
-
- it('should have paymentReferenceLabel stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentReferenceLabel').to.equal(VALID_PAYLOAD['reference-label'])
- })
-
- it('should have paymentReferenceHint stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentReferenceHint').to.equal(VALID_PAYLOAD['reference-hint-text'])
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the amount page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.amount)
- })
- })
-
- describe(`when no payment reference is entered and standard reference is selected`, () => {
- let result, session, app
- const VALID_PAYLOAD = {
- 'csrfToken': csrf().create('123'),
- 'reference-type-group': 'standard',
- 'reference-label': '',
- 'reference-hint-text': ''
- }
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {})
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.reference)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- it('should have paymentReferenceType stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentReferenceType').to.equal(VALID_PAYLOAD['reference-type-group'])
- })
-
- it('should have paymentReferenceLabel stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentReferenceLabel').to.equal(VALID_PAYLOAD['reference-label'])
- })
-
- it('should have paymentReferenceHint stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('paymentReferenceHint').to.equal(VALID_PAYLOAD['reference-hint-text'])
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the amount page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.amount)
- })
- })
-
- describe(`when neither radio button is chosen`, () => {
- let result, session, app
- const VALID_PAYLOAD = {
- 'csrfToken': csrf().create('123'),
- 'reference-type-group': '',
- 'reference-label': '',
- 'reference-hint-text': ''
- }
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {})
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.reference)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- it('should have a recovered object stored on the session containing error', () => {
- const recovered = lodash.get(session, 'pageData.createPaymentLink.referencePageRecovered', {})
- expect(recovered.errors).to.have.property('type')
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect back to itself', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.reference)
- })
- })
-
- describe(`when custom reference radio button is chosen but no label is supplied`, () => {
- let result, session, app
- const VALID_PAYLOAD = {
- 'csrfToken': csrf().create('123'),
- 'reference-type-group': 'custom',
- 'reference-label': '',
- 'reference-hint-text': 'hint text'
- }
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {})
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.reference)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- it('should have a recovered object stored on the session containing errors and submitted data', () => {
- const recovered = lodash.get(session, 'pageData.createPaymentLink.referencePageRecovered', {})
- expect(recovered).to.have.property('type').to.equal('custom')
- expect(recovered).to.have.property('label').to.equal('')
- expect(recovered).to.have.property('hint').to.equal('hint text')
- expect(recovered.errors).to.have.property('label')
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect back to itself', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.reference)
- })
- })
-})
diff --git a/test/unit/controller/payment-links/post-review.controller.ft.test.js b/test/unit/controller/payment-links/post-review.controller.ft.test.js
deleted file mode 100644
index 1ac1580f37..0000000000
--- a/test/unit/controller/payment-links/post-review.controller.ft.test.js
+++ /dev/null
@@ -1,291 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const lodash = require('lodash')
-const nock = require('nock')
-const csrf = require('csrf')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-const { randomUuid } = require('../../../../app/utils/random')
-const { validCreateProductRequest, validProductResponse } = require('../../../fixtures/product.fixtures')
-const { validGatewayAccountResponse } = require('../../../fixtures/gateway-account.fixtures')
-
-const { PUBLIC_AUTH_URL, PRODUCTS_URL, CONNECTOR_URL } = process.env
-const GATEWAY_ACCOUNT_ID = '929'
-const PAYMENT_TITLE = 'Payment title'
-const PAYMENT_DESCRIPTION = 'Payment description'
-const PAYMENT_LINK_AMOUNT = 500
-const VALID_PAYLOAD = {
- 'csrfToken': csrf().create('123')
-}
-const VALID_USER = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
-})
-const VALID_CREATE_TOKEN_REQUEST = {
- account_id: GATEWAY_ACCOUNT_ID,
- created_by: VALID_USER.email,
- type: 'PRODUCTS',
- description: `Token for “${PAYMENT_TITLE}” payment link`,
- token_account_type: 'test'
-}
-const VALID_MINIMAL_GATEWAY_ACCOUNT_RESPONSE = validGatewayAccountResponse({ gateway_account_id: GATEWAY_ACCOUNT_ID })
-const VALID_CREATE_TOKEN_RESPONSE = { token: randomUuid() }
-
-const buildCreateProductRequest = (language, hasMetadata) => {
- return validCreateProductRequest({
- name: PAYMENT_TITLE,
- description: PAYMENT_DESCRIPTION,
- gatewayAccountId: GATEWAY_ACCOUNT_ID,
- payApiToken: VALID_CREATE_TOKEN_RESPONSE.token,
- serviceName: VALID_USER.serviceRoles[0].service.name,
- price: PAYMENT_LINK_AMOUNT,
- type: 'ADHOC',
- reference_enabled: false,
- language: language,
- ...hasMetadata && { metadata: { 'a-key': 'a-value' } }
- })
-}
-
-describe('Create payment link review controller', () => {
- describe('successfull submission with metadata', () => {
- let result, session, app
- before('Arrange', () => {
- const expectedProductRequest = buildCreateProductRequest('en', true)
- const productResponse = validProductResponse(expectedProductRequest)
- nock(PUBLIC_AUTH_URL).post('', VALID_CREATE_TOKEN_REQUEST).reply(201, VALID_CREATE_TOKEN_RESPONSE)
- nock(PRODUCTS_URL).post('/v1/api/products', expectedProductRequest).reply(201, productResponse)
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, VALID_MINIMAL_GATEWAY_ACCOUNT_RESPONSE)
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {
- paymentLinkTitle: PAYMENT_TITLE,
- paymentLinkDescription: PAYMENT_DESCRIPTION,
- paymentLinkAmount: PAYMENT_LINK_AMOUNT,
- isWelsh: false,
- metadata: {
- 'a-key': 'a-value'
- }
- })
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.review)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the manage page with a success message', () => {
- expect(session.flash).to.have.property('createPaymentLinkSuccess')
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.manage.index)
- })
- })
- describe('successful submission for a Welsh payment link without metadata', () => {
- let result, session, app
- before('Arrange', () => {
- const expectedProductRequest = buildCreateProductRequest('cy')
- const productResponse = validProductResponse(expectedProductRequest)
- nock(PUBLIC_AUTH_URL).post('', VALID_CREATE_TOKEN_REQUEST).reply(201, VALID_CREATE_TOKEN_RESPONSE)
- nock(PRODUCTS_URL).post('/v1/api/products', expectedProductRequest).reply(201, productResponse)
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, VALID_MINIMAL_GATEWAY_ACCOUNT_RESPONSE)
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {
- paymentLinkTitle: PAYMENT_TITLE,
- paymentLinkDescription: PAYMENT_DESCRIPTION,
- paymentLinkAmount: PAYMENT_LINK_AMOUNT,
- isWelsh: true
- })
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.review)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the manage page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.manage.index)
- })
- })
- describe('the product creation fails', () => {
- let result, session, app
-
- before('Arrange', () => {
- const expectedProductRequest = buildCreateProductRequest('en')
- nock(PUBLIC_AUTH_URL).post('', VALID_CREATE_TOKEN_REQUEST).reply(201, VALID_CREATE_TOKEN_RESPONSE)
- nock(PRODUCTS_URL).post('/v1/api/products', expectedProductRequest).replyWithError('Something went wrong')
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, VALID_MINIMAL_GATEWAY_ACCOUNT_RESPONSE)
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {
- paymentLinkTitle: PAYMENT_TITLE,
- paymentLinkDescription: PAYMENT_DESCRIPTION,
- paymentLinkAmount: PAYMENT_LINK_AMOUNT,
- isWelsh: false
- })
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.review)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect back to the review page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.review)
- })
-
- it('should add a relevant error message to the session \'flash\'', () => {
- expect(session.flash).to.have.property('genericError')
- expect(session.flash.genericError.length).to.equal(1)
- expect(session.flash.genericError[0]).to.equal('Something went wrong. Please try again or contact support.')
- })
- })
- describe('when the API token creation fails', () => {
- let result, session, app
- before('Arrange', () => {
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, VALID_MINIMAL_GATEWAY_ACCOUNT_RESPONSE)
- nock(PUBLIC_AUTH_URL).post('', VALID_CREATE_TOKEN_REQUEST).replyWithError('Something went wrong')
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {
- paymentLinkTitle: PAYMENT_TITLE,
- paymentLinkDescription: PAYMENT_DESCRIPTION,
- isWelsh: false
- })
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.review)
- .send({
- 'csrfToken': csrf().create('123')
- })
- .end((err, res) => {
- result = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect back to the index page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.review)
- })
-
- it('should add a relevant error message to the session \'flash\'', () => {
- expect(session.flash).to.have.property('genericError')
- expect(session.flash.genericError.length).to.equal(1)
- expect(session.flash.genericError[0]).to.equal('Something went wrong. Please try again or contact support.')
- })
- })
- describe('when paymentDescription in missing from the session', () => {
- let result, session, app
- before('Arrange', () => {
- const expectedProductRequest = buildCreateProductRequest('en')
- const productResponse = validProductResponse(expectedProductRequest)
- nock(PUBLIC_AUTH_URL).post('', VALID_CREATE_TOKEN_REQUEST).reply(201, VALID_CREATE_TOKEN_RESPONSE)
- nock(PRODUCTS_URL).post('/v1/api/products', lodash.omit(expectedProductRequest, 'description')).reply(201, productResponse)
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, VALID_MINIMAL_GATEWAY_ACCOUNT_RESPONSE)
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {
- paymentLinkTitle: PAYMENT_TITLE,
- paymentLinkAmount: PAYMENT_LINK_AMOUNT,
- isWelsh: false
- })
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.review)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the manage page with a success message', () => {
- expect(session.flash).to.have.property('createPaymentLinkSuccess')
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.manage.index)
- })
- })
- describe('when paymentLinkTitle is missing from the session', () => {
- let result, app
-
- before('Arrange', () => {
- nock(CONNECTOR_URL).get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`).reply(200, VALID_MINIMAL_GATEWAY_ACCOUNT_RESPONSE)
- const session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink.paymentLinkDescription', PAYMENT_DESCRIPTION)
- app = createAppWithSession(getApp(), session)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.review)
- .send({
- 'csrfToken': csrf().create('123')
- })
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- after(() => {
- nock.cleanAll()
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect back to the start page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.start)
- })
- })
-})
diff --git a/test/unit/controller/payment-links/post-web-address.controller.ft.test.js b/test/unit/controller/payment-links/post-web-address.controller.ft.test.js
deleted file mode 100644
index e13a366fb6..0000000000
--- a/test/unit/controller/payment-links/post-web-address.controller.ft.test.js
+++ /dev/null
@@ -1,125 +0,0 @@
-'use strict'
-
-const supertest = require('supertest')
-const { expect } = require('chai')
-const lodash = require('lodash')
-const nock = require('nock')
-const csrf = require('csrf')
-
-const { getApp } = require('../../../../server')
-const { getMockSession, createAppWithSession, getUser } = require('../../../test-helpers/mock-session')
-const paths = require('../../../../app/paths')
-const { validProductResponse } = require('../../../fixtures/product.fixtures')
-
-const { PRODUCTS_URL } = process.env
-let product
-const GATEWAY_ACCOUNT_ID = '929'
-const VALID_USER = getUser({
- gateway_account_ids: [GATEWAY_ACCOUNT_ID],
- permissions: [{ name: 'tokens:create' }]
-})
-const SERVICE_NAME_SLUGIFIED = 'pay-for-offline-service'
-const PAYMENT_TITLE_SLUGIFIED = 'payment-title'
-const VALID_PAYLOAD = {
- 'csrfToken': csrf().create('123'),
- 'payment-name-path': PAYMENT_TITLE_SLUGIFIED
-}
-
-describe('Create payment link web address post controller', () => {
- describe(`when an available product path name is submitted`, () => {
- let result, session, app
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- lodash.set(session, 'pageData.createPaymentLink', {
- paymentLinkTitle: 'Payment title',
- paymentLinkDescription: 'Hello world',
- serviceNamePath: SERVICE_NAME_SLUGIFIED,
- productNamePath: PAYMENT_TITLE_SLUGIFIED
- })
- app = createAppWithSession(getApp(), session)
- product = validProductResponse({
- type: 'ADHOC',
- service_name_path: SERVICE_NAME_SLUGIFIED,
- product_name_path: PAYMENT_TITLE_SLUGIFIED
- })
- nock(PRODUCTS_URL)
- .get(`/v1/api/products`)
- .query({ 'serviceNamePath': product.service_name_path, 'productNamePath': product.product_name_path })
- .reply(404, product)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.webAddress)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- it('should have productNamePath stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('productNamePath').to.equal(PAYMENT_TITLE_SLUGIFIED)
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the reference page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.reference)
- })
- })
-
- describe(`when an unavailable product path name is submitted`, () => {
- let result, session, app
- before('Arrange', () => {
- session = getMockSession(VALID_USER)
- app = createAppWithSession(getApp(), session)
- lodash.set(session, 'pageData.createPaymentLink', {
- paymentLinkTitle: 'Payment title',
- paymentLinkDescription: 'Hello world',
- serviceNamePath: SERVICE_NAME_SLUGIFIED,
- productNamePath: PAYMENT_TITLE_SLUGIFIED
- })
- product = validProductResponse({
- type: 'ADHOC',
- service_name_path: SERVICE_NAME_SLUGIFIED,
- product_name_path: PAYMENT_TITLE_SLUGIFIED
- })
- nock(PRODUCTS_URL)
- .get(`/v1/api/products`)
- .query({ 'serviceNamePath': product.service_name_path, 'productNamePath': product.product_name_path })
- .reply(200, product)
- })
- before('Act', done => {
- supertest(app)
- .post(paths.paymentLinks.webAddress)
- .send(VALID_PAYLOAD)
- .end((err, res) => {
- result = res
- done(err)
- })
- })
-
- it('should have productNamePath stored in the session', () => {
- const sessionPageData = lodash.get(session, 'pageData.createPaymentLink', {})
- expect(sessionPageData).to.have.property('productNamePath').to.equal(PAYMENT_TITLE_SLUGIFIED)
- })
-
- it('should redirect with status code 302', () => {
- expect(result.statusCode).to.equal(302)
- })
-
- it('should redirect to the web address page', () => {
- expect(result.headers).to.have.property('location').to.equal(paths.paymentLinks.webAddress)
- })
-
- it('should have a recovered object stored on the session containing errors and submitted data', () => {
- const recovered = lodash.get(session, 'pageData.createPaymentLink.webAddressPageRecovered', {})
- expect(recovered).to.have.property('paymentLinkURLPath').to.equal(PAYMENT_TITLE_SLUGIFIED)
- expect(recovered).to.have.property('errors')
- expect(recovered.errors).to.have.property('path')
- })
- })
-})