diff --git a/qa-core/src/config/internal-api/TestConfiguration/screens.ts b/qa-core/src/config/internal-api/TestConfiguration/screens.ts index 1b97d7f6bf..30c688022a 100644 --- a/qa-core/src/config/internal-api/TestConfiguration/screens.ts +++ b/qa-core/src/config/internal-api/TestConfiguration/screens.ts @@ -9,13 +9,13 @@ import InternalAPIClient from "./InternalAPIClient" this.api = apiClient } - async createScreen(body: any): Promise<[Response, Screen]> { + async create(body: any): Promise<[Response, Screen]> { const response = await this.api.post(`/screens`, { body }) const json = await response.json() return [response, json] } - async deleteScreen(screenId: any, rev: any): Promise<[Response, Screen]> { + async delete(screenId: string, rev: string): Promise<[Response, Screen]> { const response = await this.api.del(`/screens/${screenId}/${rev}`) const json = await response.json() return [response, json] diff --git a/qa-core/src/tests/internal-api/applications/create.spec.ts b/qa-core/src/tests/internal-api/applications/create.spec.ts index c09af632de..aa71724cac 100644 --- a/qa-core/src/tests/internal-api/applications/create.spec.ts +++ b/qa-core/src/tests/internal-api/applications/create.spec.ts @@ -164,7 +164,7 @@ describe("Internal API - /applications endpoints", () => { // Change/add component to the app const [screenResponse, screen] = await config.applications.addScreentoApp( - generateScreen() + generateScreen("BASIC") ) expect(screenResponse).toHaveStatusCode(200) expect(screen._id).toBeDefined() diff --git a/qa-core/src/tests/internal-api/screens/screens.spec.ts b/qa-core/src/tests/internal-api/screens/screens.spec.ts index 4d2c17177f..68e1022cb4 100644 --- a/qa-core/src/tests/internal-api/screens/screens.spec.ts +++ b/qa-core/src/tests/internal-api/screens/screens.spec.ts @@ -22,29 +22,24 @@ describe("Internal API - /screens endpoints", () => { it("POST - Create a screen with each role type", async () => { // Create app const [appResponse, app] = await appConfig.applications.create(generateApp()) - expect(appResponse).toHaveStatusCode(200) - expect(app._id).toBeDefined() // Create Screen const roleArray = ["BASIC", "POWER", "ADMIN", "PUBLIC"] appConfig.applications.api.appId = app.appId - for (let i = 0; i < 4; i++) { - const [response, screen] = await config.screen.createScreen(generateScreen(roleArray[i])) + for (let role in roleArray) { + const [response, screen] = await config.screen.create(generateScreen(roleArray[role])) expect(response).toHaveStatusCode(200) - expect(screen.routing.roleId).toEqual(roleArray[i]) + expect(screen.routing.roleId).toEqual(roleArray[role]) } }) 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("BASIC")) - expect(response).toHaveStatusCode(200) + const [response, screen] = await config.screen.create(generateScreen("BASIC")) // Check screen exists const [routesResponse, routes] = await appConfig.applications.getRoutes() @@ -55,17 +50,13 @@ describe("Internal API - /screens endpoints", () => { it("DELETE - Delete a screen", 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 [screenResponse, screen] = await config.screen.createScreen(generateScreen("BASIC")) - expect(screenResponse).toHaveStatusCode(200) - expect(screen._id).toBeDefined() + const [screenResponse, screen] = await config.screen.create(generateScreen("BASIC")) // Delete Screen - const [response] = await config.screen.deleteScreen(screen._id, screen._rev) + const [response] = await config.screen.delete(screen._id!, screen._rev!) expect(response).toHaveStatusCode(200) }) })