Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix propositions return value #1082

Merged
merged 6 commits into from
Nov 9, 2023
Merged

Fix propositions return value #1082

merged 6 commits into from
Nov 9, 2023

Conversation

jonsnyder
Copy link
Contributor

@jonsnyder jonsnyder commented Nov 8, 2023

Description

While writing documentation wiki pages for the apply propositions, I noticed that the send event call was not returning anything in propositions. It was always an empty array. After investigation, I found that this was caused by the DecisioningEngine also returning propositions from its onBeforeEvent lifecycle method. This PR changes how the lifecycle return values are merged together. If the merged values are arrays, then the arrays are concat'ed together instead of overwritten.

Additionally, I found a few more tests failing because experience edge is now returning default-content-items when before it wasn't. I've updated the tests to be more lenient on their expectations regarding the number of propositions returned.

Lastly, there are two tests for applyResponse that I skipped because I noticed there are a bunch of new propositions returned from experience edge that are messing up the expectations. See https://jira.corp.adobe.com/browse/PDCL-11302

Related Issue

Motivation and Context

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (non-breaking change which does not add functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA or I'm an Adobe employee.
  • I have made any necessary test changes and all tests pass.
  • I have run the Sandbox successfully.

@@ -70,6 +70,9 @@ describe("mergeLifecycleResponses", () => {
]
}
]
},
{
propositions: []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A unit test that coves the "merge two arrays" code path would be good.

...lifecycleOnResponseReturnValues,
...consumerOnResponseReturnValues,
...lifecycleOnBeforeRequestReturnValues
);
].reduce((accumulator, currentValue) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the defect I was going to tell you about in our meeting the other day. much improved 🏆

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would really like this accumulation of results to be available as the lifecycle progresses. I know we discussed it possibly being less performant, but might it be worth trying it out? Changing from promise.all to a sequential evaluation where the responses are accumulated. that still seems like an ideal solution for the decisioning engine propositions to be added.

...lifecycleOnResponseReturnValues,
...consumerOnResponseReturnValues,
...lifecycleOnBeforeRequestReturnValues
);
].reduce((accumulator, currentValue) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it help to extract this code into a separate util and unit test that alone?

Copy link
Contributor

@jfkhoury jfkhoury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the fix, and all the test updates!

@@ -0,0 +1,26 @@
import assign from "./assign";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at that beauty :)

@@ -0,0 +1,65 @@
import assignConcatArrayValues from "../../../../src/utils/assignConcatArrayValues";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More beauty!!!

Copy link
Contributor

@jfkhoury jfkhoury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @jonsnyder ! I think @jasonwaters 's comment is worth discussing, but it can be after the release.

@jonsnyder jonsnyder merged commit 8a78c48 into main Nov 9, 2023
1 check passed
@jonsnyder jonsnyder deleted the fixPropositionsReturnValue branch November 9, 2023 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants