From 3aad3266e4fd5903ef8ce9dcedafe1ac75c70a3e Mon Sep 17 00:00:00 2001 From: Kathleen Tuite Date: Tue, 8 Oct 2024 16:34:26 -0700 Subject: [PATCH] update version in a draft --- lib/worker/form.js | 4 ++-- test/integration/other/form-entities-version.js | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/worker/form.js b/lib/worker/form.js index a995f6305..0a55fce12 100644 --- a/lib/worker/form.js +++ b/lib/worker/form.js @@ -53,8 +53,8 @@ const updateEntitiesVersion = async ({ Forms }, event) => { const draftVersion = await Forms.getByProjectAndXmlFormId(projectId, xmlFormId, true, Form.DraftVersion).then(o => o.orNull()); if (draftVersion && draftVersion.draftDefId != null) { const partial = await draftVersion.withUpgradeEntityVersion(); - // only update xml. maybe it should update the version as well? but this is all happening in place. - await Forms._updateDef(draftVersion.def, { xml: partial.xml }); + // update xml and version in place + await Forms._updateDef(draftVersion.def, { xml: partial.xml, version: partial.def.version }); } }; diff --git a/test/integration/other/form-entities-version.js b/test/integration/other/form-entities-version.js index babb146c3..ce3656fc5 100644 --- a/test/integration/other/form-entities-version.js +++ b/test/integration/other/form-entities-version.js @@ -72,10 +72,15 @@ describe('Update / migrate entities-version within form', () => { // Run form upgrade await exhaust(container); - // The version on the draft hasn't changed because it has been updated in place + // The version on the draft does change even though it is updated in place await asAlice.get('/v1/projects/1/forms/updateEntity/draft') .then(({ body }) => { - body.version.should.equal('1.0'); + body.version.should.equal('1.0_upgrade'); + }); + + await asAlice.get('/v1/projects/1/forms/updateEntity/versions') + .then(({ body }) => { + body.length.should.equal(0); }); // The XML is updated