Improvements on apps and tables
This commit is contained in:
parent
611731e4bb
commit
ab1594c902
|
@ -153,4 +153,27 @@ export default class AppApi {
|
||||||
expect(response).toHaveStatusCode(204)
|
expect(response).toHaveStatusCode(204)
|
||||||
return [response]
|
return [response]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async unlock(appId: string): Promise<[Response, responseMessage]> {
|
||||||
|
const response = await this.api.del(`/dev/${appId}/lock`)
|
||||||
|
const json = await response.json()
|
||||||
|
expect(response).toHaveStatusCode(200)
|
||||||
|
expect(json.message).toEqual("Lock released successfully.")
|
||||||
|
return [response, json]
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateIcon(appId: string): Promise<[Response, Application]> {
|
||||||
|
const body = {
|
||||||
|
icon: {
|
||||||
|
name: "ConversionFunnel",
|
||||||
|
color: "var(--spectrum-global-color-red-400)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const response = await this.api.put(`/applications/${appId}`, { body })
|
||||||
|
const json = await response.json()
|
||||||
|
expect(response).toHaveStatusCode(200)
|
||||||
|
expect(json.icon.name).toEqual(body.icon.name)
|
||||||
|
expect(json.icon.color).toEqual(body.icon.color)
|
||||||
|
return [response, json]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ export default class RowsApi {
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
if (this.rowAdded) {
|
if (this.rowAdded) {
|
||||||
expect(response).toHaveStatusCode(200)
|
expect(response).toHaveStatusCode(200)
|
||||||
expect(json.length).toEqual(1)
|
expect(json.length).toBeGreaterThanOrEqual(1)
|
||||||
}
|
}
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,22 @@ export default class RowsApi {
|
||||||
expect(response).toHaveStatusCode(200)
|
expect(response).toHaveStatusCode(200)
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async searchSinglePage(tableId: string, body: any): Promise<[Response, Row[]]> {
|
||||||
|
const response = await this.api.post(`/${tableId}/search`, { body })
|
||||||
|
const json = await response.json()
|
||||||
|
expect(response).toHaveStatusCode(200)
|
||||||
|
expect(json.rows.length).toBeLessThanOrEqual(9)
|
||||||
|
expect(json.hasNextPage).toEqual(false)
|
||||||
|
return [response, json.rows]
|
||||||
|
}
|
||||||
|
|
||||||
|
async searchMultiPage(tableId: string, body: any): Promise<[Response, Row[]]> {
|
||||||
|
const response = await this.api.post(`/${tableId}/search`, { body })
|
||||||
|
const json = await response.json()
|
||||||
|
expect(response).toHaveStatusCode(200)
|
||||||
|
expect(json.hasNextPage).toEqual(true)
|
||||||
|
expect(json.rows.length).toEqual(10)
|
||||||
|
return [response, json.rows]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,3 +6,27 @@ export const generateNewRowForTable = (tableId: string): Row => {
|
||||||
tableId: tableId,
|
tableId: tableId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const searchBody = (primaryDisplay: string): any => {
|
||||||
|
return {
|
||||||
|
bookmark: null,
|
||||||
|
limit: 10,
|
||||||
|
paginate: true,
|
||||||
|
query: {
|
||||||
|
contains: {},
|
||||||
|
containsAny: {},
|
||||||
|
empty: {},
|
||||||
|
equal: {},
|
||||||
|
fuzzy: {},
|
||||||
|
notContains: {},
|
||||||
|
notEmpty: {},
|
||||||
|
notEqual: {},
|
||||||
|
oneOf: {},
|
||||||
|
range: {},
|
||||||
|
string: {},
|
||||||
|
},
|
||||||
|
sort: primaryDisplay,
|
||||||
|
sortOrder: "ascending",
|
||||||
|
sortType: "string"
|
||||||
|
}
|
||||||
|
}
|
|
@ -104,6 +104,14 @@ describe("Internal API - Application creation, update, publish and delete", () =
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("Update the icon and color of an application", async () => {
|
||||||
|
const app = await config.applications.create(generateApp())
|
||||||
|
|
||||||
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
await config.applications.updateIcon(<string>app.appId)
|
||||||
|
})
|
||||||
|
|
||||||
it("POST - Revert Changes without changes", async () => {
|
it("POST - Revert Changes without changes", async () => {
|
||||||
const app = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
@ -124,6 +132,7 @@ describe("Internal API - Application creation, update, publish and delete", () =
|
||||||
// // Revert the app to published state
|
// // Revert the app to published state
|
||||||
await config.applications.revertPublished(<string>app.appId)
|
await config.applications.revertPublished(<string>app.appId)
|
||||||
|
|
||||||
|
await config.applications.unlock(<string>app.appId)
|
||||||
// Check screen is removed
|
// Check screen is removed
|
||||||
await config.applications.getRoutes()
|
await config.applications.getRoutes()
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,9 +6,9 @@ import {
|
||||||
generateTable,
|
generateTable,
|
||||||
generateNewColumnForTable,
|
generateNewColumnForTable,
|
||||||
} from "../../../config/internal-api/fixtures/table"
|
} from "../../../config/internal-api/fixtures/table"
|
||||||
import { generateNewRowForTable } from "../../../config/internal-api/fixtures/rows"
|
import { generateNewRowForTable, searchBody } from "../../../config/internal-api/fixtures/rows"
|
||||||
|
|
||||||
describe("Internal API - Application creation, update, publish and delete", () => {
|
describe("Internal API - Table Operations", () => {
|
||||||
const api = new InternalAPIClient()
|
const api = new InternalAPIClient()
|
||||||
const config = new TestConfiguration<Application>(api)
|
const config = new TestConfiguration<Application>(api)
|
||||||
|
|
||||||
|
@ -86,4 +86,61 @@ describe("Internal API - Application creation, update, publish and delete", () =
|
||||||
//Table was deleted
|
//Table was deleted
|
||||||
await config.tables.getAll(2)
|
await config.tables.getAll(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("Search and pagination", async () => {
|
||||||
|
// create the app
|
||||||
|
const appName = generator.word()
|
||||||
|
const app = await createAppFromTemplate()
|
||||||
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
// Get current tables: expect 2 in this template
|
||||||
|
await config.tables.getAll(2)
|
||||||
|
|
||||||
|
// Add new table
|
||||||
|
const [createdTableResponse, createdTableData] = await config.tables.save(
|
||||||
|
generateTable()
|
||||||
|
)
|
||||||
|
|
||||||
|
//Table was added
|
||||||
|
await config.tables.getAll(3)
|
||||||
|
|
||||||
|
//Get information about the table
|
||||||
|
await config.tables.getTableById(<string>createdTableData._id)
|
||||||
|
|
||||||
|
//Add Column to table
|
||||||
|
const newColumn = generateNewColumnForTable(createdTableData)
|
||||||
|
const [addColumnResponse, addColumnData] = await config.tables.save(
|
||||||
|
newColumn,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
|
//Add Row to table
|
||||||
|
let newRow = generateNewRowForTable(<string>addColumnData._id)
|
||||||
|
await config.rows.add(<string>addColumnData._id, newRow)
|
||||||
|
|
||||||
|
//Search single row
|
||||||
|
await config.rows.searchSinglePage(<string>createdTableData._id, searchBody(<string>createdTableData.primaryDisplay))
|
||||||
|
|
||||||
|
//Add 10 more rows
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
let newRow = generateNewRowForTable(<string>addColumnData._id)
|
||||||
|
await config.rows.add(<string>addColumnData._id, newRow)
|
||||||
|
}
|
||||||
|
|
||||||
|
//Search multiple rows
|
||||||
|
const [allRowsResponse, allRowsJson] = await config.rows.searchMultiPage(<string>createdTableData._id, searchBody(<string>createdTableData.primaryDisplay))
|
||||||
|
|
||||||
|
//Delete Rows from table
|
||||||
|
const rowToDelete = {
|
||||||
|
rows: [allRowsJson],
|
||||||
|
}
|
||||||
|
const [deleteRowResponse, deleteRowData] = await config.rows.delete(
|
||||||
|
<string>addColumnData._id,
|
||||||
|
rowToDelete
|
||||||
|
)
|
||||||
|
|
||||||
|
//Search single row
|
||||||
|
await config.rows.searchSinglePage(<string>createdTableData._id, searchBody(<string>createdTableData.primaryDisplay))
|
||||||
|
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue