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
|
||||
routing: ScreenRouting
|
||||
props: ScreenProps
|
||||
name?: string
|
||||
}
|
||||
|
|
|
@ -5,10 +5,15 @@ import {
|
|||
AppPackageResponse,
|
||||
DeployConfig,
|
||||
MessageResponse,
|
||||
CreateAppRequest,
|
||||
} from "../../../types"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
|
||||
interface RenameAppBody {
|
||||
name: string
|
||||
}
|
||||
|
||||
export default class AppAPI extends BaseAPI {
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
super(client)
|
||||
|
@ -46,7 +51,7 @@ export default class AppAPI extends BaseAPI {
|
|||
return [response, json]
|
||||
}
|
||||
|
||||
async create(body: any): Promise<App> {
|
||||
async create(body: CreateAppRequest): Promise<App> {
|
||||
const [response, json] = await this.post(`/applications`, body)
|
||||
expect(json._id).toBeDefined()
|
||||
return json
|
||||
|
@ -100,18 +105,13 @@ export default class AppAPI extends BaseAPI {
|
|||
async rename(
|
||||
appId: string,
|
||||
oldName: string,
|
||||
body: any
|
||||
body: RenameAppBody
|
||||
): Promise<[Response, App]> {
|
||||
const [response, json] = await this.put(`/applications/${appId}`, body)
|
||||
expect(json.name).not.toEqual(oldName)
|
||||
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]> {
|
||||
const [response, json] = await this.get(`/routing`)
|
||||
if (screenExists) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import {
|
|||
} from "@budibase/types"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
import { DatasourceRequest } from "../../../types"
|
||||
|
||||
export default class DatasourcesAPI extends BaseAPI {
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
|
@ -31,7 +32,9 @@ export default class DatasourcesAPI extends BaseAPI {
|
|||
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)
|
||||
expect(json.datasource._id).toBeDefined()
|
||||
expect(json.datasource._rev).toBeDefined()
|
||||
|
@ -39,7 +42,9 @@ export default class DatasourcesAPI extends BaseAPI {
|
|||
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)
|
||||
expect(json.datasource._id).toBeDefined()
|
||||
expect(json.datasource._rev).toBeDefined()
|
||||
|
@ -47,28 +52,6 @@ export default class DatasourcesAPI extends BaseAPI {
|
|||
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> {
|
||||
const [response, json] = await this.del(
|
||||
`/datasources/${dataSourceId}/${revId}`
|
||||
|
|
|
@ -3,7 +3,7 @@ import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
|||
import { PreviewQueryRequest, Query } from "@budibase/types"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
|
||||
export default class DatasourcesAPI extends BaseAPI {
|
||||
export default class QueriesAPI extends BaseAPI {
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
super(client)
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ export default class DatasourcesAPI extends BaseAPI {
|
|||
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}`)
|
||||
return [response, json]
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ export default class RowAPI extends BaseAPI {
|
|||
}
|
||||
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)
|
||||
expect(json._id).toBeDefined()
|
||||
expect(json._rev).toBeDefined()
|
||||
|
@ -27,7 +27,7 @@ export default class RowAPI extends BaseAPI {
|
|||
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(
|
||||
`/${tableId}/rows/`,
|
||||
undefined,
|
||||
|
@ -38,7 +38,7 @@ export default class RowAPI extends BaseAPI {
|
|||
|
||||
async searchNoPagination(
|
||||
tableId: string,
|
||||
body: any
|
||||
body: string
|
||||
): Promise<[Response, Row[]]> {
|
||||
const [response, json] = await this.post(`/${tableId}/search`, body)
|
||||
expect(json.hasNextPage).toEqual(false)
|
||||
|
@ -47,7 +47,7 @@ export default class RowAPI extends BaseAPI {
|
|||
|
||||
async searchWithPagination(
|
||||
tableId: string,
|
||||
body: any
|
||||
body: string
|
||||
): Promise<[Response, Row[]]> {
|
||||
const [response, json] = await this.post(`/${tableId}/search`, body)
|
||||
expect(json.hasNextPage).toEqual(true)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Screen } from "@budibase/types"
|
||||
import { Response } from "node-fetch"
|
||||
import { Screen } from "@budibase/types"
|
||||
import { ScreenRequest } from "../../../types/screens"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
|
||||
|
@ -8,7 +9,7 @@ export default class ScreenAPI extends BaseAPI {
|
|||
super(client)
|
||||
}
|
||||
|
||||
async create(body: any): Promise<[Response, Screen]> {
|
||||
async create(body: ScreenRequest): Promise<[Response, Screen]> {
|
||||
const [response, json] = await this.post(`/screens`, body)
|
||||
expect(json._id).toBeDefined()
|
||||
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
|
||||
export const mongoDB = () => {
|
||||
export const mongoDB = (): DatasourceRequest => {
|
||||
return {
|
||||
datasource: {
|
||||
name: "MongoDB",
|
||||
|
@ -15,7 +16,7 @@ export const mongoDB = () => {
|
|||
}
|
||||
}
|
||||
|
||||
export const postgresSQL = () => {
|
||||
export const postgresSQL = (): DatasourceRequest => {
|
||||
return {
|
||||
datasource: {
|
||||
name: "PostgresSQL",
|
||||
|
@ -34,7 +35,7 @@ export const postgresSQL = () => {
|
|||
fetchSchema: true,
|
||||
}
|
||||
}
|
||||
export const mariaDB = () => {
|
||||
export const mariaDB = (): DatasourceRequest => {
|
||||
return {
|
||||
datasource: {
|
||||
name: "MariaDB",
|
||||
|
@ -54,7 +55,7 @@ export const mariaDB = () => {
|
|||
}
|
||||
}
|
||||
|
||||
export const restAPI = () => {
|
||||
export const restAPI = (): DatasourceRequest => {
|
||||
return {
|
||||
datasource: {
|
||||
name: "RestAPI",
|
||||
|
|
|
@ -57,7 +57,7 @@ export const expectedSchemaFields = {
|
|||
running_time_secs: "number",
|
||||
title: "string",
|
||||
year: "number",
|
||||
_id: "json",
|
||||
_id: "string",
|
||||
},
|
||||
postgres: {
|
||||
address: "string",
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { generator } from "../../shared"
|
||||
|
||||
import { ScreenRequest } from "../../types"
|
||||
const randomId = generator.guid()
|
||||
|
||||
export const generateScreen = (roleId: string): any => ({
|
||||
export const generateScreen = (roleId: string): ScreenRequest => ({
|
||||
showNavigation: true,
|
||||
width: "Large",
|
||||
name: randomId,
|
||||
|
|
|
@ -52,7 +52,7 @@ describe("Internal API - Data Sources: MariaDB", () => {
|
|||
datasourcetoSave
|
||||
)
|
||||
// Get Query
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.get(
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.getQuery(
|
||||
<string>saveQueryJson._id
|
||||
)
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ describe("Internal API - Data Sources: MongoDB", () => {
|
|||
datasourcetoSave
|
||||
)
|
||||
// Get Query
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.get(
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.getQuery(
|
||||
<string>saveQueryJson._id
|
||||
)
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ describe("Internal API - Data Sources: PostgresSQL", () => {
|
|||
datasourcetoSave
|
||||
)
|
||||
// Get Query
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.get(
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.getQuery(
|
||||
saveQueryJson._id!
|
||||
)
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ describe("Internal API - Data Sources: REST API", () => {
|
|||
datasourcetoSave
|
||||
)
|
||||
// Get Query
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.get(
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.getQuery(
|
||||
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 "./state"
|
||||
export * from "./unpublishAppResponse"
|
||||
export * from "./addedDatasource"
|
||||
|
||||
export * from "./screens"
|
||||
export * from "./datasources"
|
||||
// re-export public api 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