From 409edc5f6e4ab2c4c41ccad5450938284673abc3 Mon Sep 17 00:00:00 2001 From: Vivian Zhang Date: Fri, 28 Jun 2024 08:23:50 -0700 Subject: [PATCH] fix: 10795 10736 project and initiative creation rules updates (#1562) --- .../_internal/InitiativeUiSchemaCreate.ts | 64 +++++++-- .../_internal/ProjectUiSchemaCreate.ts | 64 +++++++-- .../InitiativeUiSchemaCreate.test.ts | 136 ++++++++++++++---- .../_internal/ProjectUiSchemaCreate.test.ts | 64 +++++++-- 4 files changed, 266 insertions(+), 62 deletions(-) diff --git a/packages/common/src/initiatives/_internal/InitiativeUiSchemaCreate.ts b/packages/common/src/initiatives/_internal/InitiativeUiSchemaCreate.ts index 700c15b25d7..f87d9781c98 100644 --- a/packages/common/src/initiatives/_internal/InitiativeUiSchemaCreate.ts +++ b/packages/common/src/initiatives/_internal/InitiativeUiSchemaCreate.ts @@ -109,13 +109,33 @@ export const buildUiSchema = async ( options: { section: "step", }, - rule: { - effect: UiSchemaRuleEffects.DISABLE, - condition: { - scope: "/properties/name", - schema: { const: "" }, + rules: [ + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { const: "" }, + }, + ], }, - }, + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { minLength: 251 }, + }, + ], + }, + { + effect: UiSchemaRuleEffects.DISABLE, + condition: { + scope: "/properties/summary", + schema: { minLength: 2049 }, + }, + }, + ], elements: [ { type: "Section", @@ -206,13 +226,33 @@ export const buildUiSchema = async ( options: { section: "step", }, - rule: { - effect: UiSchemaRuleEffects.DISABLE, - condition: { - scope: "/properties/name", - schema: { const: "" }, + rules: [ + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { const: "" }, + }, + ], }, - }, + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { minLength: 251 }, + }, + ], + }, + { + effect: UiSchemaRuleEffects.DISABLE, + condition: { + scope: "/properties/summary", + schema: { minLength: 2049 }, + }, + }, + ], elements: [ { scope: "/properties/access", diff --git a/packages/common/src/projects/_internal/ProjectUiSchemaCreate.ts b/packages/common/src/projects/_internal/ProjectUiSchemaCreate.ts index 26d4bd48ee8..30c1385f759 100644 --- a/packages/common/src/projects/_internal/ProjectUiSchemaCreate.ts +++ b/packages/common/src/projects/_internal/ProjectUiSchemaCreate.ts @@ -98,13 +98,33 @@ export const buildUiSchema = async ( options: { section: "step", }, - rule: { - effect: UiSchemaRuleEffects.DISABLE, - condition: { - scope: "/properties/name", - schema: { const: "" }, + rules: [ + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { const: "" }, + }, + ], }, - }, + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { minLength: 251 }, + }, + ], + }, + { + effect: UiSchemaRuleEffects.DISABLE, + condition: { + scope: "/properties/summary", + schema: { minLength: 2049 }, + }, + }, + ], elements: [ { type: "Section", @@ -143,13 +163,33 @@ export const buildUiSchema = async ( options: { section: "step", }, - rule: { - effect: UiSchemaRuleEffects.DISABLE, - condition: { - scope: "/properties/name", - schema: { const: "" }, + rules: [ + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { const: "" }, + }, + ], }, - }, + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { minLength: 251 }, + }, + ], + }, + { + effect: UiSchemaRuleEffects.DISABLE, + condition: { + scope: "/properties/summary", + schema: { minLength: 2049 }, + }, + }, + ], elements: [ { scope: "/properties/access", diff --git a/packages/common/test/initiatives/_internal/InitiativeUiSchemaCreate.test.ts b/packages/common/test/initiatives/_internal/InitiativeUiSchemaCreate.test.ts index 6ef6a2b998d..9803d30d35a 100644 --- a/packages/common/test/initiatives/_internal/InitiativeUiSchemaCreate.test.ts +++ b/packages/common/test/initiatives/_internal/InitiativeUiSchemaCreate.test.ts @@ -116,13 +116,33 @@ describe("buildUiSchema: initiative create", () => { options: { section: "step", }, - rule: { - effect: UiSchemaRuleEffects.DISABLE, - condition: { - scope: "/properties/name", - schema: { const: "" }, + rules: [ + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { const: "" }, + }, + ], }, - }, + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { minLength: 251 }, + }, + ], + }, + { + effect: UiSchemaRuleEffects.DISABLE, + condition: { + scope: "/properties/summary", + schema: { minLength: 2049 }, + }, + }, + ], elements: [ { type: "Section", @@ -131,7 +151,9 @@ describe("buildUiSchema: initiative create", () => { effect: UiSchemaRuleEffects.HIDE, condition: { scope: "/properties/view/properties/hero", - schema: { const: "image" }, + schema: { + const: "image", + }, }, }, options: { @@ -203,13 +225,33 @@ describe("buildUiSchema: initiative create", () => { options: { section: "step", }, - rule: { - effect: UiSchemaRuleEffects.DISABLE, - condition: { - scope: "/properties/name", - schema: { const: "" }, + rules: [ + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { const: "" }, + }, + ], }, - }, + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { minLength: 251 }, + }, + ], + }, + { + effect: UiSchemaRuleEffects.DISABLE, + condition: { + scope: "/properties/summary", + schema: { minLength: 2049 }, + }, + }, + ], elements: [ { scope: "/properties/access", @@ -355,13 +397,33 @@ describe("buildUiSchema: initiative create", () => { options: { section: "step", }, - rule: { - effect: UiSchemaRuleEffects.DISABLE, - condition: { - scope: "/properties/name", - schema: { const: "" }, + rules: [ + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { const: "" }, + }, + ], }, - }, + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { minLength: 251 }, + }, + ], + }, + { + effect: UiSchemaRuleEffects.DISABLE, + condition: { + scope: "/properties/summary", + schema: { minLength: 2049 }, + }, + }, + ], elements: [ { type: "Section", @@ -370,7 +432,9 @@ describe("buildUiSchema: initiative create", () => { effect: UiSchemaRuleEffects.HIDE, condition: { scope: "/properties/view/properties/hero", - schema: { const: "image" }, + schema: { + const: "image", + }, }, }, options: { @@ -442,13 +506,33 @@ describe("buildUiSchema: initiative create", () => { options: { section: "step", }, - rule: { - effect: UiSchemaRuleEffects.DISABLE, - condition: { - scope: "/properties/name", - schema: { const: "" }, + rules: [ + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { const: "" }, + }, + ], }, - }, + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { minLength: 251 }, + }, + ], + }, + { + effect: UiSchemaRuleEffects.DISABLE, + condition: { + scope: "/properties/summary", + schema: { minLength: 2049 }, + }, + }, + ], elements: [ { scope: "/properties/access", diff --git a/packages/common/test/projects/_internal/ProjectUiSchemaCreate.test.ts b/packages/common/test/projects/_internal/ProjectUiSchemaCreate.test.ts index 9fa52f36d6b..c127d77b353 100644 --- a/packages/common/test/projects/_internal/ProjectUiSchemaCreate.test.ts +++ b/packages/common/test/projects/_internal/ProjectUiSchemaCreate.test.ts @@ -102,13 +102,33 @@ describe("buildUiSchema: project create", () => { options: { section: "step", }, - rule: { - effect: UiSchemaRuleEffects.DISABLE, - condition: { - scope: "/properties/name", - schema: { const: "" }, + rules: [ + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { const: "" }, + }, + ], }, - }, + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { minLength: 251 }, + }, + ], + }, + { + effect: UiSchemaRuleEffects.DISABLE, + condition: { + scope: "/properties/summary", + schema: { minLength: 2049 }, + }, + }, + ], elements: [ { type: "Section", @@ -138,13 +158,33 @@ describe("buildUiSchema: project create", () => { options: { section: "step", }, - rule: { - effect: UiSchemaRuleEffects.DISABLE, - condition: { - scope: "/properties/name", - schema: { const: "" }, + rules: [ + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { const: "" }, + }, + ], }, - }, + { + effect: UiSchemaRuleEffects.DISABLE, + conditions: [ + { + scope: "/properties/name", + schema: { minLength: 251 }, + }, + ], + }, + { + effect: UiSchemaRuleEffects.DISABLE, + condition: { + scope: "/properties/summary", + schema: { minLength: 2049 }, + }, + }, + ], elements: [ { scope: "/properties/access",