derived components endpoints working

This commit is contained in:
michael shanks 2019-07-27 07:31:31 +01:00
parent af2fc95a6b
commit d70f14d6bc
6 changed files with 21 additions and 7 deletions

View File

@ -1 +0,0 @@
{"oldname":"newTextBox","newName":"anotherSubFolder/newTextBox"}

View File

@ -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);

View File

@ -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)

View File

@ -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));