From d70f14d6bc8125b56a916bcbd06396dbaa271e29 Mon Sep 17 00:00:00 2001 From: michael shanks Date: Sat, 27 Jul 2019 07:31:31 +0100 Subject: [PATCH] derived components endpoints working --- .../{ => anotherSubFolder}/newTextBox.json | 0 .../testApp/components/undefined.json | 1 - .../appPackages/testApp/dist/package.tar.gz | Bin 2138 -> 2223 bytes packages/server/tests/builder.spec.js | 18 ++++++++++++++---- packages/server/tests/testApp.js | 7 ++++++- packages/server/utilities/builder.js | 2 +- 6 files changed, 21 insertions(+), 7 deletions(-) rename packages/server/appPackages/testApp/components/{ => anotherSubFolder}/newTextBox.json (100%) delete mode 100644 packages/server/appPackages/testApp/components/undefined.json diff --git a/packages/server/appPackages/testApp/components/newTextBox.json b/packages/server/appPackages/testApp/components/anotherSubFolder/newTextBox.json similarity index 100% rename from packages/server/appPackages/testApp/components/newTextBox.json rename to packages/server/appPackages/testApp/components/anotherSubFolder/newTextBox.json diff --git a/packages/server/appPackages/testApp/components/undefined.json b/packages/server/appPackages/testApp/components/undefined.json deleted file mode 100644 index 0a3036fd0..000000000 --- a/packages/server/appPackages/testApp/components/undefined.json +++ /dev/null @@ -1 +0,0 @@ -{"oldname":"newTextBox","newName":"anotherSubFolder/newTextBox"} diff --git a/packages/server/appPackages/testApp/dist/package.tar.gz b/packages/server/appPackages/testApp/dist/package.tar.gz index c6821cf94781ce864971d2f91e93d9e37ba4329a..70c523e2e1ab18eaae1f9e702cde2f0ba8b53cb2 100644 GIT binary patch literal 2223 zcmV;g2vGMQiwFP!000003hi5MZ`-yO?&kvi54^&FIk>K^ci)?K1+uioinUpB>nc|NBTvvL#u5Nhd2?qX!5alZQMc&kGL^>A|z(L)UfJb%Fd8sD7qj z49hXxkvnos9q9VVGDhH;)56%EC5*#Z4CSx(Q=QyD1km#kW7h=TAi@T}Ga5F}V~_j| z$99$cP4SOqSwJ_;kz`F@hX{72}fiiPbA&A&3_UEMrj!FF|X@Jj6J#Y55mRF|i4NFbU0~CkSTDXnqbCNo6X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~N zlG-=fkWJW|;$_y`5F1 z$`mc&4W>zaCH_2x9Y7pb;}o}hLVqmJhEq?OI|o)9R+M@_d-^X9ngA~;8VNG( z7LcpB85C+CX~ws1+%~TYxoH&rK>eje(gs60$v`wIeJW)?S`x|>M)()(i3G;qM-1dZ z`?LvBW%NExd_08=J>LedLpAg#9+2Hq6Xq(r&?bm+a2`d#0MEfYIxi*(X%eHn;FTBS zh*y@M1kU?q*;fiyOO=u9qqeHF8@0Q(Ve=iHihK{J3AmV`9JpzHC4mZeu3hg*Tq2T) z&5&%IPR9<}ziXT8`oCr9j;ZY5?(Dx65UIPcj2Q#pgBbml;28C^8Pm>QNRtn!pAa-a zcM*-bMCl3i8J?ek?_Yu5+EAs@7pyj)U<+l3Y#Dk2J1aSCN(w7AP08HhEyNsz=oWm4 zX@D8(^K=P4u}8Q5MTYVA>Rl0DDg&w2vk45TaR$xW(4Lxjm|TeWI6paO4IZY(rx3lFQa)5xbU^e*@H=^G(t?KK^%va&aI{)7SbpHQwL#6#UdWR`3u7r`M+y+_y4UxRsCm3g(}3&6@w4S-!Mko`mZhPzwXHH^8Z$# zuKv3(F6e5&Uk}vf|LLQOW}XEc@Bbac(k)g0vpV~41@_r_Q#x?0{I~JHI0?G^zZJ;E z|HJeRQu8zp%HKA&@t>K#{}y3DC;t{ezW<>F4G5k0H2G!*!1XIR^&;@>#X~Q!gOftu z{!@3q-~nlt#zFgct*!kVD*sdOfAnUTQ4NpW{$EOQze?lzms9F5U%fwndnwF+^5$v+ z&Odwr#>=5&&p%FndUH8>dvQK_^STQKI_RK- Q4!%nG8@-I4764cP0HP2-b^rhX diff --git a/packages/server/tests/builder.spec.js b/packages/server/tests/builder.spec.js index 24fe400c7..5823f2947 100644 --- a/packages/server/tests/builder.spec.js +++ b/packages/server/tests/builder.spec.js @@ -7,11 +7,20 @@ const testMoreComponents = require("../appPackages/testApp/moreCustomComponents/ const statusCodes = require("../utilities/statusCodes"); const derivedComponent1 = require("../appPackages/testApp/components/myTextBox.json"); const derivedComponent2 = require("../appPackages/testApp/components/subfolder/otherTextBox.json"); -const { readJSON, pathExists } = require("fs-extra"); +const { readJSON, pathExists, unlink } = require("fs-extra"); const app = require("./testApp")(); -beforeAll(async () => await app.start()); +beforeAll(async () => { + + const testComponent = "./appPackages/testApp/components/newTextBox.json"; + const testComponentAfterMove = "./appPackages/testApp/components/anotherSubFolder/newTextBox.json"; + + if(await pathExists(testComponent)) await unlink(testComponent); + if(await pathExists(testComponentAfterMove)) await unlink(testComponentAfterMove); + + await app.start(); +}); afterAll(async () => await app.destroy()); @@ -97,9 +106,10 @@ it("should be able to update derived component", async () => { }); it("should be able to rename derived component", async () => { - await app.post("/_builder/api/testApp/derivedcomponent", { - oldname: "newTextBox", newName: "anotherSubFolder/newTextBox" + await app.patch("/_builder/api/testApp/derivedcomponent", { + oldname: "newTextBox", newname: "anotherSubFolder/newTextBox" }).expect(statusCodes.OK); + const oldcomponentFile = "./appPackages/testApp/components/newTextBox.json"; const newcomponentFile = "./appPackages/testApp/components/anotherSubFolder/newTextBox.json"; expect(await pathExists(oldcomponentFile)).toBe(false); diff --git a/packages/server/tests/testApp.js b/packages/server/tests/testApp.js index 6cbea3700..510a341b9 100644 --- a/packages/server/tests/testApp.js +++ b/packages/server/tests/testApp.js @@ -69,6 +69,7 @@ module.exports = () => { config, server:() => server, post: (url, body) => postRequest(server,url,body), + patch: (url, body) => patchRequest(server,url,body), get: (url) => getRequest(server, url), credentials: { masterOwner: { @@ -108,7 +109,11 @@ module.exports = () => { }) }; - +const patchRequest = (server, url, body) => + request(server) + .patch(url) + .send(body) + .set('Accept', 'application/json'); const postRequest = (server, url, body) => request(server) diff --git a/packages/server/utilities/builder.js b/packages/server/utilities/builder.js index 97c9d1c26..bf22a1987 100644 --- a/packages/server/utilities/builder.js +++ b/packages/server/utilities/builder.js @@ -83,7 +83,7 @@ module.exports.renameDerivedComponent = async (config, appname, oldName, newName const oldComponentPath = componentPath( appPath, oldName); - const newComponentPath = join( + const newComponentPath = componentPath( appPath, newName); await ensureDir(dirname(newComponentPath));