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 0a3036fd00..0000000000 --- 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 c6821cf947..70c523e2e1 100644 Binary files a/packages/server/appPackages/testApp/dist/package.tar.gz and b/packages/server/appPackages/testApp/dist/package.tar.gz differ diff --git a/packages/server/tests/builder.spec.js b/packages/server/tests/builder.spec.js index 24fe400c75..5823f2947d 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 6cbea37009..510a341b9c 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 97c9d1c26d..bf22a19873 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));