Skip to content

Commit

Permalink
Merge pull request #4158 from alphagov/PP-11701-remove-wallet-env-vars
Browse files Browse the repository at this point in the history
PP-11701 Remove wallets feature flag
  • Loading branch information
stephencdaly authored Nov 27, 2023
2 parents 9008d26 + 2570a4c commit 2f5a335
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 73 deletions.
10 changes: 7 additions & 3 deletions app/utils/display-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ const hideServiceNavTemplates = [
'two-factor-auth/resend-sms-code'
]

const digitalWalletsSupportedProviders = [
'sandbox',
'stripe',
'worldpay'
]

/**
* converts users permission array of form
*
Expand Down Expand Up @@ -121,9 +127,7 @@ module.exports = function (req, data, template) {
convertedData.currentGatewayAccount = getAccount(account)
convertedData.isTestGateway = _.get(convertedData, 'currentGatewayAccount.type') === 'test'
convertedData.isSandbox = paymentProvider === 'sandbox'
convertedData.isDigitalWalletSupported = paymentProvider === 'worldpay' ||
(paymentProvider === 'sandbox' && process.env.ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT === 'true') ||
paymentProvider === 'stripe'
convertedData.isDigitalWalletSupported = digitalWalletsSupportedProviders.includes(paymentProvider)
convertedData.currentService = service
convertedData.isLive = req.isLive
convertedData.humanReadableEnvironment = convertedData.isLive ? 'Live' : 'Test'
Expand Down
25 changes: 4 additions & 21 deletions app/utils/display-converter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ var displayConverter = require('./display-converter')
const expect = chai.expect

describe('Display converter', function () {
afterEach(() => {
process.env.ALLOW_ENABLING_DIGITAL_WALLETS_FOR_STRIPE_ACCOUNT = undefined
process.env.ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT = undefined
})

it('should add full_type to account if type is test', function () {
let data = displayConverter({
account: {
Expand Down Expand Up @@ -89,35 +84,23 @@ describe('Display converter', function () {
expect(data.isDigitalWalletSupported).to.equal(true)
})

it('should return isDigitalWalletSupported=false for sandbox account when ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT is not set', () => {
it('should return isDigitalWalletSupported=true for sandbox accounts', () => {
const data = displayConverter({
account: {
type: 'test',
payment_provider: 'sandbox'
}
}, {}, {})
expect(data.isDigitalWalletSupported).to.equal(false)
expect(data.isDigitalWalletSupported).to.equal(true)
})

it('should return isDigitalWalletSupported=false for sandbox account when ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT is false', () => {
process.env.ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT = 'false'
it('should return isDigitalWalletSupported=false for unsupported provider', () => {
const data = displayConverter({
account: {
type: 'test',
payment_provider: 'sandbox'
payment_provider: 'epdq'
}
}, {}, {})
expect(data.isDigitalWalletSupported).to.equal(false)
})

it('should return isDigitalWalletSupported=true for sandbox account when ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT is true', () => {
process.env.ALLOW_ENABLING_DIGITAL_WALLETS_FOR_SANDBOX_ACCOUNT = 'true'
const data = displayConverter({
account: {
type: 'test',
payment_provider: 'sandbox'
}
}, {}, {})
expect(data.isDigitalWalletSupported).to.equal(true)
})
})
3 changes: 3 additions & 0 deletions app/views/settings/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
{{
govukSummaryList({
classes: 'pay-!-border-top pay-!-padding-top-2-small',
attributes: {'data-cy': 'billing-address-settings'},
rows: [
{
key: {
Expand Down Expand Up @@ -149,6 +150,7 @@
{{
govukSummaryList({
classes: 'pay-!-border-top pay-!-padding-top-2-small',
attributes: {'data-cy': 'email-notification-settings'},
rows: [
{
key: {
Expand Down Expand Up @@ -225,6 +227,7 @@
{{
govukSummaryList({
classes: 'pay-!-border-top pay-!-padding-top-2-small',
attributes: {'data-cy': 'moto-security-settings'},
rows: [
{
key: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ describe('Default billing address country', () => {

cy.visit(`/account/${gatewayAccountExternalId}/settings`)

cy.get('.govuk-summary-list__key').eq(1).should('contain', 'Default billing address country')
cy.get('.govuk-summary-list__value').eq(1).should('contain', 'None')

cy.get('.govuk-summary-list__actions').eq(1).contains('Change').click()
cy.get('[data-cy=billing-address-settings]').within(() => {
cy.get('.govuk-summary-list__key').eq(1).should('contain', 'Default billing address country')
cy.get('.govuk-summary-list__value').eq(1).should('contain', 'None')
cy.get('.govuk-summary-list__actions').eq(1).contains('Change').click()
})

cy.get('input[type="radio"]').should('have.length', 2)
cy.get('input[value="on"]').should('not.be.checked')
Expand Down Expand Up @@ -84,7 +85,8 @@ describe('Default billing address country', () => {
])

cy.visit(`/account/${gatewayAccountExternalId}/settings`)
cy.get('.govuk-summary-list__actions').eq(1).contains('View').click()

cy.get('[data-cy=billing-address-settings]').contains('View').click()
cy.get('.pay-info-warning-box').contains('You don’t have permission')
cy.get('input[value="on"]').should('be.disabled')
cy.get('input[value="off"]').should('be.disabled')
Expand Down
68 changes: 41 additions & 27 deletions test/cypress/integration/settings/email-notifications.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ describe('Settings', () => {

describe('Settings default page', () => {
it(`should have the page title 'Settings - ${serviceName} - GOV.UK Pay'`, () => {
cy.get('.govuk-summary-list__key').eq(2).should('contain', 'Enter an email address')
cy.get('.govuk-summary-list__value').eq(2).should('contain', 'On (mandatory)')
cy.get('.govuk-summary-list__actions a').eq(2).contains('Change enter an email address settings')
cy.get('.govuk-summary-list__key').eq(3).should('contain', 'Payment confirmation emails')
cy.get('.govuk-summary-list__value').eq(3).should('contain', 'On')
cy.get('.govuk-summary-list__actions a').eq(3).contains('Change payment confirmation emails settings')
cy.get('.govuk-summary-list__key').eq(4).should('contain', 'Refund emails')
cy.get('.govuk-summary-list__value').eq(4).should('contain', 'On')
cy.get('.govuk-summary-list__actions a').eq(4).contains('Change refund emails settings')
cy.get('[data-cy=email-notification-settings]').within(() => {
cy.get('.govuk-summary-list__key').eq(0).should('contain', 'Enter an email address')
cy.get('.govuk-summary-list__value').eq(0).should('contain', 'On (mandatory)')
cy.get('.govuk-summary-list__actions a').eq(0).contains('Change enter an email address settings')
cy.get('.govuk-summary-list__key').eq(1).should('contain', 'Payment confirmation emails')
cy.get('.govuk-summary-list__value').eq(1).should('contain', 'On')
cy.get('.govuk-summary-list__actions a').eq(1).contains('Change payment confirmation emails settings')
cy.get('.govuk-summary-list__key').eq(2).should('contain', 'Refund emails')
cy.get('.govuk-summary-list__value').eq(2).should('contain', 'On')
cy.get('.govuk-summary-list__actions a').eq(2).contains('Change refund emails settings')
})
})
})

Expand All @@ -57,9 +59,11 @@ describe('Settings', () => {
describe('Email collection mode page', () => {
it(`should have the page title 'Email notifications - ${serviceName} Sandbox test - GOV.UK Pay'`, () => {
// Access the collection mode page
cy.get('.govuk-summary-list__key').eq(2).should('contain', 'Enter an email address')
cy.get('.govuk-summary-list__value').eq(2).should('contain', 'On (mandatory)')
cy.get('.email-notifications-toggle-collection').contains('Change enter an email address settings').click()
cy.get('[data-cy=email-notification-settings]').within(() => {
cy.get('.govuk-summary-list__key').eq(0).should('contain', 'Enter an email address')
cy.get('.govuk-summary-list__value').eq(0).should('contain', 'On (mandatory)')
cy.get('.email-notifications-toggle-collection').contains('Change enter an email address settings').click()
})
cy.title().should('eq', `Email notifications - ${serviceName} Sandbox test - GOV.UK Pay`)
cy.url().should('include', '/email-settings-collection')

Expand All @@ -81,9 +85,11 @@ describe('Settings', () => {
describe('Confirmation email toggle page', () => {
it(`should have the page title 'Email notifications - ${serviceName} Sandbox test - GOV.UK Pay'`, () => {
// Access the confirmation toggle page
cy.get('.govuk-summary-list__key').eq(3).should('contain', 'Payment confirmation emails')
cy.get('.govuk-summary-list__value').eq(3).should('contain', 'On')
cy.get('.email-notifications-toggle-confirmation').contains('Change payment confirmation emails settings').click()
cy.get('[data-cy=email-notification-settings]').within(() => {
cy.get('.govuk-summary-list__key').eq(1).should('contain', 'Payment confirmation emails')
cy.get('.govuk-summary-list__value').eq(1).should('contain', 'On')
cy.get('.email-notifications-toggle-confirmation').contains('Change payment confirmation emails settings').click()
})
cy.title().should('eq', `Email notifications - ${serviceName} Sandbox test - GOV.UK Pay`)

cy.get('.govuk-fieldset__heading').first().should('contain', 'Do you want to send payment confirmation emails?')
Expand All @@ -103,9 +109,11 @@ describe('Settings', () => {
describe('Refund email toggle page', () => {
it(`should have the page title 'Email notifications - ${serviceName} Sandbox test - GOV.UK Pay'`, () => {
// Access the refund toggle page
cy.get('.govuk-summary-list__key').eq(4).should('contain', 'Refund emails')
cy.get('.govuk-summary-list__value').eq(4).should('contain', 'On')
cy.get('.email-notifications-toggle-refund').contains('Change refund emails settings').click()
cy.get('[data-cy=email-notification-settings]').within(() => {
cy.get('.govuk-summary-list__key').eq(2).should('contain', 'Refund emails')
cy.get('.govuk-summary-list__value').eq(2).should('contain', 'On')
cy.get('.email-notifications-toggle-refund').contains('Change refund emails settings').click()
})
cy.title().should('eq', `Email notifications - ${serviceName} Sandbox test - GOV.UK Pay`)

cy.get('.govuk-fieldset__heading').first().should('contain', 'Do you want to send refund emails?')
Expand Down Expand Up @@ -160,9 +168,11 @@ describe('Settings', () => {
describe('Email collection mode page', () => {
it(`should have the page title 'Email notifications - ${serviceName} Sandbox test - GOV.UK Pay'`, () => {
// Access the collection mode page
cy.get('.govuk-summary-list__key').eq(2).should('contain', 'Enter an email address')
cy.get('.govuk-summary-list__value').eq(2).should('contain', 'On (mandatory)')
cy.get('.email-notifications-toggle-collection').contains('View enter an email address settings').click()
cy.get('[data-cy=email-notification-settings]').within(() => {
cy.get('.govuk-summary-list__key').eq(0).should('contain', 'Enter an email address')
cy.get('.govuk-summary-list__value').eq(0).should('contain', 'On (mandatory)')
cy.get('.email-notifications-toggle-collection').contains('View enter an email address settings').click()
})
cy.title().should('eq', `Email notifications - ${serviceName} Sandbox test - GOV.UK Pay`)
cy.url().should('include', '/email-settings-collection')

Expand All @@ -179,9 +189,11 @@ describe('Settings', () => {
describe('Confirmation email toggle page', () => {
it(`should have the page title 'Email notifications - ${serviceName} Sandbox test - GOV.UK Pay'`, () => {
// Access the confirmation toggle page
cy.get('.govuk-summary-list__key').eq(3).should('contain', 'Payment confirmation emails')
cy.get('.govuk-summary-list__value').eq(3).should('contain', 'On')
cy.get('.email-notifications-toggle-confirmation').contains('View payment confirmation emails settings').click()
cy.get('[data-cy=email-notification-settings]').within(() => {
cy.get('.govuk-summary-list__key').eq(1).should('contain', 'Payment confirmation emails')
cy.get('.govuk-summary-list__value').eq(1).should('contain', 'On')
cy.get('.email-notifications-toggle-confirmation').contains('View payment confirmation emails settings').click()
})
cy.title().should('eq', `Email notifications - ${serviceName} Sandbox test - GOV.UK Pay`)

cy.get('.govuk-fieldset__heading').first().should('contain', 'Do you want to send payment confirmation emails?')
Expand All @@ -197,9 +209,11 @@ describe('Settings', () => {
describe('Refund email toggle page', () => {
it(`should have the page title 'Email notifications - ${serviceName} Sandbox test - GOV.UK Pay'`, () => {
// Access the refund toggle page
cy.get('.govuk-summary-list__key').eq(4).should('contain', 'Refund emails')
cy.get('.govuk-summary-list__value').eq(4).should('contain', 'On')
cy.get('.email-notifications-toggle-refund').contains('View refund emails settings').click()
cy.get('[data-cy=email-notification-settings]').within(() => {
cy.get('.govuk-summary-list__key').eq(2).should('contain', 'Refund emails')
cy.get('.govuk-summary-list__value').eq(2).should('contain', 'On')
cy.get('.email-notifications-toggle-refund').contains('View refund emails settings').click()
})
cy.title().should('eq', `Email notifications - ${serviceName} Sandbox test - GOV.UK Pay`)

cy.get('.govuk-fieldset__heading').first().should('contain', 'Do you want to send refund emails?')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ describe('MOTO mask security section', () => {
setupMotoStubs({ readonly: true, allowMoto: true, motoMaskCardNumber: false })

cy.visit(`/account/${gatewayAccountExternalId}/settings`)
cy.get('.govuk-summary-list__key').eq(5).should('contain', 'Hide card numbers')
cy.get('.govuk-summary-list__value').eq(5).should('contain', 'Off')
cy.get('.govuk-summary-list__actions a').eq(5).contains('View')
cy.get('.govuk-summary-list__actions a').eq(5).click()
cy.get('[data-cy=moto-security-settings]').within(() => {
cy.get('.govuk-summary-list__key').eq(0).should('contain', 'Hide card numbers')
cy.get('.govuk-summary-list__value').eq(0).should('contain', 'Off')
cy.get('.govuk-summary-list__actions a').eq(0).contains('View')
cy.get('.govuk-summary-list__actions a').eq(0).click()
})
cy.title().should('eq', `MOTO - hide card numbers for ${serviceName} - GOV.UK Pay`)
cy.get('.pay-info-warning-box').should('exist')
cy.get('input[value="on"]').should('be.disabled')
Expand All @@ -91,10 +93,12 @@ describe('MOTO mask security section', () => {
setupMotoStubs({ readonly: false, allowMoto: true, motoMaskCardNumber: false })

cy.visit(`/account/${gatewayAccountExternalId}/settings`)
cy.get('.govuk-summary-list__key').eq(5).should('contain', 'Hide card numbers')
cy.get('.govuk-summary-list__value').eq(5).should('contain', 'Off')
cy.get('.govuk-summary-list__actions a').eq(5).contains('Change')
cy.get('.govuk-summary-list__actions a').eq(5).click()
cy.get('[data-cy=moto-security-settings]').within(() => {
cy.get('.govuk-summary-list__key').eq(0).should('contain', 'Hide card numbers')
cy.get('.govuk-summary-list__value').eq(0).should('contain', 'Off')
cy.get('.govuk-summary-list__actions a').eq(0).contains('Change')
cy.get('.govuk-summary-list__actions a').eq(0).click()
})
cy.title().should('eq', `MOTO - hide card numbers for ${serviceName} - GOV.UK Pay`)
cy.get('input[value="on"]').should('not.be.disabled')
cy.get('input[value="off"]').should('not.be.disabled')
Expand All @@ -115,10 +119,12 @@ describe('MOTO mask security section', () => {
setupMotoStubs({ readonly: true, allowMoto: true, motoMaskSecurityCode: false })

cy.visit(`/account/${gatewayAccountExternalId}/settings`)
cy.get('.govuk-summary-list__key').eq(6).should('contain', 'Hide card security codes')
cy.get('.govuk-summary-list__value').eq(6).should('contain', 'Off')
cy.get('.govuk-summary-list__actions a').eq(6).contains('View')
cy.get('.govuk-summary-list__actions a').eq(6).click()
cy.get('[data-cy=moto-security-settings]').within(() => {
cy.get('.govuk-summary-list__key').eq(1).should('contain', 'Hide card security codes')
cy.get('.govuk-summary-list__value').eq(1).should('contain', 'Off')
cy.get('.govuk-summary-list__actions a').eq(1).contains('View')
cy.get('.govuk-summary-list__actions a').eq(1).click()
})
cy.title().should('eq', `MOTO - hide security codes for ${serviceName} - GOV.UK Pay`)
cy.get('.pay-info-warning-box').should('exist')
cy.get('input[value="on"]').should('be.disabled')
Expand All @@ -133,10 +139,12 @@ describe('MOTO mask security section', () => {
setupMotoStubs({ readonly: false, allowMoto: true, motoMaskSecurityCode: false })

cy.visit(`/account/${gatewayAccountExternalId}/settings`)
cy.get('.govuk-summary-list__key').eq(6).should('contain', 'Hide card security codes')
cy.get('.govuk-summary-list__value').eq(6).should('contain', 'Off')
cy.get('.govuk-summary-list__actions a').eq(6).contains('Change')
cy.get('.govuk-summary-list__actions a').eq(6).click()
cy.get('[data-cy=moto-security-settings]').within(() => {
cy.get('.govuk-summary-list__key').eq(1).should('contain', 'Hide card security codes')
cy.get('.govuk-summary-list__value').eq(1).should('contain', 'Off')
cy.get('.govuk-summary-list__actions a').eq(1).contains('Change')
cy.get('.govuk-summary-list__actions a').eq(1).click()
})
cy.title().should('eq', `MOTO - hide security codes for ${serviceName} - GOV.UK Pay`)
cy.get('input[value="on"]').should('not.be.disabled')
cy.get('input[value="off"]').should('not.be.disabled')
Expand Down
1 change: 0 additions & 1 deletion test/cypress/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ GOCARDLESS_TEST_OAUTH_BASE_URL=http://127.0.0.1:8000
GOCARDLESS_TEST_CLIENT_ID=testClientId
PAYOUTS_RELEASE_DATE=1590148800
ENABLE_STRIPE_ONBOARDING_TASK_LIST=true
ALLOW_ENABLING_DIGITAL_WALLETS_FOR_STRIPE_ACCOUNT=true

0 comments on commit 2f5a335

Please sign in to comment.