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 f633ffb824
commit 052bc0aeed
4 changed files with 9 additions and 8 deletions

View File

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

View File

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

View File

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

View File

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