Extra tests

This commit is contained in:
Adria Navarro 2024-08-09 10:43:33 +02:00
parent 723dfee8c8
commit 3acc9bde45
1 changed files with 49 additions and 0 deletions

View File

@ -199,4 +199,53 @@ describe.each([
}
})
})
it("does not allow accessing non-mapped fields", async () => {
await config.doInContext(config.appId, async () => {
await config.api.table.save({
...table,
schema: {
name: table.schema.name,
surname: table.schema.surname,
},
})
const result = await search({
tableId: table._id!,
query: {},
})
expect(result.rows).toHaveLength(10)
for (const row of result.rows) {
const keys = Object.keys(row)
expect(keys).toContain("name")
expect(keys).toContain("surname")
expect(keys).not.toContain("address")
expect(keys).not.toContain("age")
}
})
})
it("does not allow accessing non-mapped fields even if requested", async () => {
await config.doInContext(config.appId, async () => {
await config.api.table.save({
...table,
schema: {
name: table.schema.name,
surname: table.schema.surname,
},
})
const result = await search({
tableId: table._id!,
query: {},
fields: ["name", "age"],
})
expect(result.rows).toHaveLength(10)
for (const row of result.rows) {
const keys = Object.keys(row)
expect(keys).toContain("name")
expect(keys).not.toContain("age")
expect(keys).not.toContain("surname")
expect(keys).not.toContain("address")
}
})
})
})