1
0
Fork 0
mirror of synced 2024-06-15 00:44:41 +12:00

ensure correct revert endpoint being hit, update call to revert

This commit is contained in:
Martin McKeaveney 2022-10-09 19:31:35 +01:00
parent 3abf993779
commit 83f3a02d23
4 changed files with 9 additions and 8 deletions

View file

@ -103,7 +103,7 @@ exports.revert = async ctx => {
target: appId,
})
try {
if (!env.isCypress()) {
if (env.COUCH_DB_URL) {
// in-memory db stalls on rollback
await replication.rollback()
}

View file

@ -18,6 +18,7 @@ import { Table } from "@budibase/types"
import { quotas } from "@budibase/pro"
import { isEqual } from "lodash"
import { cloneDeep } from "lodash/fp"
import env from "../../../environment"
function checkAutoColumns(table: Table, oldTable: Table) {
if (!table.schema) {
@ -167,7 +168,7 @@ export async function destroy(ctx: any) {
await db.remove(tableToDelete)
// remove table search index
if (!isTest()) {
if (!isTest() || env.COUCH_DB_URL) {
const currentIndexes = await db.getIndexes()
const existingIndex = currentIndexes.indexes.find(
(existing: any) => existing.name === `search:${ctx.params.tableId}`

View file

@ -59,8 +59,8 @@ export default class AppApi {
return [response, json]
}
async revert(appId: string): Promise<[Response, Application]> {
const response = await this.api.post(`/applications/${appId}/client/revert`)
async revert(appId: string): Promise<[Response, { message: string }]> {
const response = await this.api.post(`/dev/${appId}/revert`)
const json = await response.json()
return [response, json]
}
@ -82,8 +82,8 @@ export default class AppApi {
const json = await response.json()
return [response, json]
}
async addScreentoApp(body: any): Promise<[Response, Application]> {
async addScreentoApp(body: any): Promise<[Response, Application]> {
const response = await this.api.post(`/screens`, { body })
const json = await response.json()
return [response, json]

View file

@ -158,11 +158,11 @@ describe("Internal API - /applications endpoints", () => {
expect(screenResponse).toHaveStatusCode(200)
expect(screen._id).toBeDefined()
const [revertResponse, revert] = await config.applications.revert(app.appId ? app.appId : "")
// // Revert the app to published state
const [revertResponse, revert] = await config.applications.revert(app.appId as string)
expect(revertResponse).toHaveStatusCode(200)
expect(revert).toEqual({
message: "App reverted successfully."
message: "Reverted changes successfully."
})
// Check screen is removed