diff --git a/controllers/formController.js b/controllers/formController.js index 3d73919..e606184 100644 --- a/controllers/formController.js +++ b/controllers/formController.js @@ -6,7 +6,7 @@ exports.createForm = async (req, res) => { const session = await mongoose.startSession(); session.startTransaction(); try { - const { formData } = req.body; + const formData = req.body; console.log('Received form data:', formData); const newForm = new FormData(formData); // Assuming formData should not be nested under 'formData' diff --git a/test/form.test.js b/test/form.test.js index 40f7203..bab2cf0 100644 --- a/test/form.test.js +++ b/test/form.test.js @@ -20,19 +20,31 @@ before(async () => { describe('Form CRUD Operations', function () { const testFormId = 1; + // const formData = { + // formData: { + // jobName: "Initial Job", + // customerName: "Initial Customer", + // materialID: ["001", "002"], + // materialName: ["Paper", "Plastic"], + // printType: "Digital", + // printCustomerName: false, + // printCustomText: false, + // customText: "", + // designNotes: "Initial notes", + // formId: testFormId + // } + // }; const formData = { - formData: { - jobName: "Initial Job", - customerName: "Initial Customer", - materialID: ["001", "002"], - materialName: ["Paper", "Plastic"], - printType: "Digital", - printCustomerName: false, - printCustomText: false, - customText: "", - designNotes: "Initial notes", - formId: testFormId - } + jobName: "Initial Job", + customerName: "Initial Customer", + materialID: ["001", "002"], + materialName: ["Paper", "Plastic"], + printType: "Digital", + printCustomerName: false, + printCustomText: false, + customText: "", + designNotes: "Initial notes", + formId: testFormId }; before(async function () { @@ -92,19 +104,31 @@ describe('Form CRUD Operations', function () { }); it('should return an array of forms if multiple forms are found', async function () { + // const formData2 = { + // formData: { + // jobName: "Second Job", + // customerName: "Second Customer", + // materialID: ["003", "004"], + // materialName: ["Metal", "Wood"], + // printType: "Offset", + // printCustomerName: true, + // printCustomText: true, + // customText: "Custom Text", + // designNotes: "Second notes", + // formId: 2 + // } + // }; const formData2 = { - formData: { - jobName: "Second Job", - customerName: "Second Customer", - materialID: ["003", "004"], - materialName: ["Metal", "Wood"], - printType: "Offset", - printCustomerName: true, - printCustomText: true, - customText: "Custom Text", - designNotes: "Second notes", - formId: 2 - } + jobName: "Second Job", + customerName: "Second Customer", + materialID: ["003", "004"], + materialName: ["Metal", "Wood"], + printType: "Offset", + printCustomerName: true, + printCustomText: true, + customText: "Custom Text", + designNotes: "Second notes", + formId: 2 }; await request.post('/forms').send(formData); await request.post('/forms').send(formData2);