Merge pull request #11347 from Budibase/chore/jest_improvements

Chore - Jest improvements and clean-ups
This commit is contained in:
Adria Navarro 2023-07-28 16:58:58 +01:00 committed by GitHub
commit 0bd9141cbc
38 changed files with 1001 additions and 2218 deletions

View File

@ -1,2 +1,3 @@
nodejs 14.21.3
python 3.10.0
python 3.10.0
yarn 1.22.19

View File

@ -1,8 +1,6 @@
import { Config } from "@jest/types"
const preset = require("ts-jest/jest-preset")
const baseConfig: Config.InitialProjectOptions = {
...preset,
preset: "@trendyol/jest-testcontainers",
setupFiles: ["./tests/jestEnv.ts"],
setupFilesAfterEnv: ["./tests/jestSetup.ts"],

View File

@ -23,7 +23,6 @@
"@budibase/nano": "10.1.2",
"@budibase/pouchdb-replication-stream": "1.2.10",
"@budibase/types": "0.0.0",
"@shopify/jest-koa-mocks": "5.0.1",
"@techpass/passport-openidconnect": "0.3.2",
"aws-cloudfront-sign": "2.2.0",
"aws-sdk": "2.1030.0",
@ -58,12 +57,13 @@
"uuid": "8.3.2"
},
"devDependencies": {
"@jest/test-sequencer": "29.5.0",
"@swc/core": "^1.3.25",
"@swc/jest": "^0.2.24",
"@jest/test-sequencer": "29.6.2",
"@shopify/jest-koa-mocks": "5.1.1",
"@swc/core": "1.3.71",
"@swc/jest": "0.2.27",
"@trendyol/jest-testcontainers": "^2.1.1",
"@types/chance": "1.1.3",
"@types/jest": "29.5.0",
"@types/jest": "29.5.3",
"@types/koa": "2.13.4",
"@types/lodash": "4.14.180",
"@types/node": "14.18.20",
@ -75,15 +75,14 @@
"@types/uuid": "8.3.4",
"chance": "1.1.8",
"ioredis-mock": "8.7.0",
"jest": "29.5.0",
"jest-environment-node": "29.5.0",
"jest-serial-runner": "^1.2.1",
"jest": "29.6.2",
"jest-environment-node": "29.6.2",
"jest-serial-runner": "1.2.1",
"koa": "2.13.4",
"nodemon": "2.0.16",
"pino-pretty": "10.0.0",
"pouchdb-adapter-memory": "7.2.2",
"timekeeper": "2.2.0",
"ts-jest": "29.0.5",
"ts-node": "10.8.1",
"tsconfig-paths": "4.0.0",
"typescript": "4.7.3"

View File

@ -8,6 +8,6 @@ then
jest --coverage --runInBand --forceExit
else
# --maxWorkers performs better in development
echo "jest --coverage --forceExit"
jest --coverage --forceExit
echo "jest --coverage --detectOpenHandles"
jest --coverage --detectOpenHandles
fi

View File

@ -1,5 +1,5 @@
const { flatten } = require("lodash")
const { cloneDeep } = require("lodash/fp")
import flatten from "lodash/flatten"
import cloneDeep from "lodash/fp/cloneDeep"
export type RoleHierarchy = {
permissionId: string

View File

@ -3,7 +3,7 @@ import { prefixRoleID, getRoleParams, DocumentType, SEPARATOR } from "../db"
import { getAppDB } from "../context"
import { doWithDB } from "../db"
import { Screen, Role as RoleDoc } from "@budibase/types"
const { cloneDeep } = require("lodash/fp")
import cloneDeep from "lodash/fp/cloneDeep"
export const BUILTIN_ROLE_IDS = {
ADMIN: "ADMIN",

View File

@ -1,4 +1,4 @@
import { cloneDeep } from "lodash"
import cloneDeep from "lodash/cloneDeep"
import * as permissions from "../permissions"
import { BUILTIN_ROLE_IDS } from "../roles"

View File

@ -1,5 +1,5 @@
import { Feature, License, Quotas } from "@budibase/types"
import _ from "lodash"
import cloneDeep from "lodash/cloneDeep"
let CLOUD_FREE_LICENSE: License
let UNLIMITED_LICENSE: License
@ -58,7 +58,7 @@ export const useCloudFree = () => {
// FEATURES
const useFeature = (feature: Feature) => {
const license = _.cloneDeep(UNLIMITED_LICENSE)
const license = cloneDeep(UNLIMITED_LICENSE)
const opts: UseLicenseOpts = {
features: [feature],
}
@ -97,7 +97,7 @@ export const useSyncAutomations = () => {
// QUOTAS
export const setAutomationLogsQuota = (value: number) => {
const license = _.cloneDeep(UNLIMITED_LICENSE)
const license = cloneDeep(UNLIMITED_LICENSE)
license.quotas.constant.automationLogRetentionDays.value = value
return useLicense(license)
}

View File

@ -11,7 +11,7 @@ import {
CreateAccount,
CreatePassswordAccount,
} from "@budibase/types"
import _ from "lodash"
import sample from "lodash/sample"
export const account = (partial: Partial<Account> = {}): Account => {
return {
@ -46,13 +46,11 @@ export const cloudAccount = (): CloudAccount => {
}
function providerType(): AccountSSOProviderType {
return _.sample(
Object.values(AccountSSOProviderType)
) as AccountSSOProviderType
return sample(Object.values(AccountSSOProviderType)) as AccountSSOProviderType
}
function provider(): AccountSSOProvider {
return _.sample(Object.values(AccountSSOProvider)) as AccountSSOProvider
return sample(Object.values(AccountSSOProvider)) as AccountSSOProvider
}
export function ssoAccount(account: Account = cloudAccount()): SSOAccount {

View File

@ -1,7 +1,6 @@
import { ScimCreateGroupRequest, ScimCreateUserRequest } from "@budibase/types"
import { uuid } from "./common"
import { generator } from "./generator"
import _ from "lodash"
interface CreateUserRequestFields {
externalId: string
@ -20,10 +19,10 @@ export function createUserRequest(userData?: Partial<CreateUserRequestFields>) {
username: generator.name(),
}
const { externalId, email, firstName, lastName, username } = _.assign(
defaultValues,
userData
)
const { externalId, email, firstName, lastName, username } = {
...defaultValues,
...userData,
}
let user: ScimCreateUserRequest = {
schemas: [

View File

@ -15,7 +15,7 @@ import { generator } from "./generator"
import { email, uuid } from "./common"
import * as shared from "./shared"
import { user } from "./shared"
import _ from "lodash"
import sample from "lodash/sample"
export function OAuth(): OAuth2 {
return {
@ -47,7 +47,7 @@ export function authDetails(userDoc?: User): SSOAuthDetails {
}
export function providerType(): SSOProviderType {
return _.sample(Object.values(SSOProviderType)) as SSOProviderType
return sample(Object.values(SSOProviderType)) as SSOProviderType
}
export function ssoProfile(user?: User): SSOProfile {

View File

@ -101,14 +101,14 @@
"@rollup/plugin-replace": "^2.4.2",
"@roxi/routify": "2.18.5",
"@sveltejs/vite-plugin-svelte": "1.0.1",
"@testing-library/jest-dom": "^5.11.10",
"@testing-library/jest-dom": "5.17.0",
"@testing-library/svelte": "^3.2.2",
"babel-jest": "^26.6.3",
"babel-jest": "29.6.2",
"cypress": "^9.3.1",
"cypress-multi-reporters": "^1.6.0",
"cypress-terminal-report": "^1.4.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.6.3",
"jest": "29.6.2",
"jsdom": "^21.1.1",
"mochawesome": "^7.1.3",
"mochawesome-merge": "^4.2.1",

View File

@ -53,9 +53,9 @@
"yaml": "^2.1.1"
},
"devDependencies": {
"@swc/core": "^1.3.25",
"@swc/jest": "^0.2.24",
"@types/jest": "^29.4.0",
"@swc/core": "1.3.71",
"@swc/jest": "0.2.27",
"@types/jest": "29.5.3",
"@types/node-fetch": "2.6.1",
"@types/pouchdb": "^6.4.0",
"copyfiles": "^2.4.1",

@ -1 +1 @@
Subproject commit a60183319f410d05aaa1c2f2718b772978b54d64
Subproject commit 63fa1b15f6e2afa8a264d597157fd798c9ce031c

View File

@ -2,10 +2,8 @@ import { Config } from "@jest/types"
import * as fs from "fs"
import { join } from "path"
const preset = require("ts-jest/jest-preset")
const baseConfig: Config.InitialProjectOptions = {
...preset,
preset: "@trendyol/jest-testcontainers",
setupFiles: ["./src/tests/jestEnv.ts"],
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],

View File

@ -131,15 +131,15 @@
"@babel/core": "7.17.4",
"@babel/preset-env": "7.16.11",
"@budibase/standard-components": "^0.9.139",
"@jest/test-sequencer": "29.5.0",
"@swc/core": "^1.3.25",
"@swc/jest": "^0.2.24",
"@trendyol/jest-testcontainers": "^2.1.1",
"@jest/test-sequencer": "29.6.2",
"@swc/core": "1.3.71",
"@swc/jest": "0.2.27",
"@trendyol/jest-testcontainers": "2.1.1",
"@types/apidoc": "0.50.0",
"@types/bson": "4.2.0",
"@types/global-agent": "2.1.1",
"@types/google-spreadsheet": "3.1.5",
"@types/jest": "29.5.0",
"@types/jest": "29.5.3",
"@types/koa": "2.13.4",
"@types/koa__router": "8.0.8",
"@types/lodash": "4.14.180",
@ -155,15 +155,15 @@
"@types/tar": "6.1.5",
"@typescript-eslint/parser": "5.45.0",
"apidoc": "0.50.4",
"babel-jest": "29.5.0",
"babel-jest": "29.6.2",
"copyfiles": "2.4.1",
"docker-compose": "0.23.17",
"eslint": "6.8.0",
"is-wsl": "2.2.0",
"jest": "29.5.0",
"jest": "29.6.2",
"jest-openapi": "0.14.2",
"jest-runner": "29.5.0",
"jest-serial-runner": "^1.2.1",
"jest-runner": "29.6.2",
"jest-serial-runner": "1.2.1",
"nodemon": "2.0.15",
"openapi-types": "9.3.1",
"openapi-typescript": "5.2.0",
@ -172,7 +172,6 @@
"supertest": "6.2.2",
"swagger-jsdoc": "6.1.0",
"timekeeper": "2.2.0",
"ts-jest": "29.0.5",
"ts-node": "10.8.1",
"tsconfig-paths": "4.0.0",
"typescript": "4.7.3",

View File

@ -9,7 +9,7 @@ import { context } from "@budibase/backend-core"
import { Table, Row } from "@budibase/types"
import * as linkRows from "../../../db/linkedRows"
import sdk from "../../../sdk"
import { isEqual } from "lodash"
import isEqual from "lodash/isEqual"
import { cloneDeep } from "lodash/fp"
/**

View File

@ -2,7 +2,8 @@ import { FieldTypes, FormulaTypes } from "../../../constants"
import { clearColumns } from "./utils"
import { doesContainStrings } from "@budibase/string-templates"
import { cloneDeep } from "lodash/fp"
import { isEqual, uniq } from "lodash"
import isEqual from "lodash/isEqual"
import uniq from "lodash/uniq"
import { updateAllFormulasInTable } from "../row/staticFormula"
import { context } from "@budibase/backend-core"
import { FieldSchema, Table } from "@budibase/types"

View File

@ -11,7 +11,7 @@ import {
import { runStaticFormulaChecks } from "./bulkFormula"
import { Table } from "@budibase/types"
import { quotas } from "@budibase/pro"
import { isEqual } from "lodash"
import isEqual from "lodash/isEqual"
import { cloneDeep } from "lodash/fp"
import sdk from "../../../sdk"

View File

@ -1,6 +1,6 @@
import { parse, isSchema, isRows } from "../../../utilities/schema"
import { getRowParams, generateRowID, InternalTables } from "../../../db/utils"
import { isEqual } from "lodash"
import isEqual from "lodash/isEqual"
import {
AutoFieldSubTypes,
FieldTypes,

View File

@ -17,7 +17,8 @@ import {
} from "@budibase/types"
import { builderSocket } from "../../../websockets"
const { cloneDeep, isEqual } = require("lodash")
const cloneDeep = require("lodash/cloneDeep")
import isEqual from "lodash/isEqual"
export async function fetch(ctx: Ctx) {
ctx.body = await getViews()

View File

@ -4,6 +4,7 @@ jest.mock("../../utilities/redis", () => ({
checkTestFlag: () => {
return false
},
shutdown: jest.fn(),
}))
jest.spyOn(global.console, "error")

View File

@ -1,4 +1,4 @@
import { merge } from "lodash"
import merge from "lodash/merge"
import env from "../environment"
export const AWS_REGION = env.AWS_REGION ? env.AWS_REGION : "eu-west-1"

View File

@ -8,10 +8,10 @@ import {
getLinkedTableIDs,
getLinkedTable,
} from "./linkUtils"
import { flatten } from "lodash"
import flatten from "lodash/flatten"
import { FieldTypes } from "../../constants"
import { getMultiIDParams, USER_METDATA_PREFIX } from "../utils"
import { partition } from "lodash"
import partition from "lodash/partition"
import { getGlobalUsersFromMetadata } from "../../utilities/global"
import { processFormulas } from "../../utilities/rowProcessor"
import { context } from "@budibase/backend-core"

View File

@ -17,7 +17,7 @@ import oracle from "./oracle"
import { SourceName, Integration, PluginType } from "@budibase/types"
import { getDatasourcePlugin } from "../utilities/fileSystem"
import env from "../environment"
import { cloneDeep } from "lodash"
import cloneDeep from "lodash/cloneDeep"
import sdk from "../sdk"
const DEFINITIONS: Record<SourceName, Integration | undefined> = {
@ -54,7 +54,6 @@ const INTEGRATIONS: Record<SourceName, any> = {
[SourceName.FIRESTORE]: firebase.integration,
[SourceName.GOOGLE_SHEETS]: googlesheets.integration,
[SourceName.REDIS]: redis.integration,
[SourceName.FIRESTORE]: firebase.integration,
[SourceName.SNOWFLAKE]: snowflake.integration,
[SourceName.ORACLE]: undefined,
}

View File

@ -11,7 +11,7 @@ import {
RestBasicAuthConfig,
RestBearerAuthConfig,
} from "@budibase/types"
import { get } from "lodash"
import get from "lodash/get"
import * as https from "https"
import qs from "querystring"
import fetch from "node-fetch"

View File

@ -15,7 +15,7 @@ import {
import { cloneDeep } from "lodash/fp"
import { getEnvironmentVariables } from "../../utils"
import { getDefinitions, getDefinition } from "../../../integrations"
import _ from "lodash"
import merge from "lodash/merge"
import {
BudibaseInternalDB,
getDatasourceParams,
@ -227,7 +227,7 @@ export function mergeConfigs(update: Datasource, old: Datasource) {
}
if (old.config?.auth) {
update.config = _.merge(old.config, update.config)
update.config = merge(old.config, update.config)
}
// update back to actual passwords for everything else

View File

@ -14,7 +14,6 @@ import {
import datasources from "../datasources"
import { populateExternalTableSchemas, isEditableColumn } from "./validation"
import sdk from "../../../sdk"
import _ from "lodash"
async function getAllInternalTables(db?: Database): Promise<Table[]> {
if (!db) {

View File

@ -3,7 +3,7 @@ import { TableSchema, UIFieldMetadata, View, ViewV2 } from "@budibase/types"
import sdk from "../../../sdk"
import * as utils from "../../../db/utils"
import _ from "lodash"
import merge from "lodash/merge"
export async function get(viewId: string): Promise<ViewV2 | undefined> {
const { tableId } = utils.extractViewInfoFromID(viewId)
@ -103,7 +103,7 @@ function enrichViewV2Schema(
delete tableFieldSchema.order
}
result[columnName] = _.merge(tableFieldSchema, columnUIMetadata)
result[columnName] = merge(tableFieldSchema, columnUIMetadata)
}
return result
}

View File

@ -6,7 +6,7 @@ import {
getUserMetadataParams,
InternalTables,
} from "../../db/utils"
import { isEqual } from "lodash"
import isEqual from "lodash/isEqual"
import { ContextUser, UserMetadata, User, Database } from "@budibase/types"
export function combineMetadataAndUser(

View File

@ -9,7 +9,7 @@ import {
import env from "../environment"
import { groups } from "@budibase/pro"
import { UserCtx, ContextUser, User, UserGroup } from "@budibase/types"
import { cloneDeep } from "lodash"
import cloneDeep from "lodash/cloneDeep"
export function updateAppRole(
user: ContextUser,

View File

@ -36,8 +36,8 @@
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-json": "^4.1.0",
"doctrine": "^3.0.0",
"jest": "^26.6.3",
"jest-environment-node": "^26.6.2",
"jest": "29.6.2",
"jest-environment-node": "29.6.2",
"marked": "^4.0.10",
"rollup": "^2.36.2",
"rollup-plugin-inject-process-env": "^1.3.1",

View File

@ -1,9 +1,7 @@
import { Config } from "@jest/types"
import * as fs from "fs"
const preset = require("ts-jest/jest-preset")
const config: Config.InitialOptions = {
...preset,
preset: "@trendyol/jest-testcontainers",
setupFiles: ["./src/tests/jestEnv.ts"],
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],

View File

@ -74,10 +74,10 @@
"server-destroy": "1.0.1"
},
"devDependencies": {
"@swc/core": "^1.3.25",
"@swc/jest": "^0.2.24",
"@trendyol/jest-testcontainers": "^2.1.1",
"@types/jest": "28.1.1",
"@swc/core": "1.3.71",
"@swc/jest": "0.2.27",
"@trendyol/jest-testcontainers": "2.1.1",
"@types/jest": "29.5.3",
"@types/jsonwebtoken": "8.5.1",
"@types/koa": "2.13.4",
"@types/koa__router": "8.0.8",
@ -91,14 +91,13 @@
"@typescript-eslint/parser": "5.45.0",
"copyfiles": "2.4.1",
"eslint": "6.8.0",
"jest": "28.1.1",
"jest": "29.6.2",
"lodash": "4.17.21",
"nodemon": "2.0.15",
"pouchdb-adapter-memory": "7.2.2",
"rimraf": "3.0.2",
"supertest": "6.2.2",
"timekeeper": "2.2.0",
"ts-jest": "28.0.4",
"ts-node": "10.8.1",
"tsconfig-paths": "4.0.0",
"typescript": "4.7.3",

View File

@ -314,7 +314,7 @@ describe("scim", () => {
const user = await config.getUser(email)
expect(user).toBeDefined()
expect(user.email).toEqual(email)
expect(user!.email).toEqual(email)
})
it("if multiple emails are provided, the first primary one is used as email", async () => {
@ -345,7 +345,7 @@ describe("scim", () => {
const user = await config.getUser(email)
expect(user).toBeDefined()
expect(user.email).toEqual(email)
expect(user!.email).toEqual(email)
})
it("if no email is provided and the user name is not an email, an exception is thrown", async () => {

View File

@ -24,18 +24,18 @@
},
"devDependencies": {
"@budibase/types": "^2.3.17",
"@trendyol/jest-testcontainers": "^2.1.1",
"@types/jest": "29.0.0",
"@trendyol/jest-testcontainers": "2.1.1",
"@types/jest": "29.5.3",
"@types/node-fetch": "2.6.2",
"chance": "1.1.8",
"dotenv": "16.0.1",
"jest": "29.0.0",
"jest": "29.6.2",
"prettier": "2.7.1",
"start-server-and-test": "1.14.0",
"@swc/core": "^1.3.25",
"@swc/jest": "^0.2.24",
"@swc/core": "1.3.71",
"@swc/jest": "0.2.27",
"timekeeper": "2.2.0",
"ts-jest": "29.0.0",
"ts-jest": "29.1.1",
"ts-node": "10.8.1",
"tsconfig-paths": "4.0.0",
"typescript": "4.7.3"

File diff suppressed because it is too large Load Diff

2241
yarn.lock

File diff suppressed because it is too large Load Diff