diff --git a/src/server/plugins/engine/models/FormModel.test.ts b/src/server/plugins/engine/models/FormModel.test.ts index cd77cfcec..80bfe8ea4 100644 --- a/src/server/plugins/engine/models/FormModel.test.ts +++ b/src/server/plugins/engine/models/FormModel.test.ts @@ -200,7 +200,7 @@ describe('FormModel', () => { }) describe('getFormContext', () => { - it.each([FormAction.Validate, FormAction.SaveAndExit, undefined])( + it.each([FormAction.Validate, undefined])( 'returns a form context with the correct payload and state when action is %s', (action) => { const formModel = new FormModel(fieldsRequiredDefinition, { diff --git a/src/server/plugins/engine/models/FormModel.ts b/src/server/plugins/engine/models/FormModel.ts index 42cfcad80..db3c12668 100644 --- a/src/server/plugins/engine/models/FormModel.ts +++ b/src/server/plugins/engine/models/FormModel.ts @@ -561,7 +561,7 @@ function validateFormPayload( if ( !request.payload || (action && - ![FormAction.Validate, FormAction.SaveAndExit].includes(action) && + action !== FormAction.Validate && !action.startsWith(FormAction.External)) ) { return context diff --git a/test/form/save-and-exit.test.js b/test/form/save-and-exit.test.js index d527249e1..560db299a 100644 --- a/test/form/save-and-exit.test.js +++ b/test/form/save-and-exit.test.js @@ -113,7 +113,7 @@ describe('Save and Exit functionality', () => { expect(response.statusCode).toBe(StatusCodes.SEE_OTHER) }) - it('should prevent invalid form state being persisted', async () => { + it('should allow invalid form state for current page', async () => { const payload = { licenceLength: '', action: 'save-and-exit', @@ -127,7 +127,7 @@ describe('Save and Exit functionality', () => { payload }) - expect(response.statusCode).not.toBe(StatusCodes.MOVED_TEMPORARILY) // we shouldn't be redirected to the next question + expect(response.statusCode).not.toBe(StatusCodes.SEE_OTHER) }) it('should return 404 for non-existent page', async () => {