From 7f3522ba18c8c4b77e05a317aea9f7c713367e10 Mon Sep 17 00:00:00 2001 From: Walter Moar Date: Thu, 12 Oct 2023 14:07:40 -0700 Subject: [PATCH] feat: FORMS-882 add submissionId to exports (#1082) --- app/src/forms/form/exportService.js | 2 +- app/tests/unit/forms/form/exportService.spec.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/forms/form/exportService.js b/app/src/forms/form/exportService.js index a551ba8c2..849c572d0 100644 --- a/app/src/forms/form/exportService.js +++ b/app/src/forms/form/exportService.js @@ -200,7 +200,7 @@ const service = { _submissionsColumns: (form, params) => { // Custom columns not defined - return default column selection behavior - let columns = ['confirmationId', 'formName', 'version', 'createdAt', 'fullName', 'username', 'email']; + let columns = ['submissionId', 'confirmationId', 'formName', 'version', 'createdAt', 'fullName', 'username', 'email']; // if form has 'status updates' enabled in the form settings include these in export if (form.enableStatusUpdates) { columns = columns.concat(['status', 'assignee', 'assigneeEmail']); diff --git a/app/tests/unit/forms/form/exportService.spec.js b/app/tests/unit/forms/form/exportService.spec.js index 3e63ddc6a..9baccec10 100644 --- a/app/tests/unit/forms/form/exportService.spec.js +++ b/app/tests/unit/forms/form/exportService.spec.js @@ -459,7 +459,7 @@ describe('_submissionsColumns', () => { enableCopyExistingSubmission: false, }; - it('should return right number of columns, when no prefered columns passed as params.', async () => { + it('should return right columns, when no prefered columns passed as params.', async () => { const params = { type: 'submissions', format: 'json', @@ -469,7 +469,8 @@ describe('_submissionsColumns', () => { }; const submissions = exportService._submissionsColumns(form, params); - expect(submissions.length).toEqual(8); + expect(submissions.length).toEqual(9); + expect(submissions).toEqual(expect.arrayContaining(['submissionId', 'confirmationId', 'formName', 'version', 'createdAt', 'fullName', 'username', 'email', 'submission'])); }); it('should return right number of columns, when 1 prefered column (deleted) passed as params.', async () => { @@ -483,7 +484,7 @@ describe('_submissionsColumns', () => { }; const submissions = exportService._submissionsColumns(form, params); - expect(submissions.length).toEqual(9); + expect(submissions.length).toEqual(10); }); it('should return right number of columns, when 1 prefered column (draft) passed as params.', async () => { @@ -497,7 +498,7 @@ describe('_submissionsColumns', () => { }; const submissions = exportService._submissionsColumns(form, params); - expect(submissions.length).toEqual(9); + expect(submissions.length).toEqual(10); }); it('should return right number of columns, when 2 prefered column (draft & deleted) passed as params.', async () => { @@ -511,7 +512,8 @@ describe('_submissionsColumns', () => { }; const submissions = exportService._submissionsColumns(form, params); - expect(submissions.length).toEqual(10); + + expect(submissions.length).toEqual(11); }); it('should return right number of columns, when a garbage or NON-allowed column (testCol1 & testCol2) passed as params.', async () => { @@ -525,7 +527,7 @@ describe('_submissionsColumns', () => { }; const submissions = exportService._submissionsColumns(form, params); - expect(submissions.length).toEqual(8); + expect(submissions.length).toEqual(9); }); });