Skip to content

Commit 5a57f8e

Browse files
Merge branch 'main' into Admin-Panel-Fixes
2 parents 34a47c4 + d4be741 commit 5a57f8e

8 files changed

Lines changed: 72 additions & 45 deletions

File tree

app/frontend/src/components/forms/manage/ExternalAPIs.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default {
2525
externalAPIStatusCodes: [],
2626
items: [],
2727
techdocsLink:
28-
'https://developer.gov.bc.ca/docs/default/component/chefs-techdocs/Capabilities/Integrations/Calling-External-API/',
28+
'https://developer.gov.bc.ca/docs/default/component/chefs-techdocs/Capabilities/Integrations/Getting-Live-Data-in-Your-Forms/',
2929
editDialog: {
3030
title: '',
3131
item: {

app/src/forms/form/service.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,8 @@ const service = {
563563

564564
_validateSortBy: (params, selection, fields) => {
565565
if (params.sortBy?.column && !selection.includes(params.sortBy.column) && !fields.includes(params.sortBy.column)) {
566-
throw new Problem(400, {
567-
details: `orderBy column '${params.sortBy.column}' not in selected columns`,
568-
});
566+
// don't throw an error, just remove the sortBy column, user can choose a different column
567+
delete params.sortBy;
569568
}
570569
},
571570

@@ -575,9 +574,9 @@ const service = {
575574

576575
// Determine if assignee data should be included in response
577576
const shouldIncludeAssignee = service._shouldIncludeAssignee(form);
578-
const query = service._initFormSubmissionsListQuery(formId, params, currentUser, shouldIncludeAssignee);
579577
const { selection, fields } = service._buildSelectionAndFields(params, shouldIncludeAssignee);
580578
service._validateSortBy(params, selection, fields);
579+
const query = service._initFormSubmissionsListQuery(formId, params, currentUser, shouldIncludeAssignee);
581580

582581
query.select(
583582
selection,

app/tests/unit/forms/form/service.spec.js

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -643,15 +643,14 @@ describe('listFormSubmissions', () => {
643643
MockModel.mockResolvedValue([]);
644644
});
645645

646-
describe('400 response when', () => {
646+
describe('should not error when sortBy column is not in select', () => {
647647
test('sort by column not in select', async () => {
648-
await expect(
649-
service.listFormSubmissions(formId, {
650-
sortBy: {
651-
column: 'x',
652-
},
653-
})
654-
).rejects.toThrow('400');
648+
await service.listFormSubmissions(formId, {
649+
sortBy: {
650+
column: 'x',
651+
},
652+
});
653+
expect(MockModel.select).toBeCalledTimes(1);
655654
});
656655
});
657656

@@ -1781,17 +1780,10 @@ describe('listFormSubmission helpers', () => {
17811780
const { fields } = service._buildSelectionAndFields(params, true);
17821781
expect(fields).toContain('lateEntry');
17831782
});
1784-
it('should throw 400 if sortBy column not in selection or fields', () => {
1783+
it('should remove sortBy if column not in selection or fields', () => {
17851784
const params = { sortBy: { column: 'notAColumn' } };
1786-
try {
1787-
service._validateSortBy(params, ['a'], ['b']);
1788-
// If no error is thrown, fail the test
1789-
throw new Error('Did not throw');
1790-
} catch (err) {
1791-
expect(err).toBeInstanceOf(require('api-problem'));
1792-
expect(err.status).toBe(400);
1793-
expect(err.details).toMatch(/orderBy column/);
1794-
}
1785+
service._validateSortBy(params, ['a'], ['b']);
1786+
expect(params.sortBy).toBeUndefined();
17951787
});
17961788
});
17971789

@@ -2226,21 +2218,27 @@ describe('Branch coverage for assignee and selection helpers', () => {
22262218
it('does not throw if sortBy.column is in selection', () => {
22272219
const params = { sortBy: { column: 'foo' } };
22282220
expect(() => service._validateSortBy(params, ['foo'], ['bar'])).not.toThrow();
2221+
expect(params.sortBy).toBeDefined();
22292222
});
22302223

22312224
it('does not throw if sortBy.column is in fields', () => {
22322225
const params = { sortBy: { column: 'bar' } };
22332226
expect(() => service._validateSortBy(params, ['foo'], ['bar'])).not.toThrow();
2227+
expect(params.sortBy).toBeDefined();
22342228
});
22352229

2236-
it('throws Problem 400 if sortBy.column is not in selection or fields', () => {
2230+
it('does not throw if sortBy.column is not in selection or fields, removes sortBy', () => {
22372231
const params = { sortBy: { column: 'baz' } };
2238-
expect(() => service._validateSortBy(params, ['foo'], ['bar'])).toThrow(expect.any(require('api-problem')));
2232+
expect(params.sortBy).toBeDefined();
2233+
expect(() => service._validateSortBy(params, ['foo'], ['bar'])).not.toThrow();
2234+
expect(params.sortBy).toBeUndefined();
22392235
});
22402236

2241-
it('does not throw if sortBy is missing', () => {
2237+
it('does not throw if sortBy is missing, removes sortBy', () => {
22422238
const params = {};
2239+
expect(params.sortBy).toBeUndefined();
22432240
expect(() => service._validateSortBy(params, ['foo'], ['bar'])).not.toThrow();
2241+
expect(params.sortBy).toBeUndefined();
22442242
});
22452243
});
22462244
});

tests/functional/cypress/e2e/form-design-advancedfield.cy.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ describe('Form Designer', () => {
257257
// for print option verification
258258
cy.get(':nth-child(2) > .d-print-none > :nth-child(1) > .v-btn').should('be.visible');
259259
cy.get('.mdi-printer').should('be.visible');
260-
cy.get('.ml-auto > :nth-child(3) > .v-btn').should('be.visible');
260+
//Wide form layout button
261+
cy.get(':nth-child(2) > .v-btn').should('be.visible');
261262
cy.waitForLoad();
262263
cy.waitForLoad();
263264
cy.get('input[type="radio"]').click();
@@ -284,11 +285,8 @@ describe('Form Designer', () => {
284285
//verify file uploads to object storage
285286
cy.get('.col-md-9 > a').should('have.attr', 'ref').and('include', 'fileLink');
286287
cy.get('div.col-md-2').contains('61.48 kB');
287-
cy.get('.ml-auto > :nth-child(3) > .v-btn').click();
288288
cy.waitForLoad();
289289
cy.wait(2000);
290-
//Close the upload warning message
291-
//cy.get('.v-alert__close > .v-btn').click();
292290
cy.wait(2000);
293291
//form submission
294292
cy.get('button').contains('Submit').click();
@@ -300,7 +298,6 @@ describe('Form Designer', () => {
300298
cy.get('.choices__inner > .choices__list > .choices__item').contains('hello');
301299
cy.get('.col-md-9 > a').contains('add1.png');
302300
cy.get('.ui > .choices__list > .choices__item').contains('THRIFTY FOODS');
303-
304301
//Delete form after test run
305302
cy.visit(`/${depEnv}/form/manage?f=${arrayValues[0]}`);
306303
cy.waitForLoad();

tests/functional/cypress/e2e/form-draft-submission-management.cy.js

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,15 @@ import { formsettings } from '../support/login.js';
33

44
const depEnv = Cypress.env('depEnv');
55

6-
76
Cypress.Commands.add('waitForLoad', () => {
87
const loaderTimeout = 60000;
98

109
cy.get('.nprogress-busy', { timeout: loaderTimeout }).should('not.exist');
1110
});
12-
13-
14-
1511
describe('Form Designer', () => {
1612

1713
beforeEach(()=>{
1814

19-
20-
2115
cy.on('uncaught:exception', (err, runnable) => {
2216
// Form.io throws an uncaught exception for missing projectid
2317
// Cypress catches it as undefined: undefined so we can't get the text
@@ -42,7 +36,7 @@ it('Verify draft submission', () => {
4236
cy.get('span.btn').contains('Text Field')
4337

4438
.trigger('mousedown', { which: 1}, { force: true })
45-
.trigger('mousemove', coords.x, -50, { force: true })
39+
.trigger('mousemove', coords.x, -110, { force: true })
4640
.trigger('mouseup', { force: true });
4741
cy.get('button').contains('Save').click();
4842
});
@@ -106,7 +100,7 @@ it('Verify draft submission', () => {
106100
cy.get('[data-test="save-btn"] > .v-btn__content').click();
107101
cy.get('.v-data-table__tr > :nth-child(4)').contains('DRAFT').should('not.exist');
108102
cy.get('.mdi-pencil').click();
109-
cy.get('.ml-auto > :nth-child(3) > .v-btn').click();
103+
cy.get(':nth-child(4) > .v-btn').click();
110104
cy.waitForLoad();
111105
cy.get('.v-alert__content > div').contains('Draft Saved');
112106
// Edit draft submission
@@ -125,16 +119,51 @@ it('Verify draft submission', () => {
125119
cy.location('pathname').should('eq', `/${depEnv}/form/success`);
126120
cy.contains('h1', 'Your form has been submitted successfully');
127121
cy.get('.mt-6 > :nth-child(1) > .v-btn > .v-btn__content > span').click();
128-
//cy.get('div > .bg-primary').click();
122+
//Verify status column removed
129123
cy.get('.v-data-table__tr > :nth-child(4)').contains('SUBMITTED').should('not.exist');
124+
//Verify multiple draft upload functionality
125+
cy.visit(`/${depEnv}/form/submit?f=${arrayValues[0]}`);
126+
cy.waitForLoad();
127+
cy.get('button').contains('Submit').should('be.visible');
128+
cy.waitForLoad();
129+
cy.waitForLoad();
130+
cy.get('button[title="Switch to multiple submissions"]').click();
131+
cy.get('h1').contains('Select JSON file to upload').click();
132+
let fileUploadInputField = cy.get('input[type=file]');
133+
cy.get('input[type=file]').should('not.to.be.null');
134+
fileUploadInputField.attachFile('test_schema.json');
135+
cy.get('.v-alert__content').contains('Wrong json file format').should('be.visible');
136+
cy.get('h1').contains('Select JSON file to upload').click();
137+
cy.get('input[type=file]').attachFile('test_submissions.json');
138+
cy.wait(1000);
139+
//Upload sucessful message
140+
cy.get('.v-alert__content').contains('Your multiple draft upload has been successful!').should('be.visible');
141+
cy.wait(1000);
142+
//Verify download template link
143+
cy.get('i[class="mdi-download mdi v-icon notranslate v-theme--chefsTheme v-icon--size-default mr-1"]').should('exist');
144+
//Verify Draft upload
145+
cy.contains('p',' Your multiple draft upload has been successful!').should('exist');
146+
cy.get('.mt-6 > :nth-child(1) > .v-btn > .v-btn__content > span').click();
147+
//Verify draft uploaded
148+
cy.get('button[title="Edit This Draft"]').then($el => {
149+
const rem=$el[0];
150+
cy.get(rem).click();
151+
})
152+
//Edit the uploaded draft
153+
cy.get('input[name="data[simpletextfield]"]').should('have.value', 'simple').should('exist');
154+
cy.contains('Text Field').type('{selectall}{backspace}');
155+
cy.contains("Text Field").type("Edit uploaded draft");
156+
//form submission
157+
cy.get("button").contains("Submit").click();
158+
cy.waitForLoad();
159+
cy.get('[data-test="continue-btn-continue"]').click({ force: true });
160+
cy.wait(2000);
130161
//Delete form after test run
131162
cy.visit(`/${depEnv}/form/manage?f=${arrayValues[0]}`);
132163
cy.waitForLoad();
133164
cy.get('.mdi-delete').click();
134165
cy.get('[data-test="continue-btn-continue"]').click();
135166
cy.get('#logoutButton > .v-btn__content > span').click();
136-
137-
138167
});
139168

140169
});

tests/functional/cypress/e2e/form-submission-assign-revise-status.cy.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ it('Submission revise status Assignment', () => {
9696
let arr = search.split('=');
9797
let arrayValues = arr[1].split('&');
9898
cy.log(arrayValues[0]);
99-
//Manage members for draft management
10099
cy.get('.mdi-pencil').click();
101-
cy.get('.ml-auto > :nth-child(3) > .v-btn').click();
100+
cy.get(':nth-child(4) > .v-btn').click();
102101
cy.waitForLoad();
103102
cy.get('.v-alert__content > div').contains('Draft Saved');
104-
cy.get(':nth-child(2) > :nth-child(4) > :nth-child(1) > .v-btn').click();
103+
//Manage members for draft management
104+
cy.get('.mdi-account-multiple').click();
105105
cy.get('form > .v-input > .v-input__control > .v-field > .v-field__field > .v-field__input').click();
106106
cy.get('.v-card-actions > .v-btn > .v-btn__content > span').click();
107107
cy.waitForLoad();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"simpletextfield":"simple","submit":false,"lateEntry":false},{"simpletextfield":"simple","submit":false,"lateEntry":false}]

tests/functional/cypress/support/login.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ export function formsettings(){
5454
});
5555
//validate share draft with team is not enabled
5656
cy.get('[data-test="enableTeamMemberDraftShare"]').should('not.be.enabled');
57+
//Save and edit draft
5758
cy.get('[data-test="canSaveAndEditDraftsCheckbox"]').click();
59+
//Upload draft
60+
cy.get('[data-test="canUploadDraftCheckbox"]').click();
5861
//validate share draft with team is enabled
5962
cy.get('[data-test="enableTeamMemberDraftShare"]').should('be.visible').and('not.be.disabled');
6063
cy.get('[data-test="canUpdateStatusOfFormCheckbox"]').click();//Update the status of the form

0 commit comments

Comments
 (0)