-
Notifications
You must be signed in to change notification settings - Fork 297
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 forEach
error
#10194
Fix forEach
error
#10194
Conversation
…mary without properties to reproduce error.
Build files for 93b4390 have been deleted. |
Size Change: +121 B (+0.01%) Total Size: 2 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the changes here are in test files. Hiding whitespace changes may also be useful to enable.
@@ -73,7 +70,7 @@ const fetchGetAccountSummariesStore = createFetchStore( { | |||
...state, | |||
accountSummaries: [ | |||
...( state.accountSummaries || [] ), | |||
...( response.accountSummaries || [] ), | |||
...populateAccountSummaries( response.accountSummaries || [] ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a potential bug where findMatchedProperty
could be invoked after account summaries had been received, but before they had been transformed/populated with their IDs which happened in an action once all AS's had been received. This resulted in all propertyID
s being undefined
and obviously caused problems with proper matching. That wasn't really necessary, as only the sorting needs to be done at the end.
} ); | ||
} ); | ||
summaries.forEach( | ||
( { _id: accountID, propertySummaries = [] } ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fallback to the empty array was the main initial fix as the key isn't always defined in the accountSummary
if there are no properties. This is no longer the case however as populateAccountSummaries
will ensure every AS has propertySummaries
defined.
@@ -118,119 +122,176 @@ describe( 'getAccountDefaults', () => { | |||
).toHaveProperty( ENHANCED_MEASUREMENT_ENABLED, true ); | |||
} ); | |||
} ); | |||
} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously the added populate*
describe blocks were nested under getAccountDefaults
. This fixes the grouping as well. Toggle "hide whitespace" (?w=1
) to make reviewing this part easier.
{ _id: '1122334455' }, | ||
{ _id: '1122334456' }, | ||
{ _id: '1122334457' }, | ||
{ property: 'properties/1122334455' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary because of the populating of ID that we do in the reducer callback for receiveGetAccountSummaries
which will otherwise overwrite the pre-populated ID field here with undefined
since the source property is missing. This was the only instance where this was needed so I opted to update the test instead of the populate utilities. It might be a good idea to preserve an existing/pre-populated ID in the future.
Summary
Addresses issue:
Important
This PR now targets develop
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist