Skip to content

Commit

Permalink
Requested changes from PR.
Browse files Browse the repository at this point in the history
  • Loading branch information
nataliecarey committed Dec 20, 2024
1 parent c58ef8b commit e1b6eec
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 91 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { response } = require('@utils/response')
const formatSimplifiedAccountPathsFor = require('../../../../utils/simplified-account/format/format-simplified-account-paths-for')
const paths = require('../../../..//paths')
const formatSimplifiedAccountPathsFor = require('@utils/simplified-account/format/format-simplified-account-paths-for')
const paths = require('@root/paths')

const GB_COUNTRY_CODE = 'GB'

Expand Down
2 changes: 1 addition & 1 deletion app/simplified-account-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ simplifiedAccount.post(paths.simplifiedAccount.settings.organisationDetails.edit
simplifiedAccount.get(paths.simplifiedAccount.settings.cardTypes.index, permission('transactions:read'), serviceSettingsController.cardTypes.get)

// card payments
simplifiedAccount.get(paths.simplifiedAccount.settings.cardPayments.index, permission('payment-types:update'), serviceSettingsController.cardPayments.get)
simplifiedAccount.get(paths.simplifiedAccount.settings.cardPayments.index, permission('payment-types:read'), serviceSettingsController.cardPayments.get)

// worldpay details
simplifiedAccount.get(paths.simplifiedAccount.settings.worldpayDetails.index, permission('gateway-credentials:read'), serviceSettingsController.worldpayDetails.get)
Expand Down
12 changes: 3 additions & 9 deletions app/utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,8 @@ const logger = createLogger({
]
})

const nsDebugFormat = printf(({ level, message, timestamp, ...metadata }) => {
const metadataStr = Object.keys(metadata).length
? JSON.stringify(metadata, null, 2)
: ''

return metadataStr
? `${timestamp} [${level}]: ${message}\n${metadataStr}`
: `${timestamp} [${level}]: ${message}`
const nsDebugFormat = printf(({ level, message, timestamp }) => {
return `${timestamp} [${level}]: ${message}`
})

const nsDebugLogger = createLogger({
Expand All @@ -56,7 +50,7 @@ const nsDebugLogger = createLogger({
]
})

const nsDebug = process.env.NS_DEBUG === 'true'
const nsDebug = process.env.GOVUK_PAY__USE_BASIC_LOGGER === 'true'

module.exports = (loggerName) => {
if (process.env.GOVUK_PAY__USE_BASIC_LOGGER === 'true') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,29 @@ describe('Card payments page', () => {
serviceName: 'version 1'
})
cy.visit(pageUrl)
assertSummaryListsEqual([
[
{
key: 'Collect billing address',
value: 'On'
},
{
key: 'Default billing address country',
value: 'United Kingdom'
}
],
[

{
key: 'Apple Pay',
value: 'On'
},
{
key: 'Google Pay',
value: 'On'
}
]
])
cy.get('.govuk-summary-list').eq(0).within(() => {
cy.get('.govuk-summary-list__row').eq(0).within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Collect billing address')
cy.get('.govuk-summary-list__value').should('contain', 'On')
})
cy.get('.govuk-summary-list__row').eq(1).within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Default billing address country')
cy.get('.govuk-summary-list__value').should('contain', 'United Kingdom')
})
})
cy.get('.govuk-summary-list').eq(1).within(() => {
cy.get('.govuk-summary-list__row').eq(0).within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Apple Pay')
cy.get('.govuk-summary-list__value').should('contain', 'On')
})
cy.get('.govuk-summary-list__row').eq(1).within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Google Pay')
cy.get('.govuk-summary-list__value').should('contain', 'On')
})
})
})

it('should display the provided card payment details (version 2 -everything off)', () => {
it('should display the provided card payment details (version 2 - everything off)', () => {
setupStubs({
collectBillingAddress: false,
defaultBillingAddressCountry: 'IE',
Expand All @@ -96,62 +93,27 @@ describe('Card payments page', () => {
})

cy.visit(pageUrl)
assertSummaryListsEqual([
[
{
key: 'Collect billing address',
value: 'Off'
},
{
key: 'Default billing address country',
value: 'IE'
}
],
[

{
key: 'Apple Pay',
value: 'Off'
},
{
key: 'Google Pay',
value: 'Off'
}
]
])
})
})

// describe('for a non-admin user', () => {
// beforeEach(() => {
// setupStubs({
// role: 'view-and-refund'
// })
// })
//
// it('should return a 403', () => {
// cy.request({
// url: pageUrl,
// failOnStatusCode: false
// }).then(response => expect(response.status).to.eq(403))
// })
// })
})
})

function assertSummaryListsEqual (expectation) {
expectation.forEach((currentSummaryListExpectations, summaryListIndex) => {
currentSummaryListExpectations.forEach((currentRowExpectations, currentRowIndex) => {
const currentRowExpectationsKeys = Object.keys(currentRowExpectations)
if (!currentRowExpectationsKeys.includes('key') || !currentRowExpectationsKeys.includes('value') || currentRowExpectationsKeys.lenght > 2) {
throw new Error(`Row expectations *must* (currently) be "key" and "value". [${currentRowExpectationsKeys.join(', ')}] provided`)
}
cy.get('.govuk-summary-list').eq(summaryListIndex).within(() => {
cy.get('.govuk-summary-list__row').eq(currentRowIndex).within(() => {
cy.get('.govuk-summary-list__key').should('contain', currentRowExpectations.key)
cy.get('.govuk-summary-list__value').should('contain', currentRowExpectations.value)
cy.get('.govuk-summary-list').eq(0).within(() => {
cy.get('.govuk-summary-list__row').eq(0).within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Collect billing address')
cy.get('.govuk-summary-list__value').should('contain', 'Off')
})
cy.get('.govuk-summary-list__row').eq(1).within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Default billing address country')
cy.get('.govuk-summary-list__value').should('contain', 'IE')
})
})
cy.get('.govuk-summary-list').eq(1).within(() => {
cy.get('.govuk-summary-list__row').eq(0).within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Apple Pay')
cy.get('.govuk-summary-list__value').should('contain', 'Off')
})
cy.get('.govuk-summary-list__row').eq(1).within(() => {
cy.get('.govuk-summary-list__key').should('contain', 'Google Pay')
cy.get('.govuk-summary-list__value').should('contain', 'Off')
})
})
})
})
})
}
})

0 comments on commit e1b6eec

Please sign in to comment.