API Screens - Fetch screens test

Additional test to fetch screens.
- To confirm the screen was created i am checking `routes`
- It will then confirm the route with the screen exists - in this case the route is `/test` (as determined when the screen is created)
This commit is contained in:
Mitch-Budibase 2022-10-10 17:27:55 +01:00
parent d52c9a5cfb
commit 6aa0d41eb2
2 changed files with 22 additions and 0 deletions

View File

@ -46,4 +46,10 @@ export default class AppApi {
const json = await response.json()
return [response, json.data]
}
async getRoutes(): Promise<[Response, any]> {
const response = await this.api.get(`/routing`)
const json = await response.json()
return [response, json]
}
}

View File

@ -30,7 +30,23 @@ describe("Internal API - /screens endpoints", () => {
const [response, screen] = await config.screen.createScreen(generateScreen())
expect(response).toHaveStatusCode(200)
expect(screen.routing.roleId).toEqual("BASIC")
})
it("GET - Fetch screens", async () => {
// Create app
const [appResponse, app] = await appConfig.applications.create(generateApp())
expect(appResponse).toHaveStatusCode(200)
expect(app._id).toBeDefined()
// Create Screen
appConfig.applications.api.appId = app.appId
const [response, screen] = await config.screen.createScreen(generateScreen())
expect(response).toHaveStatusCode(200)
// Check screen exists
const [routesResponse, routes] = await appConfig.applications.getRoutes()
expect(routesResponse).toHaveStatusCode(200)
expect(routes.routes["/test"]).toBeTruthy()
})
it("DELETE - Delete a screen", async () => {