adding renaming test
This commit is contained in:
parent
dd0b66be69
commit
a597232814
|
@ -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() {
|
||||
|
|
|
@ -44,5 +44,6 @@
|
|||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
font-family: Inter;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue