@budibase/backend-core 2.30.2 → 2.30.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/index.js +371 -169
  2. package/dist/index.js.map +3 -3
  3. package/dist/index.js.meta.json +1 -1
  4. package/dist/package.json +5 -5
  5. package/dist/plugins.js +1 -0
  6. package/dist/plugins.js.map +2 -2
  7. package/dist/plugins.js.meta.json +1 -1
  8. package/dist/src/context/mainContext.d.ts +2 -0
  9. package/dist/src/context/mainContext.js +19 -0
  10. package/dist/src/context/mainContext.js.map +1 -1
  11. package/dist/src/context/types.d.ts +3 -0
  12. package/dist/src/environment.d.ts +4 -0
  13. package/dist/src/environment.js +27 -1
  14. package/dist/src/environment.js.map +1 -1
  15. package/dist/src/events/processors/posthog/PosthogProcessor.d.ts +1 -1
  16. package/dist/src/events/processors/posthog/PosthogProcessor.js +2 -2
  17. package/dist/src/events/processors/posthog/PosthogProcessor.js.map +1 -1
  18. package/dist/src/features/index.d.ts +30 -28
  19. package/dist/src/features/index.js +200 -79
  20. package/dist/src/features/index.js.map +1 -1
  21. package/dist/src/index.d.ts +3 -1
  22. package/dist/src/index.js +3 -1
  23. package/dist/src/index.js.map +1 -1
  24. package/dist/src/redis/redis.d.ts +1 -0
  25. package/dist/src/redis/redis.js +4 -0
  26. package/dist/src/redis/redis.js.map +1 -1
  27. package/dist/src/security/auth.js +1 -1
  28. package/dist/src/security/auth.js.map +1 -1
  29. package/dist/src/sql/sqlTable.js +23 -8
  30. package/dist/src/sql/sqlTable.js.map +1 -1
  31. package/dist/tests/core/utilities/mocks/index.d.ts +0 -2
  32. package/dist/tests/core/utilities/mocks/index.js +1 -7
  33. package/dist/tests/core/utilities/mocks/index.js.map +1 -1
  34. package/dist/tests/core/utilities/structures/users.js +1 -1
  35. package/dist/tests/core/utilities/structures/users.js.map +1 -1
  36. package/dist/tests/jestSetup.js +7 -2
  37. package/dist/tests/jestSetup.js.map +1 -1
  38. package/package.json +5 -5
  39. package/src/context/mainContext.ts +19 -0
  40. package/src/context/tests/index.spec.ts +1 -1
  41. package/src/context/types.ts +3 -0
  42. package/src/environment.ts +29 -0
  43. package/src/events/processors/posthog/PosthogProcessor.ts +1 -1
  44. package/src/events/processors/posthog/tests/PosthogProcessor.spec.ts +16 -22
  45. package/src/features/index.ts +242 -80
  46. package/src/features/tests/features.spec.ts +209 -63
  47. package/src/index.ts +1 -1
  48. package/src/middleware/passport/sso/tests/oidc.spec.ts +4 -12
  49. package/src/middleware/passport/sso/tests/sso.spec.ts +10 -12
  50. package/src/plugin/tests/validation.spec.ts +168 -42
  51. package/src/redis/redis.ts +4 -0
  52. package/src/redis/tests/redis.spec.ts +6 -3
  53. package/src/security/auth.ts +1 -1
  54. package/src/security/tests/auth.spec.ts +2 -2
  55. package/src/sql/sqlTable.ts +21 -7
  56. package/tests/core/utilities/mocks/index.ts +0 -2
  57. package/tests/core/utilities/structures/users.ts +1 -1
  58. package/tests/jestSetup.ts +10 -3
  59. package/dist/tests/core/utilities/mocks/fetch.d.ts +0 -32
  60. package/dist/tests/core/utilities/mocks/fetch.js +0 -15
  61. package/dist/tests/core/utilities/mocks/fetch.js.map +0 -1
  62. package/dist/tests/core/utilities/mocks/posthog.d.ts +0 -0
  63. package/dist/tests/core/utilities/mocks/posthog.js +0 -9
  64. package/dist/tests/core/utilities/mocks/posthog.js.map +0 -1
  65. package/tests/core/utilities/mocks/fetch.ts +0 -17
  66. package/tests/core/utilities/mocks/posthog.ts +0 -7
@@ -1,4 +1,4 @@
1
- import { generator, mocks, structures } from "../../../../../tests"
1
+ import { generator, structures } from "../../../../../tests"
2
2
  import {
3
3
  JwtClaims,
4
4
  OIDCInnerConfig,
@@ -7,6 +7,7 @@ import {
7
7
  } from "@budibase/types"
8
8
  import * as _sso from "../sso"
9
9
  import * as oidc from "../oidc"
10
+ import nock from "nock"
10
11
 
11
12
  jest.mock("@techpass/passport-openidconnect")
12
13
  const mockStrategy = require("@techpass/passport-openidconnect").Strategy
@@ -22,16 +23,9 @@ describe("oidc", () => {
22
23
  const oidcConfig: OIDCInnerConfig = structures.sso.oidcConfig()
23
24
  const wellKnownConfig = structures.sso.oidcWellKnownConfig()
24
25
 
25
- function mockRetrieveWellKnownConfig() {
26
- // mock the request to retrieve the oidc configuration
27
- mocks.fetch.mockReturnValue({
28
- ok: true,
29
- json: () => wellKnownConfig,
30
- })
31
- }
32
-
33
26
  beforeEach(() => {
34
- mockRetrieveWellKnownConfig()
27
+ nock.cleanAll()
28
+ nock(oidcConfig.configUrl).get("/").reply(200, wellKnownConfig)
35
29
  })
36
30
 
37
31
  describe("strategyFactory", () => {
@@ -42,8 +36,6 @@ describe("oidc", () => {
42
36
  )
43
37
  await oidc.strategyFactory(strategyConfiguration, mockSaveUser)
44
38
 
45
- expect(mocks.fetch).toHaveBeenCalledWith(oidcConfig.configUrl)
46
-
47
39
  const expectedOptions = {
48
40
  issuer: wellKnownConfig.issuer,
49
41
  authorizationURL: wellKnownConfig.authorization_endpoint,
@@ -1,10 +1,11 @@
1
- import { structures, mocks } from "../../../../../tests"
1
+ import { structures } from "../../../../../tests"
2
2
  import { testEnv } from "../../../../../tests/extra"
3
3
  import { SSOAuthDetails, User } from "@budibase/types"
4
4
 
5
5
  import { HTTPError } from "../../../../errors"
6
6
  import * as sso from "../sso"
7
7
  import * as context from "../../../../context"
8
+ import nock from "nock"
8
9
 
9
10
  const mockDone = jest.fn()
10
11
  const mockSaveUser = jest.fn()
@@ -23,6 +24,7 @@ describe("sso", () => {
23
24
  beforeEach(() => {
24
25
  jest.clearAllMocks()
25
26
  testEnv.singleTenant()
27
+ nock.cleanAll()
26
28
  })
27
29
 
28
30
  describe("validation", () => {
@@ -51,15 +53,6 @@ describe("sso", () => {
51
53
  })
52
54
  })
53
55
 
54
- function mockGetProfilePicture() {
55
- mocks.fetch.mockReturnValueOnce(
56
- Promise.resolve({
57
- status: 200,
58
- headers: { get: () => "image/" },
59
- })
60
- )
61
- }
62
-
63
56
  describe("when the user doesn't exist", () => {
64
57
  let user: User
65
58
  let details: SSOAuthDetails
@@ -68,7 +61,10 @@ describe("sso", () => {
68
61
  users.getById.mockImplementationOnce(() => {
69
62
  throw new HTTPError("", 404)
70
63
  })
71
- mockGetProfilePicture()
64
+
65
+ nock("http://example.com").get("/").reply(200, undefined, {
66
+ "Content-Type": "image/png",
67
+ })
72
68
 
73
69
  user = structures.users.user()
74
70
  delete user._rev
@@ -131,7 +127,9 @@ describe("sso", () => {
131
127
  existingUser = structures.users.user()
132
128
  existingUser._id = structures.uuid()
133
129
  details = structures.sso.authDetails(existingUser)
134
- mockGetProfilePicture()
130
+ nock("http://example.com").get("/").reply(200, undefined, {
131
+ "Content-Type": "image/png",
132
+ })
135
133
  })
136
134
 
137
135
  describe("exists by email", () => {
@@ -1,12 +1,129 @@
1
1
  import { validate } from "../utils"
2
2
  import fetch from "node-fetch"
3
3
  import { PluginType } from "@budibase/types"
4
+ import nock from "nock"
4
5
 
5
- const repoUrl =
6
- "https://raw.githubusercontent.com/Budibase/budibase-skeleton/master"
7
- const automationLink = `${repoUrl}/automation/schema.json.hbs`
8
- const componentLink = `${repoUrl}/component/schema.json.hbs`
9
- const datasourceLink = `${repoUrl}/datasource/schema.json.hbs`
6
+ const automationLink = `http://example.com/automation/schema.json`
7
+ const componentLink = `http://example.com/component/schema.json`
8
+ const datasourceLink = `http://example.com/datasource/schema.json`
9
+
10
+ function mockDatasourceSchema() {
11
+ nock("http://example.com")
12
+ .get("/datasource/schema.json")
13
+ .reply(200, {
14
+ type: "datasource",
15
+ metadata: {},
16
+ schema: {
17
+ docs: "https://docs.budibase.com",
18
+ friendlyName: "Basic HTTP",
19
+ type: "API",
20
+ description: "Performs a basic HTTP calls to a URL",
21
+ datasource: {
22
+ url: {
23
+ type: "string",
24
+ required: true,
25
+ },
26
+ cookie: {
27
+ type: "string",
28
+ required: false,
29
+ },
30
+ },
31
+ query: {
32
+ create: {
33
+ type: "json",
34
+ },
35
+ read: {
36
+ type: "fields",
37
+ fields: {
38
+ queryString: {
39
+ display: "Query string",
40
+ type: "string",
41
+ required: false,
42
+ },
43
+ },
44
+ },
45
+ update: {
46
+ type: "json",
47
+ },
48
+ delete: {
49
+ type: "fields",
50
+ fields: {
51
+ id: {
52
+ type: "string",
53
+ required: true,
54
+ },
55
+ },
56
+ },
57
+ },
58
+ },
59
+ })
60
+ }
61
+
62
+ function mockAutomationSchema() {
63
+ nock("http://example.com")
64
+ .get("/automation/schema.json")
65
+ .reply(200, {
66
+ type: "automation",
67
+ metadata: {},
68
+ schema: {
69
+ name: "{{ name }}",
70
+ tagline: "{{ description }}",
71
+ icon: "Actions",
72
+ description: "{{ description }}",
73
+ type: "action",
74
+ stepId: "{{ name }}",
75
+ inputs: {
76
+ text: "",
77
+ },
78
+ schema: {
79
+ inputs: {
80
+ properties: {
81
+ text: {
82
+ type: "string",
83
+ title: "Log",
84
+ },
85
+ },
86
+ required: ["text"],
87
+ },
88
+ outputs: {
89
+ properties: {
90
+ success: {
91
+ type: "boolean",
92
+ description: "Whether the action was successful",
93
+ },
94
+ message: {
95
+ type: "string",
96
+ description: "What was output",
97
+ },
98
+ },
99
+ required: ["success", "message"],
100
+ },
101
+ },
102
+ },
103
+ })
104
+ }
105
+
106
+ function mockComponentSchema() {
107
+ nock("http://example.com")
108
+ .get("/component/schema.json")
109
+ .reply(200, {
110
+ type: "component",
111
+ metadata: {},
112
+ schema: {
113
+ name: "{{ name }}",
114
+ friendlyName: "{{ name }}",
115
+ description: "{{ description }}",
116
+ icon: "Text",
117
+ settings: [
118
+ {
119
+ type: "text",
120
+ key: "text",
121
+ label: "Text",
122
+ },
123
+ ],
124
+ },
125
+ })
126
+ }
10
127
 
11
128
  async function getSchema(link: string) {
12
129
  const response = await fetch(link)
@@ -31,53 +148,62 @@ async function runTest(opts: { link?: string; schema?: any }) {
31
148
  return error
32
149
  }
33
150
 
34
- describe("it should be able to validate an automation schema", () => {
35
- it("should return automation skeleton schema is valid", async () => {
36
- const error = await runTest({ link: automationLink })
37
- expect(error).toBeUndefined()
151
+ describe("plugin validation", () => {
152
+ beforeEach(() => {
153
+ nock.cleanAll()
154
+ mockAutomationSchema()
155
+ mockComponentSchema()
156
+ mockDatasourceSchema()
38
157
  })
39
158
 
40
- it("should fail given invalid automation schema", async () => {
41
- const error = await runTest({
42
- schema: {
43
- type: PluginType.AUTOMATION,
44
- schema: {},
45
- },
159
+ describe("it should be able to validate an automation schema", () => {
160
+ it("should return automation skeleton schema is valid", async () => {
161
+ const error = await runTest({ link: automationLink })
162
+ expect(error).toBeUndefined()
46
163
  })
47
- expect(error).toBeDefined()
48
- })
49
- })
50
164
 
51
- describe("it should be able to validate a component schema", () => {
52
- it("should return component skeleton schema is valid", async () => {
53
- const error = await runTest({ link: componentLink })
54
- expect(error).toBeUndefined()
165
+ it("should fail given invalid automation schema", async () => {
166
+ const error = await runTest({
167
+ schema: {
168
+ type: PluginType.AUTOMATION,
169
+ schema: {},
170
+ },
171
+ })
172
+ expect(error).toBeDefined()
173
+ })
55
174
  })
56
175
 
57
- it("should fail given invalid component schema", async () => {
58
- const error = await runTest({
59
- schema: {
60
- type: PluginType.COMPONENT,
61
- schema: {},
62
- },
176
+ describe("it should be able to validate a component schema", () => {
177
+ it("should return component skeleton schema is valid", async () => {
178
+ const error = await runTest({ link: componentLink })
179
+ expect(error).toBeUndefined()
63
180
  })
64
- expect(error).toBeDefined()
65
- })
66
- })
67
181
 
68
- describe("it should be able to validate a datasource schema", () => {
69
- it("should return datasource skeleton schema is valid", async () => {
70
- const error = await runTest({ link: datasourceLink })
71
- expect(error).toBeUndefined()
182
+ it("should fail given invalid component schema", async () => {
183
+ const error = await runTest({
184
+ schema: {
185
+ type: PluginType.COMPONENT,
186
+ schema: {},
187
+ },
188
+ })
189
+ expect(error).toBeDefined()
190
+ })
72
191
  })
73
192
 
74
- it("should fail given invalid datasource schema", async () => {
75
- const error = await runTest({
76
- schema: {
77
- type: PluginType.DATASOURCE,
78
- schema: {},
79
- },
193
+ describe("it should be able to validate a datasource schema", () => {
194
+ it("should return datasource skeleton schema is valid", async () => {
195
+ const error = await runTest({ link: datasourceLink })
196
+ expect(error).toBeUndefined()
197
+ })
198
+
199
+ it("should fail given invalid datasource schema", async () => {
200
+ const error = await runTest({
201
+ schema: {
202
+ type: PluginType.DATASOURCE,
203
+ schema: {},
204
+ },
205
+ })
206
+ expect(error).toBeDefined()
80
207
  })
81
- expect(error).toBeDefined()
82
208
  })
83
209
  })
@@ -111,6 +111,10 @@ function init(selectDb = DEFAULT_SELECT_DB) {
111
111
  CLIENTS[selectDb] = client
112
112
  }
113
113
 
114
+ export function closeAll() {
115
+ Object.values(CLIENTS).forEach(client => client.disconnect())
116
+ }
117
+
114
118
  function waitForConnection(selectDb: number = DEFAULT_SELECT_DB) {
115
119
  return new Promise(resolve => {
116
120
  if (pickClient(selectDb) == null) {
@@ -1,7 +1,7 @@
1
1
  import { GenericContainer, StartedTestContainer } from "testcontainers"
2
2
  import { generator, structures } from "../../../tests"
3
- import RedisWrapper from "../redis"
4
- import { env } from "../.."
3
+ import RedisWrapper, { closeAll } from "../redis"
4
+ import env from "../../environment"
5
5
  import { randomUUID } from "crypto"
6
6
 
7
7
  jest.setTimeout(30000)
@@ -23,7 +23,10 @@ describe("redis", () => {
23
23
  env._set("REDIS_PASSWORD", 0)
24
24
  })
25
25
 
26
- afterAll(() => container?.stop())
26
+ afterAll(() => {
27
+ container?.stop()
28
+ closeAll()
29
+ })
27
30
 
28
31
  beforeEach(async () => {
29
32
  redis = new RedisWrapper(structures.db.id())
@@ -1,6 +1,6 @@
1
1
  import env from "../environment"
2
2
 
3
- export const PASSWORD_MIN_LENGTH = +(env.PASSWORD_MIN_LENGTH || 8)
3
+ export const PASSWORD_MIN_LENGTH = +(env.PASSWORD_MIN_LENGTH || 12)
4
4
  export const PASSWORD_MAX_LENGTH = +(env.PASSWORD_MAX_LENGTH || 512)
5
5
 
6
6
  export function validatePassword(
@@ -4,7 +4,7 @@ import { PASSWORD_MAX_LENGTH, validatePassword } from "../auth"
4
4
  describe("auth", () => {
5
5
  describe("validatePassword", () => {
6
6
  it("a valid password returns successful", () => {
7
- expect(validatePassword("password")).toEqual({ valid: true })
7
+ expect(validatePassword("password123!")).toEqual({ valid: true })
8
8
  })
9
9
 
10
10
  it.each([
@@ -14,7 +14,7 @@ describe("auth", () => {
14
14
  ])("%s returns unsuccessful", (_, password) => {
15
15
  expect(validatePassword(password as string)).toEqual({
16
16
  valid: false,
17
- error: "Password invalid. Minimum 8 characters.",
17
+ error: "Password invalid. Minimum 12 characters.",
18
18
  })
19
19
  })
20
20
 
@@ -28,16 +28,25 @@ function generateSchema(
28
28
  oldTable: null | Table = null,
29
29
  renamed?: RenameColumn
30
30
  ) {
31
- let primaryKey = table && table.primary ? table.primary[0] : null
31
+ let primaryKeys = table && table.primary ? table.primary : []
32
32
  const columns = Object.values(table.schema)
33
33
  // all columns in a junction table will be meta
34
34
  let metaCols = columns.filter(col => (col as NumberFieldMetadata).meta)
35
35
  let isJunction = metaCols.length === columns.length
36
+ let columnTypeSet: string[] = []
37
+
36
38
  // can't change primary once its set for now
37
- if (primaryKey && !oldTable && !isJunction) {
38
- schema.increments(primaryKey).primary()
39
- } else if (!oldTable && isJunction) {
40
- schema.primary(metaCols.map(col => col.name))
39
+ if (!oldTable) {
40
+ // junction tables are special - we have an expected format
41
+ if (isJunction) {
42
+ schema.primary(metaCols.map(col => col.name))
43
+ } else if (primaryKeys.length === 1) {
44
+ schema.increments(primaryKeys[0]).primary()
45
+ // note that we've set its type
46
+ columnTypeSet.push(primaryKeys[0])
47
+ } else {
48
+ schema.primary(primaryKeys)
49
+ }
41
50
  }
42
51
 
43
52
  // check if any columns need added
@@ -49,7 +58,7 @@ function generateSchema(
49
58
  const oldColumn = oldTable ? oldTable.schema[key] : null
50
59
  if (
51
60
  (oldColumn && oldColumn.type) ||
52
- (primaryKey === key && !isJunction) ||
61
+ columnTypeSet.includes(key) ||
53
62
  renamed?.updated === key
54
63
  ) {
55
64
  continue
@@ -61,7 +70,12 @@ function generateSchema(
61
70
  case FieldType.LONGFORM:
62
71
  case FieldType.BARCODEQR:
63
72
  case FieldType.BB_REFERENCE_SINGLE:
64
- schema.text(key)
73
+ // primary key strings have to have a length in some DBs
74
+ if (primaryKeys.includes(key)) {
75
+ schema.string(key, 255)
76
+ } else {
77
+ schema.text(key)
78
+ }
65
79
  break
66
80
  case FieldType.NUMBER:
67
81
  // if meta is specified then this is a junction table entry
@@ -5,7 +5,5 @@ export const accounts = jest.mocked(_accounts)
5
5
 
6
6
  export * as date from "./date"
7
7
  export * as licenses from "./licenses"
8
- export { default as fetch } from "./fetch"
9
8
  export * from "./alerts"
10
9
  import "./events"
11
- import "./posthog"
@@ -21,7 +21,7 @@ export const user = (userProps?: Partial<Omit<User, "userId">>): User => {
21
21
  _id: userId,
22
22
  userId,
23
23
  email: newEmail(),
24
- password: "password",
24
+ password: "password123!",
25
25
  roles: { app_test: "admin" },
26
26
  firstName: generator.first(),
27
27
  lastName: generator.last(),
@@ -2,14 +2,21 @@ import "./core/logging"
2
2
  import env from "../src/environment"
3
3
  import { cleanup } from "../src/timers"
4
4
  import { mocks, testContainerUtils } from "./core/utilities"
5
-
6
- // must explicitly enable fetch mock
7
- mocks.fetch.enable()
5
+ import nock from "nock"
8
6
 
9
7
  // mock all dates to 2020-01-01T00:00:00.000Z
10
8
  // use tk.reset() to use real dates in individual tests
11
9
  import tk from "timekeeper"
12
10
 
11
+ nock.disableNetConnect()
12
+ nock.enableNetConnect(host => {
13
+ return (
14
+ host.includes("localhost") ||
15
+ host.includes("127.0.0.1") ||
16
+ host.includes("::1")
17
+ )
18
+ })
19
+
13
20
  tk.freeze(mocks.date.MOCK_DATE)
14
21
 
15
22
  if (!process.env.DEBUG) {
@@ -1,32 +0,0 @@
1
- declare const _default: {
2
- enable: () => void;
3
- apply(this: Function, thisArg: any, argArray?: any): any;
4
- call(this: Function, thisArg: any, ...argArray: any[]): any;
5
- bind(this: Function, thisArg: any, ...argArray: any[]): any;
6
- toString(): string;
7
- prototype: any;
8
- length: number;
9
- arguments: any;
10
- caller: Function;
11
- name: string;
12
- [Symbol.hasInstance](value: any): boolean;
13
- getMockName(): string;
14
- mock: jest.MockContext<any, [url: any, opts: any], any>;
15
- mockClear(): jest.Mock<any, [url: any, opts: any], any>;
16
- mockReset(): jest.Mock<any, [url: any, opts: any], any>;
17
- mockRestore(): void;
18
- getMockImplementation(): ((...args: [url: any, opts: any]) => any) | undefined;
19
- mockImplementation(fn?: ((url: any, opts: any) => any) | undefined): jest.Mock<any, [url: any, opts: any], any>;
20
- mockImplementationOnce(fn: (url: any, opts: any) => any): jest.Mock<any, [url: any, opts: any], any>;
21
- withImplementation(fn: (url: any, opts: any) => any, callback: () => Promise<unknown>): Promise<void>;
22
- withImplementation(fn: (url: any, opts: any) => any, callback: () => void): void;
23
- mockName(name: string): jest.Mock<any, [url: any, opts: any], any>;
24
- mockReturnThis(): jest.Mock<any, [url: any, opts: any], any>;
25
- mockReturnValue(value: any): jest.Mock<any, [url: any, opts: any], any>;
26
- mockReturnValueOnce(value: any): jest.Mock<any, [url: any, opts: any], any>;
27
- mockResolvedValue(value: any): jest.Mock<any, [url: any, opts: any], any>;
28
- mockResolvedValueOnce(value: any): jest.Mock<any, [url: any, opts: any], any>;
29
- mockRejectedValue(value: any): jest.Mock<any, [url: any, opts: any], any>;
30
- mockRejectedValueOnce(value: any): jest.Mock<any, [url: any, opts: any], any>;
31
- };
32
- export default _default;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const mockFetch = jest.fn((url, opts) => {
4
- const fetch = jest.requireActual("node-fetch");
5
- const env = jest.requireActual("../../../../src/environment").default;
6
- if (url.includes(env.COUCH_DB_URL) || url.includes("raw.github")) {
7
- return fetch(url, opts);
8
- }
9
- return undefined;
10
- });
11
- const enable = () => {
12
- jest.mock("node-fetch", () => mockFetch);
13
- };
14
- exports.default = Object.assign(Object.assign({}, mockFetch), { enable });
15
- //# sourceMappingURL=fetch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../../../tests/core/utilities/mocks/fetch.ts"],"names":[],"mappings":";;AAAA,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,GAAQ,EAAE,IAAS,EAAE,EAAE;IAChD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,CAAA;IAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,6BAA6B,CAAC,CAAC,OAAO,CAAA;IACrE,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QACjE,OAAO,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACzB,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAC,CAAA;AAEF,MAAM,MAAM,GAAG,GAAG,EAAE;IAClB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;AAC1C,CAAC,CAAA;AAED,kDACK,SAAS,KACZ,MAAM,IACP"}
File without changes
@@ -1,9 +0,0 @@
1
- "use strict";
2
- jest.mock("posthog-node", () => {
3
- return jest.fn().mockImplementation(() => {
4
- return {
5
- capture: jest.fn(),
6
- };
7
- });
8
- });
9
- //# sourceMappingURL=posthog.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"posthog.js","sourceRoot":"","sources":["../../../../../tests/core/utilities/mocks/posthog.ts"],"names":[],"mappings":";AAAA,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;IAC7B,OAAO,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE;QACvC,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;SACnB,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,17 +0,0 @@
1
- const mockFetch = jest.fn((url: any, opts: any) => {
2
- const fetch = jest.requireActual("node-fetch")
3
- const env = jest.requireActual("../../../../src/environment").default
4
- if (url.includes(env.COUCH_DB_URL) || url.includes("raw.github")) {
5
- return fetch(url, opts)
6
- }
7
- return undefined
8
- })
9
-
10
- const enable = () => {
11
- jest.mock("node-fetch", () => mockFetch)
12
- }
13
-
14
- export default {
15
- ...mockFetch,
16
- enable,
17
- }
@@ -1,7 +0,0 @@
1
- jest.mock("posthog-node", () => {
2
- return jest.fn().mockImplementation(() => {
3
- return {
4
- capture: jest.fn(),
5
- }
6
- })
7
- })