Remove type casting any from test methods
This commit is contained in:
parent
b6267e0f96
commit
eff22c4e74
|
@ -21,4 +21,5 @@ export interface Screen extends Document {
|
||||||
width?: string
|
width?: string
|
||||||
routing: ScreenRouting
|
routing: ScreenRouting
|
||||||
props: ScreenProps
|
props: ScreenProps
|
||||||
|
name?: string
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,15 @@ import {
|
||||||
AppPackageResponse,
|
AppPackageResponse,
|
||||||
DeployConfig,
|
DeployConfig,
|
||||||
MessageResponse,
|
MessageResponse,
|
||||||
|
CreateAppRequest,
|
||||||
} from "../../../types"
|
} from "../../../types"
|
||||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||||
import BaseAPI from "./BaseAPI"
|
import BaseAPI from "./BaseAPI"
|
||||||
|
|
||||||
|
interface RenameAppBody {
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
|
||||||
export default class AppAPI extends BaseAPI {
|
export default class AppAPI extends BaseAPI {
|
||||||
constructor(client: BudibaseInternalAPIClient) {
|
constructor(client: BudibaseInternalAPIClient) {
|
||||||
super(client)
|
super(client)
|
||||||
|
@ -46,7 +51,7 @@ export default class AppAPI extends BaseAPI {
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(body: any): Promise<App> {
|
async create(body: CreateAppRequest): Promise<App> {
|
||||||
const [response, json] = await this.post(`/applications`, body)
|
const [response, json] = await this.post(`/applications`, body)
|
||||||
expect(json._id).toBeDefined()
|
expect(json._id).toBeDefined()
|
||||||
return json
|
return json
|
||||||
|
@ -100,18 +105,13 @@ export default class AppAPI extends BaseAPI {
|
||||||
async rename(
|
async rename(
|
||||||
appId: string,
|
appId: string,
|
||||||
oldName: string,
|
oldName: string,
|
||||||
body: any
|
body: RenameAppBody
|
||||||
): Promise<[Response, App]> {
|
): Promise<[Response, App]> {
|
||||||
const [response, json] = await this.put(`/applications/${appId}`, body)
|
const [response, json] = await this.put(`/applications/${appId}`, body)
|
||||||
expect(json.name).not.toEqual(oldName)
|
expect(json.name).not.toEqual(oldName)
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
|
||||||
async addScreentoApp(body: any): Promise<[Response, App]> {
|
|
||||||
const [response, json] = await this.post(`/screens`, body)
|
|
||||||
return [response, json]
|
|
||||||
}
|
|
||||||
|
|
||||||
async getRoutes(screenExists?: boolean): Promise<[Response, RouteConfig]> {
|
async getRoutes(screenExists?: boolean): Promise<[Response, RouteConfig]> {
|
||||||
const [response, json] = await this.get(`/routing`)
|
const [response, json] = await this.get(`/routing`)
|
||||||
if (screenExists) {
|
if (screenExists) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import {
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||||
import BaseAPI from "./BaseAPI"
|
import BaseAPI from "./BaseAPI"
|
||||||
|
import { DatasourceRequest } from "../../../types"
|
||||||
|
|
||||||
export default class DatasourcesAPI extends BaseAPI {
|
export default class DatasourcesAPI extends BaseAPI {
|
||||||
constructor(client: BudibaseInternalAPIClient) {
|
constructor(client: BudibaseInternalAPIClient) {
|
||||||
|
@ -31,7 +32,9 @@ export default class DatasourcesAPI extends BaseAPI {
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
|
||||||
async add(body: any): Promise<[Response, CreateDatasourceResponse]> {
|
async add(
|
||||||
|
body: DatasourceRequest
|
||||||
|
): Promise<[Response, CreateDatasourceResponse]> {
|
||||||
const [response, json] = await this.post(`/datasources`, body)
|
const [response, json] = await this.post(`/datasources`, body)
|
||||||
expect(json.datasource._id).toBeDefined()
|
expect(json.datasource._id).toBeDefined()
|
||||||
expect(json.datasource._rev).toBeDefined()
|
expect(json.datasource._rev).toBeDefined()
|
||||||
|
@ -39,7 +42,9 @@ export default class DatasourcesAPI extends BaseAPI {
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(body: any): Promise<[Response, UpdateDatasourceResponse]> {
|
async update(
|
||||||
|
body: Datasource
|
||||||
|
): Promise<[Response, UpdateDatasourceResponse]> {
|
||||||
const [response, json] = await this.put(`/datasources/${body._id}`, body)
|
const [response, json] = await this.put(`/datasources/${body._id}`, body)
|
||||||
expect(json.datasource._id).toBeDefined()
|
expect(json.datasource._id).toBeDefined()
|
||||||
expect(json.datasource._rev).toBeDefined()
|
expect(json.datasource._rev).toBeDefined()
|
||||||
|
@ -47,28 +52,6 @@ export default class DatasourcesAPI extends BaseAPI {
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
|
||||||
async previewQuery(body: any): Promise<[Response, any]> {
|
|
||||||
const [response, json] = await this.post(`/queries/preview`, body)
|
|
||||||
return [response, json]
|
|
||||||
}
|
|
||||||
|
|
||||||
async saveQuery(body: any): Promise<[Response, any]> {
|
|
||||||
const [response, json] = await this.post(`/queries`, body)
|
|
||||||
return [response, json]
|
|
||||||
}
|
|
||||||
|
|
||||||
async getQuery(queryId: string): Promise<[Response, any]> {
|
|
||||||
const [response, json] = await this.get(`/queries/${queryId}`)
|
|
||||||
|
|
||||||
return [response, json]
|
|
||||||
}
|
|
||||||
|
|
||||||
async getQueryPermissions(queryId: string): Promise<[Response, any]> {
|
|
||||||
const [response, json] = await this.get(`/permissions/${queryId}`)
|
|
||||||
|
|
||||||
return [response, json]
|
|
||||||
}
|
|
||||||
|
|
||||||
async delete(dataSourceId: string, revId: string): Promise<Response> {
|
async delete(dataSourceId: string, revId: string): Promise<Response> {
|
||||||
const [response, json] = await this.del(
|
const [response, json] = await this.del(
|
||||||
`/datasources/${dataSourceId}/${revId}`
|
`/datasources/${dataSourceId}/${revId}`
|
||||||
|
|
|
@ -3,7 +3,7 @@ import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||||
import { PreviewQueryRequest, Query } from "@budibase/types"
|
import { PreviewQueryRequest, Query } from "@budibase/types"
|
||||||
import BaseAPI from "./BaseAPI"
|
import BaseAPI from "./BaseAPI"
|
||||||
|
|
||||||
export default class DatasourcesAPI extends BaseAPI {
|
export default class QueriesAPI extends BaseAPI {
|
||||||
constructor(client: BudibaseInternalAPIClient) {
|
constructor(client: BudibaseInternalAPIClient) {
|
||||||
super(client)
|
super(client)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ export default class DatasourcesAPI extends BaseAPI {
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
|
||||||
async get(queryId: string): Promise<[Response, any]> {
|
async getQuery(queryId: string): Promise<[Response, any]> {
|
||||||
const [response, json] = await this.get(`/queries/${queryId}`)
|
const [response, json] = await this.get(`/queries/${queryId}`)
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ export default class RowAPI extends BaseAPI {
|
||||||
}
|
}
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
async add(tableId: string, body: any): Promise<[Response, Row]> {
|
async add(tableId: string, body: Row): Promise<[Response, Row]> {
|
||||||
const [response, json] = await this.post(`/${tableId}/rows`, body)
|
const [response, json] = await this.post(`/${tableId}/rows`, body)
|
||||||
expect(json._id).toBeDefined()
|
expect(json._id).toBeDefined()
|
||||||
expect(json._rev).toBeDefined()
|
expect(json._rev).toBeDefined()
|
||||||
|
@ -27,7 +27,7 @@ export default class RowAPI extends BaseAPI {
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(tableId: string, body: any): Promise<[Response, Row[]]> {
|
async delete(tableId: string, body: Row): Promise<[Response, Row[]]> {
|
||||||
const [response, json] = await this.del(
|
const [response, json] = await this.del(
|
||||||
`/${tableId}/rows/`,
|
`/${tableId}/rows/`,
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -38,7 +38,7 @@ export default class RowAPI extends BaseAPI {
|
||||||
|
|
||||||
async searchNoPagination(
|
async searchNoPagination(
|
||||||
tableId: string,
|
tableId: string,
|
||||||
body: any
|
body: string
|
||||||
): Promise<[Response, Row[]]> {
|
): Promise<[Response, Row[]]> {
|
||||||
const [response, json] = await this.post(`/${tableId}/search`, body)
|
const [response, json] = await this.post(`/${tableId}/search`, body)
|
||||||
expect(json.hasNextPage).toEqual(false)
|
expect(json.hasNextPage).toEqual(false)
|
||||||
|
@ -47,7 +47,7 @@ export default class RowAPI extends BaseAPI {
|
||||||
|
|
||||||
async searchWithPagination(
|
async searchWithPagination(
|
||||||
tableId: string,
|
tableId: string,
|
||||||
body: any
|
body: string
|
||||||
): Promise<[Response, Row[]]> {
|
): Promise<[Response, Row[]]> {
|
||||||
const [response, json] = await this.post(`/${tableId}/search`, body)
|
const [response, json] = await this.post(`/${tableId}/search`, body)
|
||||||
expect(json.hasNextPage).toEqual(true)
|
expect(json.hasNextPage).toEqual(true)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Screen } from "@budibase/types"
|
|
||||||
import { Response } from "node-fetch"
|
import { Response } from "node-fetch"
|
||||||
|
import { Screen } from "@budibase/types"
|
||||||
|
import { ScreenRequest } from "../../../types/screens"
|
||||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||||
import BaseAPI from "./BaseAPI"
|
import BaseAPI from "./BaseAPI"
|
||||||
|
|
||||||
|
@ -8,7 +9,7 @@ export default class ScreenAPI extends BaseAPI {
|
||||||
super(client)
|
super(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(body: any): Promise<[Response, Screen]> {
|
async create(body: ScreenRequest): Promise<[Response, Screen]> {
|
||||||
const [response, json] = await this.post(`/screens`, body)
|
const [response, json] = await this.post(`/screens`, body)
|
||||||
expect(json._id).toBeDefined()
|
expect(json._id).toBeDefined()
|
||||||
expect(json.routing.roleId).toBe(body.routing.roleId)
|
expect(json.routing.roleId).toBe(body.routing.roleId)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
import { DatasourceRequest } from "../../types"
|
||||||
// Add information about the data source to the fixtures file from 1password
|
// Add information about the data source to the fixtures file from 1password
|
||||||
export const mongoDB = () => {
|
export const mongoDB = (): DatasourceRequest => {
|
||||||
return {
|
return {
|
||||||
datasource: {
|
datasource: {
|
||||||
name: "MongoDB",
|
name: "MongoDB",
|
||||||
|
@ -15,7 +16,7 @@ export const mongoDB = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const postgresSQL = () => {
|
export const postgresSQL = (): DatasourceRequest => {
|
||||||
return {
|
return {
|
||||||
datasource: {
|
datasource: {
|
||||||
name: "PostgresSQL",
|
name: "PostgresSQL",
|
||||||
|
@ -34,7 +35,7 @@ export const postgresSQL = () => {
|
||||||
fetchSchema: true,
|
fetchSchema: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const mariaDB = () => {
|
export const mariaDB = (): DatasourceRequest => {
|
||||||
return {
|
return {
|
||||||
datasource: {
|
datasource: {
|
||||||
name: "MariaDB",
|
name: "MariaDB",
|
||||||
|
@ -54,7 +55,7 @@ export const mariaDB = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const restAPI = () => {
|
export const restAPI = (): DatasourceRequest => {
|
||||||
return {
|
return {
|
||||||
datasource: {
|
datasource: {
|
||||||
name: "RestAPI",
|
name: "RestAPI",
|
||||||
|
|
|
@ -57,7 +57,7 @@ export const expectedSchemaFields = {
|
||||||
running_time_secs: "number",
|
running_time_secs: "number",
|
||||||
title: "string",
|
title: "string",
|
||||||
year: "number",
|
year: "number",
|
||||||
_id: "json",
|
_id: "string",
|
||||||
},
|
},
|
||||||
postgres: {
|
postgres: {
|
||||||
address: "string",
|
address: "string",
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { generator } from "../../shared"
|
import { generator } from "../../shared"
|
||||||
|
import { ScreenRequest } from "../../types"
|
||||||
const randomId = generator.guid()
|
const randomId = generator.guid()
|
||||||
|
|
||||||
export const generateScreen = (roleId: string): any => ({
|
export const generateScreen = (roleId: string): ScreenRequest => ({
|
||||||
showNavigation: true,
|
showNavigation: true,
|
||||||
width: "Large",
|
width: "Large",
|
||||||
name: randomId,
|
name: randomId,
|
||||||
|
|
|
@ -52,7 +52,7 @@ describe("Internal API - Data Sources: MariaDB", () => {
|
||||||
datasourcetoSave
|
datasourcetoSave
|
||||||
)
|
)
|
||||||
// Get Query
|
// Get Query
|
||||||
const [getQueryResponse, getQueryJson] = await config.api.queries.get(
|
const [getQueryResponse, getQueryJson] = await config.api.queries.getQuery(
|
||||||
<string>saveQueryJson._id
|
<string>saveQueryJson._id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ describe("Internal API - Data Sources: MongoDB", () => {
|
||||||
datasourcetoSave
|
datasourcetoSave
|
||||||
)
|
)
|
||||||
// Get Query
|
// Get Query
|
||||||
const [getQueryResponse, getQueryJson] = await config.api.queries.get(
|
const [getQueryResponse, getQueryJson] = await config.api.queries.getQuery(
|
||||||
<string>saveQueryJson._id
|
<string>saveQueryJson._id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ describe("Internal API - Data Sources: PostgresSQL", () => {
|
||||||
datasourcetoSave
|
datasourcetoSave
|
||||||
)
|
)
|
||||||
// Get Query
|
// Get Query
|
||||||
const [getQueryResponse, getQueryJson] = await config.api.queries.get(
|
const [getQueryResponse, getQueryJson] = await config.api.queries.getQuery(
|
||||||
saveQueryJson._id!
|
saveQueryJson._id!
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ describe("Internal API - Data Sources: REST API", () => {
|
||||||
datasourcetoSave
|
datasourcetoSave
|
||||||
)
|
)
|
||||||
// Get Query
|
// Get Query
|
||||||
const [getQueryResponse, getQueryJson] = await config.api.queries.get(
|
const [getQueryResponse, getQueryJson] = await config.api.queries.getQuery(
|
||||||
saveQueryJson._id!
|
saveQueryJson._id!
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
export interface DatasourceRequest {
|
||||||
|
datasource: {
|
||||||
|
name: string
|
||||||
|
plus?: boolean
|
||||||
|
source: string
|
||||||
|
type: string
|
||||||
|
config: {
|
||||||
|
connectionString?: string
|
||||||
|
db?: string
|
||||||
|
database?: string
|
||||||
|
host?: string
|
||||||
|
password?: string
|
||||||
|
port?: string
|
||||||
|
schema?: string
|
||||||
|
user?: string
|
||||||
|
defaultHeaders?: {}
|
||||||
|
rejectUnauthorized?: boolean
|
||||||
|
url?: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fetchSchema: boolean
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ export * from "./responseMessage"
|
||||||
export * from "./routing"
|
export * from "./routing"
|
||||||
export * from "./state"
|
export * from "./state"
|
||||||
export * from "./unpublishAppResponse"
|
export * from "./unpublishAppResponse"
|
||||||
export * from "./addedDatasource"
|
export * from "./screens"
|
||||||
|
export * from "./datasources"
|
||||||
// re-export public api types
|
// re-export public api types
|
||||||
export * from "@budibase/server/api/controllers/public/mapping/types"
|
export * from "@budibase/server/api/controllers/public/mapping/types"
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
export interface ScreenRequest {
|
||||||
|
showNavigation: boolean
|
||||||
|
width: string
|
||||||
|
name: string
|
||||||
|
template: string
|
||||||
|
props: ScreenProps
|
||||||
|
routing: ScreenRouting
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ScreenProps {
|
||||||
|
_id: string
|
||||||
|
_component: string
|
||||||
|
_styles: {
|
||||||
|
normal: {}
|
||||||
|
hover: {}
|
||||||
|
active: {}
|
||||||
|
selected: {}
|
||||||
|
}
|
||||||
|
_children: []
|
||||||
|
_instanceName: string
|
||||||
|
direction: string
|
||||||
|
hAlign: string
|
||||||
|
vAlign: string
|
||||||
|
size: string
|
||||||
|
gap: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ScreenRouting {
|
||||||
|
route: string
|
||||||
|
roleId: string
|
||||||
|
homeScreen: boolean
|
||||||
|
}
|
Loading…
Reference in New Issue