1
0
Fork 0
mirror of synced 2024-10-02 10:08:09 +13:00

adding renaming test

This commit is contained in:
Martin McKeaveney 2020-06-26 09:55:15 +01:00
parent dd0b66be69
commit a597232814
3 changed files with 46 additions and 2 deletions

View file

@ -13,7 +13,7 @@
let linkedRecords = new Set(linked)
$: linked = [...linkedRecords]
$: FIELDS_TO_HIDE = [$backendUiStore.selectedModel._id]
$: FIELDS_TO_HIDE = [$backendUiStore.selectedModel.name]
$: schema = $backendUiStore.selectedModel.schema
async function fetchRecords() {

View file

@ -44,5 +44,6 @@
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
font-family: Inter;
}
</style>

View file

@ -26,7 +26,6 @@ describe("/models", () => {
})
describe("create", () => {
beforeEach(async () => {
instance = await createInstance(request, app._id);
});
@ -51,6 +50,50 @@ describe("/models", () => {
});
})
it("renames all the record fields for a model when a schema key is renamed", async () => {
const testModel = await createModel(request, app._id, instance._id);
const testRecord = await request
.post(`/api/${testModel._id}/records`)
.send({
name: "test"
})
.set(defaultHeaders(app._id, instance._id))
.expect('Content-Type', /json/)
.expect(200)
const updatedModel = await request
.post(`/api/models`)
.send({
_id: testModel._id,
_rev: testModel._rev,
name: "TestModel",
key: "name",
_rename: {
old: "name",
updated: "updatedName"
},
schema: {
updatedName: { type: "string" }
}
})
.set(defaultHeaders(app._id, instance._id))
.expect('Content-Type', /json/)
.expect(200)
expect(updatedModel.res.statusMessage).toEqual("Model TestModel saved successfully.");
expect(updatedModel.body.name).toEqual("TestModel");
const res = await request
.get(`/api/${testModel._id}/records/${testRecord.body._id}`)
.set(defaultHeaders(app._id, instance._id))
.expect('Content-Type', /json/)
.expect(200)
expect(res.body.updatedName).toEqual("test");
expect(res.body.name).toBeUndefined();
});
it("should apply authorization to endpoint", async () => {
await builderEndpointShouldBlockNormalUsers({
request,