From 9474080ea1cc316580b8af8c6b5921060ce93ee1 Mon Sep 17 00:00:00 2001 From: Nina Ceban Ciocanu Date: Tue, 29 Oct 2024 17:34:55 +0200 Subject: [PATCH] remove required for data (#1203) Co-authored-by: Nina Ciocanu --- .../Personalization/createApplyPropositions.js | 2 ++ .../validateApplyPropositionsOptions.js | 2 +- .../createApplyPropositions.spec.js | 4 ++-- .../validateApplyPropositionsOptions.spec.js | 18 ++---------------- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/components/Personalization/createApplyPropositions.js b/src/components/Personalization/createApplyPropositions.js index dcdb86cbb..2c4a8c2c2 100644 --- a/src/components/Personalization/createApplyPropositions.js +++ b/src/components/Personalization/createApplyPropositions.js @@ -12,6 +12,7 @@ governing permissions and limitations under the License. import { defer, isEmptyObject, isNonEmptyArray } from "../../utils/index.js"; import { + DEFAULT_CONTENT_ITEM, DOM_ACTION, HTML_CONTENT_ITEM, JSON_CONTENT_ITEM, @@ -29,6 +30,7 @@ const SUPPORTED_SCHEMAS = { [HTML_CONTENT_ITEM]: () => true, [JSON_CONTENT_ITEM]: isInteractionTrackingItem, [MESSAGE_IN_APP]: () => true, + [DEFAULT_CONTENT_ITEM]: () => true, }; const filterItemsPredicate = (schema, actionType) => diff --git a/src/components/Personalization/validateApplyPropositionsOptions.js b/src/components/Personalization/validateApplyPropositionsOptions.js index 4268febdb..7045b3e9b 100644 --- a/src/components/Personalization/validateApplyPropositionsOptions.js +++ b/src/components/Personalization/validateApplyPropositionsOptions.js @@ -31,7 +31,7 @@ export default ({ logger, options }) => { objectOf({ id: string().required(), schema: string().required(), - data: anything().required(), + data: objectOf(anything()), }), ) .nonEmpty() diff --git a/test/unit/specs/components/Personalization/createApplyPropositions.spec.js b/test/unit/specs/components/Personalization/createApplyPropositions.spec.js index 413e192bf..70e54dc7e 100644 --- a/test/unit/specs/components/Personalization/createApplyPropositions.spec.js +++ b/test/unit/specs/components/Personalization/createApplyPropositions.spec.js @@ -76,7 +76,7 @@ describe("Personalization::createApplyPropositions", () => { expect(processPropositions).toHaveBeenCalledOnceWith([]); }); - it("it should apply user-provided dom-action schema propositions", async () => { + it("it should apply user-provided dom-action/default-content schema propositions", async () => { const expectedExecuteDecisionsPropositions = clone( PAGE_WIDE_SCOPE_DECISIONS, ).map((proposition) => { @@ -99,7 +99,7 @@ describe("Personalization::createApplyPropositions", () => { expect(proposition.items).toEqual( jasmine.arrayContaining([jasmine.any(Object)]), ); - expect(proposition.items.length).toEqual(2); + expect(proposition.items.length).toEqual(3); }); }); diff --git a/test/unit/specs/components/Personalization/validateApplyPropositionsOptions.spec.js b/test/unit/specs/components/Personalization/validateApplyPropositionsOptions.spec.js index 07aa4139e..e11bec5da 100644 --- a/test/unit/specs/components/Personalization/validateApplyPropositionsOptions.spec.js +++ b/test/unit/specs/components/Personalization/validateApplyPropositionsOptions.spec.js @@ -176,8 +176,7 @@ describe("Personalization::validateApplyPropositionsOptions", () => { ], errorMessage: "'propositions[0].items[0].id' is a required option\n" + - "'propositions[0].items[0].schema' is a required option\n" + - "'propositions[0].items[0].data' is a required option", + "'propositions[0].items[0].schema' is a required option", }, { propositions: [ @@ -188,20 +187,7 @@ describe("Personalization::validateApplyPropositionsOptions", () => { items: [{ id: "abc" }], }, ], - errorMessage: - "'propositions[0].items[0].schema' is a required option\n" + - "'propositions[0].items[0].data' is a required option", - }, - { - propositions: [ - { - id: "abc", - scope: "web://aepdemo.com/", - scopeDetails, - items: [{ id: "abc", schema: DOM_ACTION }], - }, - ], - errorMessage: "'propositions[0].items[0].data' is a required option", + errorMessage: "'propositions[0].items[0].schema' is a required option", }, ];