Extra tests
This commit is contained in:
parent
3c0a033c8b
commit
a87e3dd0fc
|
@ -1539,7 +1539,7 @@ describe.each([
|
||||||
tableId = table._id!
|
tableId = table._id!
|
||||||
})
|
})
|
||||||
|
|
||||||
it("can save and retrieve when BB reference fields are empty", async () => {
|
it("can save a row when BB reference fields are empty", async () => {
|
||||||
const rowData = {
|
const rowData = {
|
||||||
...basicRow(tableId),
|
...basicRow(tableId),
|
||||||
name: generator.name(),
|
name: generator.name(),
|
||||||
|
@ -1557,7 +1557,7 @@ describe.each([
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("can save and retrieve a row with a single BB reference field", async () => {
|
it("can save a row with a single BB reference field", async () => {
|
||||||
const user = await config.createUser()
|
const user = await config.createUser()
|
||||||
const rowData = {
|
const rowData = {
|
||||||
...basicRow(tableId),
|
...basicRow(tableId),
|
||||||
|
@ -1586,13 +1586,13 @@ describe.each([
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("can save and retrieve a row with a multiple BB reference field", async () => {
|
it("can save a row with a multiple BB reference field", async () => {
|
||||||
const users = [await config.createUser(), await config.createUser()]
|
const users = [await config.createUser(), await config.createUser()]
|
||||||
const rowData = {
|
const rowData = {
|
||||||
...basicRow(tableId),
|
...basicRow(tableId),
|
||||||
name: generator.name(),
|
name: generator.name(),
|
||||||
description: generator.name(),
|
description: generator.name(),
|
||||||
user: users,
|
users: users,
|
||||||
}
|
}
|
||||||
const row = await config.api.row.save(tableId, rowData)
|
const row = await config.api.row.save(tableId, rowData)
|
||||||
|
|
||||||
|
@ -1601,7 +1601,7 @@ describe.each([
|
||||||
description: rowData.description,
|
description: rowData.description,
|
||||||
type: "row",
|
type: "row",
|
||||||
tableId,
|
tableId,
|
||||||
user: users.map(u => ({
|
users: users.map(u => ({
|
||||||
_id: u._id,
|
_id: u._id,
|
||||||
email: u.email,
|
email: u.email,
|
||||||
firstName: u.firstName,
|
firstName: u.firstName,
|
||||||
|
@ -1612,5 +1612,51 @@ describe.each([
|
||||||
_rev: expect.any(String),
|
_rev: expect.any(String),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("can update an existing populated row", async () => {
|
||||||
|
const [user1, user2, user3] = [
|
||||||
|
await config.createUser(),
|
||||||
|
await config.createUser(),
|
||||||
|
await config.createUser(),
|
||||||
|
]
|
||||||
|
|
||||||
|
const rowData = {
|
||||||
|
...basicRow(tableId),
|
||||||
|
name: generator.name(),
|
||||||
|
description: generator.name(),
|
||||||
|
users: [user1, user2],
|
||||||
|
}
|
||||||
|
const row = await config.api.row.save(tableId, rowData)
|
||||||
|
|
||||||
|
const updatedRow = await config.api.row.save(tableId, {
|
||||||
|
...row,
|
||||||
|
user: [user3],
|
||||||
|
users: [user3, user2],
|
||||||
|
})
|
||||||
|
expect(updatedRow).toEqual({
|
||||||
|
name: rowData.name,
|
||||||
|
description: rowData.description,
|
||||||
|
type: "row",
|
||||||
|
tableId,
|
||||||
|
user: [
|
||||||
|
{
|
||||||
|
_id: user3._id,
|
||||||
|
email: user3.email,
|
||||||
|
firstName: user3.firstName,
|
||||||
|
lastName: user3.lastName,
|
||||||
|
primaryDisplay: user3.email,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
users: [user3, user2].map(u => ({
|
||||||
|
_id: u._id,
|
||||||
|
email: u.email,
|
||||||
|
firstName: u.firstName,
|
||||||
|
lastName: u.lastName,
|
||||||
|
primaryDisplay: u.email,
|
||||||
|
})),
|
||||||
|
_id: row._id,
|
||||||
|
_rev: expect.any(String),
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -44,12 +44,12 @@ export class RowAPI extends TestAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
save = async (
|
save = async (
|
||||||
sourceId: string,
|
tableId: string,
|
||||||
row: SaveRowRequest,
|
row: SaveRowRequest,
|
||||||
{ expectStatus } = { expectStatus: 200 }
|
{ expectStatus } = { expectStatus: 200 }
|
||||||
): Promise<Row> => {
|
): Promise<Row> => {
|
||||||
const resp = await this.request
|
const resp = await this.request
|
||||||
.post(`/api/${sourceId}/rows`)
|
.post(`/api/${tableId}/rows`)
|
||||||
.send(row)
|
.send(row)
|
||||||
.set(this.config.defaultHeaders())
|
.set(this.config.defaultHeaders())
|
||||||
.expect("Content-Type", /json/)
|
.expect("Content-Type", /json/)
|
||||||
|
|
Loading…
Reference in New Issue