From 45e7a5ce16557a7bbe0e95eaf8013001f378bcf2 Mon Sep 17 00:00:00 2001 From: James Peacock Date: Thu, 10 Oct 2024 13:00:05 +0100 Subject: [PATCH 1/2] PP-13174 Do not show test stripe link for new services Context: Changes to the onboarding flow on 29/08/2024 meant that local gov services were automatically allocated a Stripe test account. Therefore the link to create a Stripe test account should not be displayed for services that onboarded since that date. - add condition to only show the create Stripe test account link to services onboarding prior to 29/08/2024 - update Cypress tests accordingly --- .../dashboard-activity.controller.js | 5 +++- .../dashboard/dashboard-links.cy.js | 27 +++++++++++++++---- test/cypress/stubs/user-stubs.js | 4 +++ test/fixtures/service.fixtures.js | 6 +++-- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/controllers/dashboard/dashboard-activity.controller.js b/app/controllers/dashboard/dashboard-activity.controller.js index a2db72b416..45cb94837a 100644 --- a/app/controllers/dashboard/dashboard-activity.controller.js +++ b/app/controllers/dashboard/dashboard-activity.controller.js @@ -92,7 +92,10 @@ const displayGoLiveLink = (service, account, user) => { } const displayRequestTestStripeAccountLink = (service, account, user) => { - return account.payment_provider === 'sandbox' && service.currentGoLiveStage !== LIVE && + //Since 29/08/2024, services that identified as local govt were automatically allocated Stripe test accounts + //So services created after that date don't need a link to create a Stripe test account + const serviceCreatedBeforeOrgTypeCaptured = new Date(service.createdDate) <= new Date('2024-08-29'); + return account.payment_provider === 'sandbox' && service.currentGoLiveStage !== LIVE && serviceCreatedBeforeOrgTypeCaptured && service.currentPspTestAccountStage !== pspTestAccountStage.CREATED && user.hasPermission(service.externalId, 'psp-test-account-stage:update') } diff --git a/test/cypress/integration/dashboard/dashboard-links.cy.js b/test/cypress/integration/dashboard/dashboard-links.cy.js index 399730ff6f..106ae676e7 100644 --- a/test/cypress/integration/dashboard/dashboard-links.cy.js +++ b/test/cypress/integration/dashboard/dashboard-links.cy.js @@ -10,10 +10,10 @@ const gatewayAccountId = '42' const gatewayAccountExternalId = 'a-gateway-account-external-id' const dashboardUrl = `/account/${gatewayAccountExternalId}/dashboard` -function getStubsForDashboard (gatewayAccountId, type, paymentProvider, goLiveStage, pspTestAccountStage) { +function getStubsForDashboard (gatewayAccountId, type, paymentProvider, goLiveStage, pspTestAccountStage, createdDate) { let stubs = [] - stubs.push(userStubs.getUserSuccess({ userExternalId, gatewayAccountId, goLiveStage, pspTestAccountStage }), + stubs.push(userStubs.getUserSuccess({ userExternalId, gatewayAccountId, goLiveStage, pspTestAccountStage, createdDate }), gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ gatewayAccountId, gatewayAccountExternalId, @@ -66,8 +66,25 @@ describe('the links are displayed correctly on the dashboard', () => { cy.get('#payment-links-link').should('have.class', 'flex-grid--column-half') }) - it('should display 4 links for a test sandbox account', () => { - cy.task('setupStubs', getStubsForDashboard(gatewayAccountId, 'test', 'sandbox', 'NOT_STARTED')) + it('should display 3 links for a test sandbox account created since onboarding flow changed on 29/08/2024', () => { + cy.task('setupStubs', getStubsForDashboard(gatewayAccountId, 'test', 'sandbox', 'NOT_STARTED', null, '2024-08-30')) + + cy.visit(dashboardUrl) + cy.get('.links__box').should('have.length', 3) + + cy.get('#demo-payment-link').should('exist') + cy.get('#demo-payment-link').should('have.class', 'flex-grid--column-third') + + cy.get('#test-payment-link-link').should('exist') + cy.get('#test-payment-link-link').should('have.class', 'flex-grid--column-third') + + cy.get('#request-to-go-live-link').should('exist') + cy.get('#request-to-go-live-link').should('have.class', 'flex-grid--column-third') + + }) + + it('should display 4 links for a test sandbox account created before 29/08/2024', () => { + cy.task('setupStubs', getStubsForDashboard(gatewayAccountId, 'test', 'sandbox', 'NOT_STARTED', null, '2024-08-28')) cy.visit(dashboardUrl) cy.get('.links__box').should('have.length', 4) @@ -115,7 +132,7 @@ describe('the links are displayed correctly on the dashboard', () => { }) it('should display `Stripe test account requested` section if request has been submitted', () => { - cy.task('setupStubs', getStubsForDashboard(gatewayAccountId, 'test', 'sandbox', 'NOT_STARTED', 'REQUEST_SUBMITTED')) + cy.task('setupStubs', getStubsForDashboard(gatewayAccountId, 'test', 'sandbox', 'NOT_STARTED', 'REQUEST_SUBMITTED', '2024-08-28')) cy.visit(dashboardUrl) cy.get('.links__box').should('have.length', 4) diff --git a/test/cypress/stubs/user-stubs.js b/test/cypress/stubs/user-stubs.js index 9ea6cbd8df..737712051e 100644 --- a/test/cypress/stubs/user-stubs.js +++ b/test/cypress/stubs/user-stubs.js @@ -265,6 +265,10 @@ function buildServiceRoleOpts (opts) { serviceRole.role = opts.role } + if (opts.createdDate) { + service.created_date = opts.createdDate + } + return serviceRole } diff --git a/test/fixtures/service.fixtures.js b/test/fixtures/service.fixtures.js index c3ed87fce4..fd7927e870 100644 --- a/test/fixtures/service.fixtures.js +++ b/test/fixtures/service.fixtures.js @@ -118,7 +118,8 @@ module.exports = { current_go_live_stage: 'NOT_STARTED', current_psp_test_account_stage: 'NOT_STARTED', agent_initiated_moto_enabled: false, - takes_payments_over_phone: false + takes_payments_over_phone: false, + created_date: '2024-08-30' }) const service = { @@ -133,7 +134,8 @@ module.exports = { experimental_features_enabled: true, current_psp_test_account_stage: opts.current_psp_test_account_stage, agent_initiated_moto_enabled: opts.agent_initiated_moto_enabled, - takes_payments_over_phone: opts.takes_payments_over_phone + takes_payments_over_phone: opts.takes_payments_over_phone, + created_date: opts.created_date } if (opts.merchant_details) { From 6f3fe36df16f3ea6fb380e1e4013fd2bf8ea0762 Mon Sep 17 00:00:00 2001 From: James Peacock Date: Thu, 10 Oct 2024 13:32:57 +0100 Subject: [PATCH 2/2] PP-13174 Check that stripe test link does not exist for new services --- test/cypress/integration/dashboard/dashboard-links.cy.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/cypress/integration/dashboard/dashboard-links.cy.js b/test/cypress/integration/dashboard/dashboard-links.cy.js index 106ae676e7..73ed87aef4 100644 --- a/test/cypress/integration/dashboard/dashboard-links.cy.js +++ b/test/cypress/integration/dashboard/dashboard-links.cy.js @@ -81,6 +81,8 @@ describe('the links are displayed correctly on the dashboard', () => { cy.get('#request-to-go-live-link').should('exist') cy.get('#request-to-go-live-link').should('have.class', 'flex-grid--column-third') + cy.get('#request-stripe-test-account').should('not.exist') + }) it('should display 4 links for a test sandbox account created before 29/08/2024', () => {