1
0
Fork 0
mirror of synced 2024-06-02 02:25:17 +12:00

Add tests for endpoints

This commit is contained in:
Pedro Silva 2022-10-07 12:19:00 +01:00
parent f3d6879349
commit e343aab655
2 changed files with 74 additions and 1 deletions

View file

@ -53,7 +53,7 @@ export default class AppApi {
return [response, json]
}
async update(appId: string, body: any): Promise<[Response, Application]> {
async updateClient(appId: string, body: any): Promise<[Response, Application]> {
const response = await this.api.put(`/applications/${appId}/client/update`, { body })
const json = await response.json()
return [response, json]
@ -77,5 +77,11 @@ export default class AppApi {
return [response, json]
}
async update(appId: string, body: any): Promise<[Response, Application]> {
const response = await this.api.put(`/applications/${appId}`, { body })
const json = await response.json()
return [response, json]
}
}

View file

@ -84,4 +84,71 @@ describe("Internal API - /applications endpoints", () => {
await config.applications.canRender()
expect(publishedAppRenders).toBe(true)
})
it("POST - Sync application before deployment", async () => {
const [response, app] = await config.applications.create(generateApp())
expect(response).toHaveStatusCode(200)
expect(app.appId).toBeDefined()
config.applications.api.appId = app.appId
const [syncResponse, sync] = await config.applications.sync(app.appId ? app.appId : "")
expect(syncResponse).toHaveStatusCode(200)
expect(sync).toEqual({
message: "App sync not required, app not deployed."
})
})
it("POST - Sync application after deployment", async () => {
const [response, app] = await config.applications.create(generateApp())
expect(response).toHaveStatusCode(200)
expect(app.appId).toBeDefined()
config.applications.api.appId = app.appId
// publish app
await config.applications.publish()
const [syncResponse, sync] = await config.applications.sync(app.appId ? app.appId : "")
expect(syncResponse).toHaveStatusCode(200)
expect(sync).toEqual({
message: "App sync completed successfully."
})
})
it("PUT - Update an application", async () => {
const [response, app] = await config.applications.create(generateApp())
expect(response).toHaveStatusCode(200)
expect(app.appId).toBeDefined()
})
it.skip("POST - Revert Changes", async () => {
const [response, app] = await config.applications.create(generateApp())
expect(response).toHaveStatusCode(200)
expect(app.appId).toBeDefined()
// publish app
await config.applications.publish()
const [updateResponse, updatedApp] = await config.applications.update(app.appId ? app.appId : "", {
name: generator.word(),
})
expect(updateResponse).toHaveStatusCode(200)
expect(updatedApp.name).not.toEqual(app.name)
const [revertResponse, revert] = await config.applications.revert(app.appId ? app.appId : "")
expect(revertResponse).toHaveStatusCode(200)
expect(revert).toEqual({
message: "App reverted successfully."
})
})
it("DELETE - Delete an application", async () => {
const [response, app] = await config.applications.create(generateApp())
expect(response).toHaveStatusCode(200)
expect(app.appId).toBeDefined()
const [deleteResponse] = await config.applications.delete(app.appId ? app.appId : "")
expect(deleteResponse).toHaveStatusCode(200)
})
})