Skip to content

Commit

Permalink
Merge pull request #4284 from alphagov/PP-13174-Do-not-show-Test-Stri…
Browse files Browse the repository at this point in the history
…pe-link-for-new-services

PP-13174 Do not show test stripe link for new services
  • Loading branch information
james-peacock-gds authored Oct 10, 2024
2 parents 1f90124 + 6f3fe36 commit 9d78088
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
5 changes: 4 additions & 1 deletion app/controllers/dashboard/dashboard-activity.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down
29 changes: 24 additions & 5 deletions test/cypress/integration/dashboard/dashboard-links.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -66,8 +66,27 @@ 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')

cy.get('#request-stripe-test-account').should('not.exist')

})

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)
Expand Down Expand Up @@ -115,7 +134,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)
Expand Down
4 changes: 4 additions & 0 deletions test/cypress/stubs/user-stubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ function buildServiceRoleOpts (opts) {
serviceRole.role = opts.role
}

if (opts.createdDate) {
service.created_date = opts.createdDate
}

return serviceRole
}

Expand Down
6 changes: 4 additions & 2 deletions test/fixtures/service.fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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) {
Expand Down

0 comments on commit 9d78088

Please sign in to comment.