Legacy views tests

This commit is contained in:
Adria Navarro 2023-09-08 10:43:19 +02:00
parent 93e9b1b8b4
commit 9e799c6b93
2 changed files with 57 additions and 49 deletions

View File

@ -710,9 +710,11 @@ describe.each([
}) })
}) })
// Legacy views are not available for external
isInternal &&
describe("fetchView", () => { describe("fetchView", () => {
it("should be able to fetch tables contents via 'view'", async () => { it("should be able to fetch tables contents via 'view'", async () => {
const row = await config.createRow() const row = await createRow()
const rowUsage = await getRowUsage() const rowUsage = await getRowUsage()
const queryUsage = await getQueryUsage() const queryUsage = await getQueryUsage()
@ -741,8 +743,13 @@ describe.each([
}) })
it("should be able to run on a view", async () => { it("should be able to run on a view", async () => {
const view = await config.createLegacyView() const view = await config.createLegacyView({
const row = await config.createRow() tableId: table._id!,
name: "ViewTest",
filters: [],
schema: {},
})
const row = await createRow()
const rowUsage = await getRowUsage() const rowUsage = await getRowUsage()
const queryUsage = await getQueryUsage() const queryUsage = await getQueryUsage()

View File

@ -50,6 +50,7 @@ import {
SearchFilters, SearchFilters,
UserRoles, UserRoles,
Automation, Automation,
View,
} from "@budibase/types" } from "@budibase/types"
import API from "./api" import API from "./api"
@ -629,12 +630,12 @@ class TestConfiguration {
// VIEW // VIEW
async createLegacyView(config?: any) { async createLegacyView(config?: View) {
if (!this.table) { if (!this.table && !config) {
throw "Test requires table to be configured." throw "Test requires table to be configured."
} }
const view = config || { const view = config || {
tableId: this.table._id, tableId: this.table!._id,
name: "ViewTest", name: "ViewTest",
} }
return this._req(view, null, controllers.view.v1.save) return this._req(view, null, controllers.view.v1.save)