diff --git a/app/controllers/stripe-setup/add-psp-account-details/get.controller.test.js b/app/controllers/stripe-setup/add-psp-account-details/get.controller.test.js index 026e4c69d6..e0ab5ba0a3 100644 --- a/app/controllers/stripe-setup/add-psp-account-details/get.controller.test.js +++ b/app/controllers/stripe-setup/add-psp-account-details/get.controller.test.js @@ -35,13 +35,13 @@ describe('get controller', () => { it('should redirect to bank account setup page', async () => { req.account.connectorGatewayAccountStripeProgress.bankAccount = false getController(req, res) - sinon.assert.calledWith(res.redirect, 303, `/account/a-valid-external-id/${paths.account.stripeSetup.bankDetails}`) + sinon.assert.calledWith(res.redirect, 303, `/account/a-valid-external-id${paths.account.stripeSetup.bankDetails}`) }) it('should redirect to responsible person page', async () => { req.account.connectorGatewayAccountStripeProgress.bankAccount = true getController(req, res) - sinon.assert.calledWith(res.redirect, 303, `/account/a-valid-external-id/${paths.account.stripeSetup.responsiblePerson}`) + sinon.assert.calledWith(res.redirect, 303, `/account/a-valid-external-id${paths.account.stripeSetup.responsiblePerson}`) }) it('should redirect to VAT number page', async () => { @@ -50,7 +50,7 @@ describe('get controller', () => { responsiblePerson: true } getController(req, res) - sinon.assert.calledWith(res.redirect, 303, `/account/a-valid-external-id/${paths.account.stripeSetup.vatNumber}`) + sinon.assert.calledWith(res.redirect, 303, `/account/a-valid-external-id${paths.account.stripeSetup.vatNumber}`) }) it('should redirect to company registration number page', async () => { @@ -60,7 +60,7 @@ describe('get controller', () => { vatNumber: true } getController(req, res) - sinon.assert.calledWith(res.redirect, 303, `/account/a-valid-external-id/${paths.account.stripeSetup.companyNumber}`) + sinon.assert.calledWith(res.redirect, 303, `/account/a-valid-external-id${paths.account.stripeSetup.companyNumber}`) }) it('should render go live complete page when all steps are completed', async () => { diff --git a/app/controllers/stripe-setup/bank-details/post.controller.test.js b/app/controllers/stripe-setup/bank-details/post.controller.test.js index 9d7d3689bf..43e9f0b9ad 100644 --- a/app/controllers/stripe-setup/bank-details/post.controller.test.js +++ b/app/controllers/stripe-setup/bank-details/post.controller.test.js @@ -53,7 +53,7 @@ describe('Bank details post controller', () => { bank_account_number: sanitisedAccountNumber }) sinon.assert.calledWith(setStripeAccountSetupFlagMock, req.account.gateway_account_id, 'bank_account', req.correlationId) - sinon.assert.calledWith(res.redirect, 303, `/account/a-valid-external-id/${paths.account.stripe.addPspAccountDetails}`) + sinon.assert.calledWith(res.redirect, 303, `/account/a-valid-external-id${paths.account.stripe.addPspAccountDetails}`) }) it('should render error page when Stripe returns unknown error', async () => { diff --git a/app/controllers/stripe-setup/responsible-person/post.controller.test.js b/app/controllers/stripe-setup/responsible-person/post.controller.test.js index 1931c97dc2..81c621a994 100644 --- a/app/controllers/stripe-setup/responsible-person/post.controller.test.js +++ b/app/controllers/stripe-setup/responsible-person/post.controller.test.js @@ -109,7 +109,7 @@ describe('Responsible person POST controller', () => { dob_year: dobYearNormalised }) sinon.assert.calledWith(setStripeAccountSetupFlagMock, req.account.gateway_account_id, 'responsible_person', req.correlationId) - sinon.assert.calledWith(res.redirect, 303, `/account/a-valid-external-id/${paths.account.stripe.addPspAccountDetails}`) + sinon.assert.calledWith(res.redirect, 303, `/account/a-valid-external-id${paths.account.stripe.addPspAccountDetails}`) }) it('should call Stripe with normalised details (no second address line), then connector, then redirect to add details redirect route', async function () { @@ -138,7 +138,7 @@ describe('Responsible person POST controller', () => { dob_year: dobYearNormalised }) sinon.assert.calledWith(setStripeAccountSetupFlagMock, req.account.gateway_account_id, 'responsible_person', req.correlationId) - sinon.assert.calledWith(res.redirect, 303, `/account/a-valid-external-id/${paths.account.stripe.addPspAccountDetails}`) + sinon.assert.calledWith(res.redirect, 303, `/account/a-valid-external-id${paths.account.stripe.addPspAccountDetails}`) }) it('should render error when Stripe returns error, not call connector, and not redirect', async function () { diff --git a/app/paths.js b/app/paths.js index 5ea2e463ba..982a573110 100644 --- a/app/paths.js +++ b/app/paths.js @@ -95,36 +95,6 @@ module.exports = { flex: '/your-psp/flex', worldpay3dsFlex: '/your-psp/worldpay-3ds-flex' }, - apiKeys: { - index: '/api-keys', - revoked: '/api-keys/revoked', - create: '/api-keys/create', - revoke: '/api-keys/revoke', - update: '/api-keys/update' - }, - paymentLinks: { - start: '/create-payment-link', - information: '/create-payment-link/information', - webAddress: '/create-payment-link/web-address', - reference: '/create-payment-link/reference', - amount: '/create-payment-link/amount', - review: '/create-payment-link/review', - addMetadata: '/create-payment-link/add-reporting-column', - editMetadata: '/create-payment-link/add-reporting-column/:metadataKey', - deleteMetadata: '/create-payment-link/add-reporting-column/:metadataKey/delete', - manage: { - index: '/create-payment-link/manage', - edit: '/create-payment-link/manage/edit/:productExternalId', - disable: '/create-payment-link/manage/disable/:productExternalId', - delete: '/create-payment-link/manage/delete/:productExternalId', - editInformation: '/create-payment-link/manage/edit/information/:productExternalId', - editReference: '/create-payment-link/manage/edit/reference/:productExternalId', - editAmount: '/create-payment-link/manage/edit/amount/:productExternalId', - addMetadata: '/create-payment-link/manage/:productExternalId/add-reporting-column', - editMetadata: '/create-payment-link/manage/:productExternalId/add-reporting-column/:metadataKey', - deleteMetadata: '/create-payment-link/manage/:productExternalId/add-reporting-column/:metadataKey/delete' - } - }, stripeSetup: { bankDetails: '/bank-details', responsiblePerson: '/responsible-person', diff --git a/app/routes.js b/app/routes.js index 21c198b0ab..b39efe4d4e 100644 --- a/app/routes.js +++ b/app/routes.js @@ -193,9 +193,8 @@ module.exports.bind = function (app) { ...lodash.values(user.profile), ...lodash.values(requestToGoLive), ...lodash.values(policyPages), - ...lodash.values(stripeSetup), - ...lodash.values(stripe), ...lodash.values(payouts), + ...lodash.values(redirects), paths.feedback ] // Extract all the authenticated paths as a single array diff --git a/app/views/stripe-setup/bank-details/index.njk b/app/views/stripe-setup/bank-details/index.njk index 4a21b9c88f..dcd8b4d8b6 100644 --- a/app/views/stripe-setup/bank-details/index.njk +++ b/app/views/stripe-setup/bank-details/index.njk @@ -29,7 +29,7 @@

This is the bank account payments will go into.

+ data-validate="true"> {% set sortCodeError = false %} diff --git a/app/views/stripe-setup/company-number/index.njk b/app/views/stripe-setup/company-number/index.njk index c398aef241..f607ba1384 100644 --- a/app/views/stripe-setup/company-number/index.njk +++ b/app/views/stripe-setup/company-number/index.njk @@ -27,7 +27,7 @@ {% endif %} + > {% set companyNumberError = false %} diff --git a/app/views/stripe-setup/responsible-person/index.njk b/app/views/stripe-setup/responsible-person/index.njk index 0c07e1778c..6976acaca9 100644 --- a/app/views/stripe-setup/responsible-person/index.njk +++ b/app/views/stripe-setup/responsible-person/index.njk @@ -73,7 +73,7 @@

Stripe will store the responsible person’s details, not GOV.UK Pay.

- + {% call govukFieldset({ diff --git a/app/views/stripe-setup/vat-number/index.njk b/app/views/stripe-setup/vat-number/index.njk index da3d2ebf13..0a0a42d2f8 100644 --- a/app/views/stripe-setup/vat-number/index.njk +++ b/app/views/stripe-setup/vat-number/index.njk @@ -22,7 +22,7 @@

+ novalidate> {% set vatNumberError = false %} diff --git a/test/cypress/integration/dashboard/dashboard-stripe-add-details.cy.test.js b/test/cypress/integration/dashboard/dashboard-stripe-add-details.cy.test.js index db8bc71b96..2db56684fe 100644 --- a/test/cypress/integration/dashboard/dashboard-stripe-add-details.cy.test.js +++ b/test/cypress/integration/dashboard/dashboard-stripe-add-details.cy.test.js @@ -7,13 +7,15 @@ const stripeAccountSetupStubs = require('../../stubs/stripe-account-setup-stub') const stripeAccountStubs = require('../../stubs/stripe-account-stubs') describe('The Stripe psp details banner', () => { - const gatewayAccountId = 22 + const gatewayAccountId = '22' + const gatewayAccountExternalId = 'a-valid-external-id' const userExternalId = 'cd0fa54cf3b7408a80ae2f1b93e7c16e' beforeEach(() => { cy.setEncryptedCookies(userExternalId, gatewayAccountId) cy.task('setupStubs', [ - userStubs.getUserSuccess({ userExternalId, gatewayAccountId }), + userStubs.getUserSuccess({ userExternalId, gatewayAccountId, gatewayAccountExternalId }), gatewayAccountStubs.getGatewayAccountSuccess({ gatewayAccountId, type: 'live', paymentProvider: 'stripe' }), + gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId, type: 'live', paymentProvider: 'stripe' }), transactionsSummaryStubs.getDashboardStatistics(), stripeAccountSetupStubs.getGatewayAccountStripeSetupSuccess({ gatewayAccountId, diff --git a/test/cypress/integration/stripe-setup/bank-details.cy.test.js b/test/cypress/integration/stripe-setup/bank-details.cy.test.js index e22996f645..ff4a875b9a 100644 --- a/test/cypress/integration/stripe-setup/bank-details.cy.test.js +++ b/test/cypress/integration/stripe-setup/bank-details.cy.test.js @@ -6,7 +6,7 @@ const transactionSummaryStubs = require('../../stubs/transaction-summary-stubs') const stripeAccountSetupStubs = require('../../stubs/stripe-account-setup-stub') const stripeAccountStubs = require('../../stubs/stripe-account-stubs') -function setupStubs (userExternalId, gatewayAccountId, bankAccount, type = 'live', paymentProvider = 'stripe') { +function setupStubs (userExternalId, gatewayAccountId, gatewayAccountExternalId, bankAccount, type = 'live', paymentProvider = 'stripe') { let stripeSetupStub if (Array.isArray(bankAccount)) { @@ -20,7 +20,7 @@ function setupStubs (userExternalId, gatewayAccountId, bankAccount, type = 'live cy.task('setupStubs', [ userStubs.getUserSuccess({ userExternalId, gatewayAccountId }), - gatewayAccountStubs.getGatewayAccountSuccess({ gatewayAccountId, type, paymentProvider }), + gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId, type, paymentProvider }), stripeSetupStub, stripeAccountStubs.getStripeAccountSuccess(gatewayAccountId, 'acct_123example123'), transactionSummaryStubs.getDashboardStatistics() @@ -28,7 +28,8 @@ function setupStubs (userExternalId, gatewayAccountId, bankAccount, type = 'live } describe('Stripe setup: bank details page', () => { - const gatewayAccountId = 42 + const gatewayAccountId = '42' + const gatewayAccountExternalId = 'a-valid-external-id' const userExternalId = 'userExternalId' const accountNumber = '00012345' const sortCode = '108800' @@ -40,8 +41,8 @@ describe('Stripe setup: bank details page', () => { describe('Bank details page is shown', () => { beforeEach(() => { - setupStubs(userExternalId, gatewayAccountId, false) - cy.visit('/bank-details') + setupStubs(userExternalId, gatewayAccountId, gatewayAccountExternalId, false) + cy.visit('/account/a-valid-external-id/bank-details') }) it('should display page correctly', () => { @@ -75,9 +76,9 @@ describe('Stripe setup: bank details page', () => { describe('Bank account flag already true', () => { it('should redirect to Dashboard with an error message when on Bank details page', () => { - setupStubs(userExternalId, gatewayAccountId, true) + setupStubs(userExternalId, gatewayAccountId, gatewayAccountExternalId, true) - cy.visit('/bank-details') + cy.visit('/account/a-valid-external-id/bank-details') cy.get('h1').should('contain', 'Dashboard') cy.location().should((location) => { @@ -88,9 +89,9 @@ describe('Stripe setup: bank details page', () => { }) it('should redirect to Dashboard with an error message when submitting Bank details page', () => { - setupStubs(userExternalId, gatewayAccountId, [false, true], 'live', 'stripe') + setupStubs(userExternalId, gatewayAccountId, gatewayAccountExternalId, [false, true], 'live', 'stripe') - cy.visit('/bank-details') + cy.visit('/account/a-valid-external-id/bank-details') cy.get('input#account-number[name="account-number"]').type(accountNumber) cy.get('input#sort-code[name="sort-code"]').type(sortCode) @@ -107,9 +108,9 @@ describe('Stripe setup: bank details page', () => { describe('Not a Stripe gateway account', () => { it('should show a 404 error when gateway account is not Stripe', () => { - setupStubs(userExternalId, gatewayAccountId, true, 'live', 'sandbox') + setupStubs(userExternalId, gatewayAccountId, gatewayAccountExternalId, true, 'live', 'sandbox') - cy.visit('/bank-details', { + cy.visit('/account/a-valid-external-id/bank-details', { failOnStatusCode: false }) cy.get('h1').should('contain', 'Page not found') @@ -118,9 +119,9 @@ describe('Stripe setup: bank details page', () => { describe('Not a live gateway account', () => { it('should show a 404 error when gateway account is not live', () => { - setupStubs(userExternalId, gatewayAccountId, false, 'test', 'sandbox') + setupStubs(userExternalId, gatewayAccountId, gatewayAccountExternalId, false, 'test', 'sandbox') - cy.visit('/bank-details', { + cy.visit('/account/a-valid-external-id/bank-details', { failOnStatusCode: false }) cy.get('h1').should('contain', 'Page not found') @@ -131,10 +132,11 @@ describe('Stripe setup: bank details page', () => { it('should show a permission error when the user does not have enough permissions', () => { cy.task('setupStubs', [ userStubs.getUserWithNoPermissions(userExternalId, gatewayAccountId), - gatewayAccountStubs.getGatewayAccountSuccess({ gatewayAccountId, type: 'live', paymentProvider: 'stripe' }) + gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId, type: 'live', paymentProvider: 'stripe' }), + stripeAccountSetupStubs.getGatewayAccountStripeSetupSuccess({ gatewayAccountId, bankAccount: false }) ]) - cy.visit('/bank-details', { + cy.visit('/account/a-valid-external-id/bank-details', { failOnStatusCode: false }) cy.get('h1').should('contain', 'An error occurred:') diff --git a/test/cypress/integration/stripe-setup/company-number.cy.test.js b/test/cypress/integration/stripe-setup/company-number.cy.test.js index b3fa4cb3d7..96a6193e07 100644 --- a/test/cypress/integration/stripe-setup/company-number.cy.test.js +++ b/test/cypress/integration/stripe-setup/company-number.cy.test.js @@ -6,6 +6,8 @@ const transactionSummaryStubs = require('../../stubs/transaction-summary-stubs') const stripeAccountSetupStubs = require('../../stubs/stripe-account-setup-stub') const stripeAccountStubs = require('../../stubs/stripe-account-stubs') +const GATEWAY_ACCOUNT_EXTERNAL_ID = 'a-valid-external-id' + function setupStubs (userExternalId, gatewayAccountId, companyNumber, type = 'live', paymentProvider = 'stripe') { let stripeSetupStub @@ -20,7 +22,7 @@ function setupStubs (userExternalId, gatewayAccountId, companyNumber, type = 'li cy.task('setupStubs', [ userStubs.getUserSuccess({ userExternalId, gatewayAccountId }), - gatewayAccountStubs.getGatewayAccountSuccess({ gatewayAccountId, type, paymentProvider }), + gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId: GATEWAY_ACCOUNT_EXTERNAL_ID, type, paymentProvider }), stripeSetupStub, stripeAccountStubs.getStripeAccountSuccess(gatewayAccountId, 'acct_123example123'), transactionSummaryStubs.getDashboardStatistics() @@ -37,7 +39,7 @@ describe('Stripe setup: company number page', () => { setupStubs(userExternalId, gatewayAccountId, false) cy.setEncryptedCookies(userExternalId, gatewayAccountId, {}) - cy.visit('/company-number') + cy.visit('/account/a-valid-external-id/company-number') }) it('should display page correctly', () => { @@ -109,7 +111,7 @@ describe('Stripe setup: company number page', () => { it('should redirect to Dashboard with an error message when displaying the page', () => { setupStubs(userExternalId, gatewayAccountId, true) - cy.visit('/company-number') + cy.visit('/account/a-valid-external-id/company-number') cy.get('h1').should('contain', 'Dashboard') cy.location().should((location) => { @@ -122,7 +124,7 @@ describe('Stripe setup: company number page', () => { it('should redirect to Dashboard with an error message when submitting the form', () => { setupStubs(userExternalId, gatewayAccountId, [false, true]) - cy.visit('/company-number') + cy.visit('/account/a-valid-external-id/company-number') cy.get('#company-number-form').should('exist') .within(() => { @@ -149,7 +151,7 @@ describe('Stripe setup: company number page', () => { it('should show a 404 error when gateway account is not Stripe', () => { setupStubs(userExternalId, gatewayAccountId, [false, true], 'live', 'sandbox') - cy.visit('/company-number', { + cy.visit('/account/a-valid-external-id/company-number', { failOnStatusCode: false }) cy.get('h1').should('contain', 'Page not found') @@ -164,7 +166,7 @@ describe('Stripe setup: company number page', () => { it('should show a 404 error when gateway account is not live', () => { setupStubs(userExternalId, gatewayAccountId, [false, true], 'test', 'stripe') - cy.visit('/company-number', { + cy.visit('/account/a-valid-external-id/company-number', { failOnStatusCode: false }) cy.get('h1').should('contain', 'Page not found') @@ -179,10 +181,11 @@ describe('Stripe setup: company number page', () => { it('should show a permission error when the user does not have enough permissions', () => { cy.task('setupStubs', [ userStubs.getUserWithNoPermissions(userExternalId, gatewayAccountId), - gatewayAccountStubs.getGatewayAccountSuccess({ gatewayAccountId, type: 'live', paymentProvider: 'stripe' }) + gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId: GATEWAY_ACCOUNT_EXTERNAL_ID, type: 'live', paymentProvider: 'stripe' }), + stripeAccountSetupStubs.getGatewayAccountStripeSetupSuccess({ gatewayAccountId, companyNumber: true }) ]) - cy.visit('/company-number', { failOnStatusCode: false }) + cy.visit('/account/a-valid-external-id/company-number', { failOnStatusCode: false }) cy.get('h1').should('contain', 'An error occurred:') cy.get('#errorMsg').should('contain', 'You do not have the administrator rights to perform this operation.') }) diff --git a/test/cypress/integration/stripe-setup/responsible-person.cy.test.js b/test/cypress/integration/stripe-setup/responsible-person.cy.test.js index f450eed947..35590c1bca 100644 --- a/test/cypress/integration/stripe-setup/responsible-person.cy.test.js +++ b/test/cypress/integration/stripe-setup/responsible-person.cy.test.js @@ -6,6 +6,8 @@ const transactionSummaryStubs = require('../../stubs/transaction-summary-stubs') const stripeAccountSetupStubs = require('../../stubs/stripe-account-setup-stub') const stripeAccountStubs = require('../../stubs/stripe-account-stubs') +const GATEWAY_ACCOUNT_EXTERNAL_ID = 'a-valid-external-id' + function setupStubs (userExternalId, gatewayAccountId, responsiblePerson, type = 'live', paymentProvider = 'stripe') { let stripeSetupStub @@ -20,7 +22,7 @@ function setupStubs (userExternalId, gatewayAccountId, responsiblePerson, type = cy.task('setupStubs', [ userStubs.getUserSuccess({ userExternalId, gatewayAccountId }), - gatewayAccountStubs.getGatewayAccountSuccess({ gatewayAccountId, type, paymentProvider }), + gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId: GATEWAY_ACCOUNT_EXTERNAL_ID, type, paymentProvider }), stripeSetupStub, stripeAccountStubs.getStripeAccountSuccess(gatewayAccountId, 'acct_123example123'), transactionSummaryStubs.getDashboardStatistics() @@ -52,7 +54,7 @@ describe('Stripe setup: responsible person page', () => { beforeEach(() => { setupStubs(userExternalId, gatewayAccountId, false) - cy.visit('/responsible-person') + cy.visit('/account/a-valid-external-id/responsible-person') }) it('should display form', () => { @@ -149,7 +151,7 @@ describe('Stripe setup: responsible person page', () => { beforeEach(() => { setupStubs(userExternalId, gatewayAccountId, true) - cy.visit('/responsible-person') + cy.visit('/account/a-valid-external-id/responsible-person') }) it('should redirect to dashboard with error message instead of showing form', () => { @@ -165,7 +167,7 @@ describe('Stripe setup: responsible person page', () => { beforeEach(() => { setupStubs(userExternalId, gatewayAccountId, [false, true]) - cy.visit('/responsible-person') + cy.visit('/account/a-valid-external-id/responsible-person') }) it('should redirect to dashboard with error message instead of saving details', () => { @@ -194,7 +196,7 @@ describe('Stripe setup: responsible person page', () => { beforeEach(() => { setupStubs(userExternalId, gatewayAccountId, false, 'live', 'worldpay') - cy.visit('/responsible-person', { failOnStatusCode: false }) + cy.visit('/account/a-valid-external-id/responsible-person', { failOnStatusCode: false }) }) it('should return a 404', () => { @@ -206,10 +208,11 @@ describe('Stripe setup: responsible person page', () => { beforeEach(() => { cy.task('setupStubs', [ userStubs.getUserWithNoPermissions(userExternalId, gatewayAccountId), - gatewayAccountStubs.getGatewayAccountSuccess({ gatewayAccountId, type: 'live', paymentProvider: 'stripe' }) + gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId: GATEWAY_ACCOUNT_EXTERNAL_ID, type: 'live', paymentProvider: 'stripe' }), + stripeAccountSetupStubs.getGatewayAccountStripeSetupSuccess({ gatewayAccountId, responsiblePerson: true }) ]) - cy.visit('/responsible-person', { failOnStatusCode: false }) + cy.visit('/account/a-valid-external-id/responsible-person', { failOnStatusCode: false }) }) it('should show a permission denied error', () => { diff --git a/test/cypress/integration/stripe-setup/vat-number.cy.test.js b/test/cypress/integration/stripe-setup/vat-number.cy.test.js index e86f8599f2..85a6120627 100644 --- a/test/cypress/integration/stripe-setup/vat-number.cy.test.js +++ b/test/cypress/integration/stripe-setup/vat-number.cy.test.js @@ -6,6 +6,8 @@ const transactionSummaryStubs = require('../../stubs/transaction-summary-stubs') const stripeAccountSetupStubs = require('../../stubs/stripe-account-setup-stub') const stripeAccountStubs = require('../../stubs/stripe-account-stubs') +const GATEWAY_ACCOUNT_EXTERNAL_ID = 'a-valid-external-id' + function setupStubs (userExternalId, gatewayAccountId, vatNumber, type = 'live', paymentProvider = 'stripe') { let stripeSetupStub @@ -20,7 +22,7 @@ function setupStubs (userExternalId, gatewayAccountId, vatNumber, type = 'live', cy.task('setupStubs', [ userStubs.getUserSuccess({ userExternalId, gatewayAccountId }), - gatewayAccountStubs.getGatewayAccountSuccess({ gatewayAccountId, type, paymentProvider }), + gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId: GATEWAY_ACCOUNT_EXTERNAL_ID, type, paymentProvider }), stripeSetupStub, stripeAccountStubs.getStripeAccountSuccess(gatewayAccountId, 'acct_123example123'), transactionSummaryStubs.getDashboardStatistics() @@ -28,7 +30,7 @@ function setupStubs (userExternalId, gatewayAccountId, vatNumber, type = 'live', } describe('Stripe setup: VAT number page', () => { - const gatewayAccountId = 42 + const gatewayAccountId = '42' const userExternalId = 'userExternalId' describe('Card gateway account', () => { @@ -38,7 +40,7 @@ describe('Stripe setup: VAT number page', () => { cy.setEncryptedCookies(userExternalId, gatewayAccountId, {}) - cy.visit('/vat-number') + cy.visit('/account/a-valid-external-id/vat-number') }) it('should display page correctly', () => { @@ -89,7 +91,7 @@ describe('Stripe setup: VAT number page', () => { it('should redirect to Dashboard with an error message when displaying the page', () => { setupStubs(userExternalId, gatewayAccountId, true) - cy.visit('/vat-number') + cy.visit('/account/a-valid-external-id/vat-number') cy.get('h1').should('contain', 'Dashboard') cy.location().should((location) => { @@ -102,7 +104,7 @@ describe('Stripe setup: VAT number page', () => { it('should redirect to Dashboard with an error message when submitting the form', () => { setupStubs(userExternalId, gatewayAccountId, [false, true]) - cy.visit('/vat-number') + cy.visit('/account/a-valid-external-id/vat-number') cy.get('input#vat-number[name="vat-number"]').type('GB999 9999 73') @@ -125,7 +127,7 @@ describe('Stripe setup: VAT number page', () => { it('should show a 404 error when gateway account is not Stripe', () => { setupStubs(userExternalId, gatewayAccountId, false, 'live', 'sandbox') - cy.visit('/vat-number', { + cy.visit('/account/a-valid-external-id/vat-number', { failOnStatusCode: false }) cy.get('h1').should('contain', 'Page not found') @@ -140,7 +142,7 @@ describe('Stripe setup: VAT number page', () => { it('should show a 404 error when gateway account is not live', () => { setupStubs(userExternalId, gatewayAccountId, false, 'test', 'stripe') - cy.visit('/vat-number', { + cy.visit('/account/a-valid-external-id/vat-number', { failOnStatusCode: false }) cy.get('h1').should('contain', 'Page not found') @@ -155,10 +157,11 @@ describe('Stripe setup: VAT number page', () => { it('should show a permission error when the user does not have enough permissions', () => { cy.task('setupStubs', [ userStubs.getUserWithNoPermissions(userExternalId, gatewayAccountId), - gatewayAccountStubs.getGatewayAccountSuccess({ gatewayAccountId, type: 'live', paymentProvider: 'stripe' }) + gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId: GATEWAY_ACCOUNT_EXTERNAL_ID, type: 'live', paymentProvider: 'stripe' }), + stripeAccountSetupStubs.getGatewayAccountStripeSetupSuccess({ gatewayAccountId, vatNumber: true }) ]) - cy.visit('/vat-number', { failOnStatusCode: false }) + cy.visit('/account/a-valid-external-id/vat-number', { failOnStatusCode: false }) cy.get('h1').should('contain', 'An error occurred:') cy.get('#errorMsg').should('contain', 'You do not have the administrator rights to perform this operation.') }) diff --git a/test/cypress/stubs/user-stubs.js b/test/cypress/stubs/user-stubs.js index 788cecf024..b083192555 100644 --- a/test/cypress/stubs/user-stubs.js +++ b/test/cypress/stubs/user-stubs.js @@ -44,8 +44,8 @@ function getUserSuccessWithServiceRole (opts) { return builGetUserSuccessStub(opts.userExternalId, fixtureOpts) } -function getUserWithNoPermissions (userExternalId, gatewayAccountIds) { - return getUserSuccess({ userExternalId, gatewayAccountIds, goLiveStage: 'NOT_STARTED', role: { permissions: [] } }) +function getUserWithNoPermissions (userExternalId, gatewayAccountId) { + return getUserSuccess({ userExternalId, gatewayAccountId, goLiveStage: 'NOT_STARTED', role: { permissions: [] } }) } function postUserAuthenticateSuccess (userExternalId, username, password) { diff --git a/test/integration/add-psp-details.ft.test.js b/test/integration/add-psp-details.ft.test.js index 8f20ba2496..1ad31d910a 100644 --- a/test/integration/add-psp-details.ft.test.js +++ b/test/integration/add-psp-details.ft.test.js @@ -10,8 +10,8 @@ const { validGatewayAccountResponse } = require('../fixtures/gateway-account.fix const { buildGetStripeAccountSetupResponse } = require('../fixtures/stripe-account-setup.fixtures') const connectorMock = nock(process.env.CONNECTOR_URL) -const GATEWAY_ACCOUNT_ID = 111 - +const GATEWAY_ACCOUNT_ID = '111' +const GATEWAY_ACCOUNT_EXTERNAL_ID = 'a-valid-external-id' const { getApp } = require('../../server') const { getMockSession, createAppWithSession, getUser } = require('../test-helpers/mock-session') @@ -30,10 +30,10 @@ describe('Add stripe psp details route', function () { app = createAppWithSession(getApp(), session) connectorMock - .get(`/v1/frontend/accounts/${GATEWAY_ACCOUNT_ID}`) + .get(`/v1/frontend/accounts/external-id/${GATEWAY_ACCOUNT_EXTERNAL_ID}`) .reply(200, validGatewayAccountResponse({ gateway_account_id: GATEWAY_ACCOUNT_ID, - external_id: 'a-valid-external-id', + external_id: GATEWAY_ACCOUNT_EXTERNAL_ID, payment_provider: 'stripe', type: 'live' })) @@ -50,8 +50,10 @@ describe('Add stripe psp details route', function () { }) it('should load the "Go live complete" page', async () => { + const url = `/account/a-valid-external-id${paths.account.stripe.addPspAccountDetails}` + console.log('going to url', url) const res = await supertest(app) - .get(`/account/a-valid-external-id/${paths.account.stripe.addPspAccountDetails}`) + .get(url) const $ = cheerio.load(res.text) expect(res.statusCode).to.equal(200) expect($('h1').text()).to.contain('Go live complete')