Add test for table pagination
This commit is contained in:
parent
125a06517d
commit
3fc6dd62f7
|
@ -37,16 +37,15 @@ export default class RowsApi {
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
|
||||||
async searchSinglePage(tableId: string, body: any): Promise<[Response, Row[]]> {
|
async searchNoPagination(tableId: string, body: any): Promise<[Response, Row[]]> {
|
||||||
const response = await this.api.post(`/${tableId}/search`, { body })
|
const response = await this.api.post(`/${tableId}/search`, { body })
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
expect(response).toHaveStatusCode(200)
|
expect(response).toHaveStatusCode(200)
|
||||||
expect(json.rows.length).toBeLessThanOrEqual(9)
|
|
||||||
expect(json.hasNextPage).toEqual(false)
|
expect(json.hasNextPage).toEqual(false)
|
||||||
return [response, json.rows]
|
return [response, json.rows]
|
||||||
}
|
}
|
||||||
|
|
||||||
async searchMultiPage(tableId: string, body: any): Promise<[Response, Row[]]> {
|
async searchWithPagination(tableId: string, body: any): Promise<[Response, Row[]]> {
|
||||||
const response = await this.api.post(`/${tableId}/search`, { body })
|
const response = await this.api.post(`/${tableId}/search`, { body })
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
expect(response).toHaveStatusCode(200)
|
expect(response).toHaveStatusCode(200)
|
||||||
|
|
|
@ -31,7 +31,7 @@ describe("Internal API - Table Operations", () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
it("Operations on Tables", async () => {
|
it("Create and delete table, columns and rows", async () => {
|
||||||
// create the app
|
// create the app
|
||||||
const appName = generator.word()
|
const appName = generator.word()
|
||||||
const app = await createAppFromTemplate()
|
const app = await createAppFromTemplate()
|
||||||
|
@ -119,7 +119,7 @@ describe("Internal API - Table Operations", () => {
|
||||||
await config.rows.add(<string>addColumnData._id, newRow)
|
await config.rows.add(<string>addColumnData._id, newRow)
|
||||||
|
|
||||||
//Search single row
|
//Search single row
|
||||||
await config.rows.searchSinglePage(<string>createdTableData._id, searchBody(<string>createdTableData.primaryDisplay))
|
await config.rows.searchNoPagination(<string>createdTableData._id, searchBody(<string>createdTableData.primaryDisplay))
|
||||||
|
|
||||||
//Add 10 more rows
|
//Add 10 more rows
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
|
@ -128,7 +128,7 @@ describe("Internal API - Table Operations", () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Search rows with pagination
|
//Search rows with pagination
|
||||||
const [allRowsResponse, allRowsJson] = await config.rows.searchMultiPage(<string>createdTableData._id, searchBody(<string>createdTableData.primaryDisplay))
|
const [allRowsResponse, allRowsJson] = await config.rows.searchWithPagination(<string>createdTableData._id, searchBody(<string>createdTableData.primaryDisplay))
|
||||||
|
|
||||||
//Delete Rows from table
|
//Delete Rows from table
|
||||||
const rowToDelete = {
|
const rowToDelete = {
|
||||||
|
@ -140,7 +140,7 @@ describe("Internal API - Table Operations", () => {
|
||||||
)
|
)
|
||||||
|
|
||||||
//Search single row
|
//Search single row
|
||||||
await config.rows.searchSinglePage(<string>createdTableData._id, searchBody(<string>createdTableData.primaryDisplay))
|
await config.rows.searchWithPagination(<string>createdTableData._id, searchBody(<string>createdTableData.primaryDisplay))
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue