diff --git a/src/__tests__/_/api-handlers/integrations-list.ts b/src/__tests__/_/api-handlers/integrations-list.ts index e1fbb0b87..85b90734c 100644 --- a/src/__tests__/_/api-handlers/integrations-list.ts +++ b/src/__tests__/_/api-handlers/integrations-list.ts @@ -32,7 +32,24 @@ export const integrationsListApiHandlers = [ key: "non-activated-actions", title: "Non Activated Actions", description: "Some Non Activated Actions Description", - configurationSchema: {}, + configurationSchema: { + username: { + type: "text", + validations: [ + { + validationType: "required", + }, + ], + }, + password: { + type: "text", + validations: [ + { + validationType: "required", + }, + ], + }, + }, }, { key: "smtp", diff --git a/src/__tests__/_/forCodeCoverage.spec.ts b/src/__tests__/_/forCodeCoverage.spec.ts index ea51937c6..177fb288c 100644 --- a/src/__tests__/_/forCodeCoverage.spec.ts +++ b/src/__tests__/_/forCodeCoverage.spec.ts @@ -17,6 +17,7 @@ import { FOR_CODE_COV as $16 } from "backend/integrations/libs/slack/types"; import { FOR_CODE_COV as $17 } from "backend/integrations/libs/smtp/types"; import { FOR_CODE_COV as $18 } from "backend/integrations/libs/twilio/types"; import { FOR_CODE_COV as $19 } from "backend/storage/types"; +import { FOR_CODE_COV as $20 } from "frontend/design-system/theme/types"; import { FOR_CODE_COV as $21 } from "shared/form-schemas/roles/permissions/base"; import { FOR_CODE_COV as $22 } from "backend/lib/config-persistence/portal/index"; import { FOR_CODE_COV as $23 } from "backend/lib/config-persistence/portal/main/types"; @@ -63,6 +64,7 @@ noop( $17, $18, $19, + $20, $21, $22, $23, diff --git a/src/frontend/design-system/theme/types.ts b/src/frontend/design-system/theme/types.ts index 377bf8930..5348bfd9d 100644 --- a/src/frontend/design-system/theme/types.ts +++ b/src/frontend/design-system/theme/types.ts @@ -14,3 +14,5 @@ export type IRootColors = | keyof IColorMode | "primary-shade-color" | "primary-color"; + +export const FOR_CODE_COV = 1; diff --git a/src/frontend/lib/data/useMutate/__tests__/mutation-helpers.spec.ts b/src/frontend/lib/data/useMutate/__tests__/mutation-helpers.spec.ts new file mode 100644 index 000000000..431df22b6 --- /dev/null +++ b/src/frontend/lib/data/useMutate/__tests__/mutation-helpers.spec.ts @@ -0,0 +1,82 @@ +import { MutationHelpers } from "../mutation-helpers"; + +describe("MutationHelpers", () => { + it("append", () => { + const old = ["a", "b"]; + const formData = "c"; + expect(MutationHelpers.append(old, formData)).toEqual(["a", "b", "c"]); + }); + + it("remove", () => { + const old = ["a", "b", "c"]; + const formData = "b"; + expect(MutationHelpers.remove(old, formData)).toEqual(["a", "c"]); + }); + + it("deleteByKey", () => { + const old = [{ id: "a" }, { id: "b" }, { id: "c" }]; + const key = "id"; + const currentDataId = "b"; + expect(MutationHelpers.deleteByKey(key)(old, currentDataId)).toEqual([ + { id: "a" }, + { id: "c" }, + ]); + }); + + it("mergeArray", () => { + const old = ["a", "b"]; + const formData = ["c", "d"]; + expect(MutationHelpers.mergeArray(old, formData)).toEqual([ + "a", + "b", + "c", + "d", + ]); + }); + + it("mergeObject", () => { + const old = { a: "a", b: "old" }; + const formData = { b: "b" }; + expect(MutationHelpers.mergeObject(old, formData)).toEqual({ + a: "a", + b: "b", + }); + }); + + it("replace", () => { + const old = "a"; + const formData = "b"; + expect(MutationHelpers.replace(old, formData)).toEqual("b"); + }); + + it("update", () => { + const old = [{ id: "a" }, { id: "b" }]; + const formData = { id: "b", data: "c" }; + expect(MutationHelpers.update(old, formData)).toEqual([ + { id: "a" }, + { id: "b", data: "c" }, + ]); + }); + + it("delete", () => { + const old = [{ id: "a" }, { id: "b" }]; + const currentDataId = "b"; + expect(MutationHelpers.delete(old, currentDataId)).toEqual([{ id: "a" }]); + }); + + it("sortOrder", () => { + const old = [{ id: "a" }, { id: "b" }, { id: "c" }]; + const order = ["c", "a", "b"]; + expect(MutationHelpers.sortOrder(old, order)).toEqual([ + { id: "c" }, + { id: "a" }, + { id: "b" }, + ]); + }); + + it("removeMany", () => { + const old = ["a", "b", "c"]; + const formData = ["b", "c"]; + expect(MutationHelpers.removeMany(old, formData)).toEqual(["a"]); + }); +}); diff --git a/src/frontend/lib/numbers/index.ts b/src/frontend/lib/numbers/index.ts index 1d7ed2378..d1b982e02 100644 --- a/src/frontend/lib/numbers/index.ts +++ b/src/frontend/lib/numbers/index.ts @@ -15,9 +15,3 @@ export function abbreviateNumber(value: number) { newValueString += suffixes[suffixNum]; return newValueString; } - -export const randomNumber = ($min: number, $max: number) => { - const min = Math.ceil($min); - const max = Math.floor($max); - return Math.floor(Math.random() * (max - min + 1)) + min; -};