From fcf8c6747f5841bdb38214b7be2300f637fdc47b Mon Sep 17 00:00:00 2001 From: John Shields Date: Wed, 18 Oct 2023 17:23:58 +0100 Subject: [PATCH 1/4] PP-9916 Change test card number in Stripe test accounts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update ‘Mock card numbers’ template to test for ‘stripe’ account and display UK issued test card. --- app/views/dashboard/demo-payment/mock-card-details.njk | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/views/dashboard/demo-payment/mock-card-details.njk b/app/views/dashboard/demo-payment/mock-card-details.njk index 55436aeace..b4ba992f48 100644 --- a/app/views/dashboard/demo-payment/mock-card-details.njk +++ b/app/views/dashboard/demo-payment/mock-card-details.njk @@ -1,5 +1,13 @@ {% extends "../../layout.njk" %} +{% set card %} +{% if currentGatewayAccount.payment_provider === 'stripe' %} +

4000058260000005

+{% else %} +

4000056655665556

+{% endif %} +{% endset %} + {% block pageTitle %} Mock card numbers for demo payment - {{currentService.name}} {{currentGatewayAccount.full_type}} - GOV.UK Pay {% endblock %} @@ -21,7 +29,7 @@ {{ govukInsetText({ - html: '

4000056655665556

' + html: card }) }} From 5a6a9ed72aebe127177bc5746c216d5503f7b3cc Mon Sep 17 00:00:00 2001 From: John Shields Date: Thu, 19 Oct 2023 15:38:16 +0100 Subject: [PATCH 2/4] PP-9916 Change test card number in Stripe test accounts Update '.secrets.baseline' to include credentials for new cypress 'Pay demo/Mock cards' test. --- .secrets.baseline | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 6846d7666f..b0223ed87b 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -75,10 +75,6 @@ { "path": "detect_secrets.filters.allowlist.is_line_allowlisted" }, - { - "path": "detect_secrets.filters.common.is_baseline_file", - "filename": ".secrets.baseline" - }, { "path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies", "min_level": 2 @@ -384,6 +380,15 @@ "line_number": 5 } ], + "test/cypress/integration/demo-payment/mock-cards.cy.js": [ + { + "type": "Hex High Entropy String", + "filename": "test/cypress/integration/demo-payment/mock-cards.cy.js", + "hashed_secret": "7bb363901b8a686a4d3e1949032e469901cddaa8", + "is_verified": false, + "line_number": 5 + } + ], "test/cypress/integration/index/index.cy.js": [ { "type": "Hex High Entropy String", @@ -894,5 +899,5 @@ } ] }, - "generated_at": "2023-08-17T11:37:31Z" + "generated_at": "2023-10-19T14:35:18Z" } From fc2ef7ff58b88a635f23ca0513abcdf7d3f8c6a9 Mon Sep 17 00:00:00 2001 From: John Shields Date: Thu, 19 Oct 2023 15:43:18 +0100 Subject: [PATCH 3/4] PP-9916 Change test card number in Stripe test accounts Add Cypresss test to check 'Mock card' screen shows correct card number for non Stripe accounts. --- .../integration/demo-payment/mock-cards.cy.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/cypress/integration/demo-payment/mock-cards.cy.js diff --git a/test/cypress/integration/demo-payment/mock-cards.cy.js b/test/cypress/integration/demo-payment/mock-cards.cy.js new file mode 100644 index 0000000000..61886528bb --- /dev/null +++ b/test/cypress/integration/demo-payment/mock-cards.cy.js @@ -0,0 +1,36 @@ +const userStubs = require('../../stubs/user-stubs') +const gatewayAccountStubs = require('../../stubs/gateway-account-stubs') +const transactionStubs = require('../../stubs/transaction-stubs') + +const userExternalId = 'cd0fa54cf3b7408a80ae2f1b93e7c16e' +const gatewayAccountId = '42' +const gatewayAccountExternalId = 'a-valid-external-id' + +describe('Show Mock cards screen', () => { + beforeEach(() => { + cy.task('setupStubs', [ + userStubs.getUserSuccess({ gatewayAccountId, userExternalId }), + gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ + gatewayAccountId, + gatewayAccountExternalId, + paymentProvider: 'sandbox' + }), + transactionStubs.getTransactionsSummarySuccess() + ]) + }) + + it('should load the mock cards page and show non stripe card', () => { + cy.setEncryptedCookies(userExternalId) + cy.visit(`/account/${gatewayAccountExternalId}/dashboard`) + cy.get('a').contains('Make a demo payment').click() + cy.get('h1').should('have.text', 'Make a demo payment') + + cy.get('#payment-description').contains('An example payment description') + cy.get('#payment-amount').contains('£20.00') + + cy.log('Continue to Mock Cards page') + cy.get('a').contains('Continue').click() + cy.get('h1').should('have.text', 'Mock card numbers') + cy.get('p').contains(/^4000056655665556/) + }) +}) From 40484518b08231585700bb2ec719b01730095389 Mon Sep 17 00:00:00 2001 From: John Shields Date: Thu, 19 Oct 2023 19:51:29 +0100 Subject: [PATCH 4/4] PP-9916 Change test card number in Stripe test accounts Add Cypresss test to check 'Mock card' screen shows correct card number for Stripe accounts. --- .../demo-payment/mock-cards-stripe.cy.js | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/cypress/integration/demo-payment/mock-cards-stripe.cy.js diff --git a/test/cypress/integration/demo-payment/mock-cards-stripe.cy.js b/test/cypress/integration/demo-payment/mock-cards-stripe.cy.js new file mode 100644 index 0000000000..e6984ce97c --- /dev/null +++ b/test/cypress/integration/demo-payment/mock-cards-stripe.cy.js @@ -0,0 +1,49 @@ +'use strict' + +const userStubs = require('../../stubs/user-stubs') +const gatewayAccountStubs = require('../../stubs/gateway-account-stubs') +const stripeAccountSetupStubs = require('../../stubs/stripe-account-setup-stub') +const userExternalId = 'cd0fa54cf3b7408a80ae2f1b93e7c16e' // pragma: allowlist secret +const gatewayAccountId = '42' +const gatewayAccountExternalId = 'a-valid-external-id' + +function setupYourPspStubs (opts = {}) { + const user = userStubs.getUserSuccess({ userExternalId, gatewayAccountId }) + + const gatewayAccountByExternalId = gatewayAccountStubs.getGatewayAccountByExternalIdSuccess({ + gatewayAccountId, + gatewayAccountExternalId, + type: 'test', + paymentProvider: 'stripe', + }) + + const stripeAccountSetup = stripeAccountSetupStubs.getGatewayAccountStripeSetupSuccess({ + gatewayAccountId, + }) + + const stubs = [ + user, + gatewayAccountByExternalId, + stripeAccountSetup, + ] + + cy.task('setupStubs', stubs) +} + +describe('Show Mock cards screen for stripe accounts', () => { + beforeEach(() => { + cy.setEncryptedCookies(userExternalId) + }) + + it('should display stripe settings page correctly', () => { + setupYourPspStubs() + cy.visit(`/account/${gatewayAccountExternalId}/settings`) + cy.log('Continue to Make a demo payment page via Dashboard') + cy.get('a').contains('Dashboard').click() + cy.get('a').contains('Make a demo payment').click() + cy.log('Continue to Mock Cards page') + cy.get('a').contains('Continue').click() + cy.get('h1').should('have.text', 'Mock card numbers') + cy.get('p').contains(/^4000058260000005/) + }) +})