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

UIP-1897: Add support for traversing wrapper components to getProps #48

Merged

Conversation

jacehensley-wf
Copy link
Contributor

@jacehensley-wf jacehensley-wf commented Feb 14, 2017

Ultimate problem:

getProps did not support traversing "Wrapper" components.

How it was fixed:

  • Add param traverseWrappers to getProps
    • When true will traverse all "Wrapper" components until it finds the first nested non-"Wrapper" component.
    • This is supported for ReactElements and Dart ReactComponents.

Also done:

  • Bump min SDK restraint to 1.21.1

Testing suggestions:

  • Verify tests pass
  • Verify tests cover all cases.

Potential areas of regression:

  • None expected, only new logic is added.

FYA: @greglittlefield-wf @aaronlademann-wf @jacehensley-wf @clairesarsam-wf @joelleibow-wf @kaanaksoy-wk

@aviary2-wf
Copy link

Raven

Number of Findings: 0

@codecov-io
Copy link

codecov-io commented Feb 14, 2017

Codecov Report

Merging #48 into master will increase coverage by 0.02%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master      #48      +/-   ##
==========================================
+ Coverage   97.65%   97.67%   +0.02%     
==========================================
  Files          28       28              
  Lines        1318     1329      +11     
==========================================
+ Hits         1287     1298      +11     
  Misses         31       31

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6543e36...f1e528c. Read the comment docs.

UIP-1897
- Get the component type meta of Dart ReactComponents by using the JS constructor as the type alias.
Copy link
Contributor

@aaronlademann-wf aaronlademann-wf 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 @jacehensley-wf! Just a few typos / doc comments update.

@@ -108,10 +109,34 @@ Expando<UnmodifiableMapView> _elementPropsCache = new Expando('_elementPropsCach
/// For a JS component, this returns the result of [getJsProps] in an unmodifiable Map view.
///
/// Throws if [instance] is not a valid [ReactElement] or composite [ReactComponent] .
Map getProps(/* ReactElement|ReactComponent */ instance) {
Map getProps(/* ReactElement|ReactComponent */ instance, {bool traverseWrappers: false}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@jacehensley-wf the doc comment should be updated to explain the use case of setting traverseWrappers to true.

@@ -574,6 +576,264 @@ main() {
}));
});

group('traverses children of Wrapper components', () {
group('and retruns props for a', () {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/retruns/returns

}));
});

test('except when traversWrappers is false', () {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/traversWrappers/traverseWrappers

}));
});

test('except when traversWrappers is false', () {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/traversWrappers/traverseWrappers

}));
});

test('except when traversWrappers is false', () {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/traversWrappers/traverseWrappers

}));
});

test('except when traverseWrapers is false', () {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/traverseWrapers/traverseWrappers

ComponentTypeMeta instanceTypeMeta;

if (isCompositeComponent && isDartComponent(instance)) {
var reactClassType = getProperty(getDartComponent(instance).jsThis, 'constructor');
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I wasn't more clear on what I meant here; I was suggesting something like:

ReactClass type = getProperty(getDartComponent(instance).jsThis, 'constructor');
instanceTypeMeta = getComponentTypeMeta(type);

@jacehensley-wf
Copy link
Contributor Author

@greglittlefield-wf @aaronlademann-wf Feedback has been addressed.

@aaronlademann-wf
Copy link
Contributor

+1

@clairesarsam-wf
Copy link
Contributor

+1

}, testChildren)
));

expect(getProps(renderedInstance), isNot({
Copy link
Contributor

Choose a reason for hiding this comment

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

Would probably be better to verify explicitly that the OneLevelWrapper's props are returned.

Copy link
Contributor

Choose a reason for hiding this comment

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

(Same goes for other analogous tests)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure why this is still here. This has been addressed.

@@ -574,6 +576,264 @@ main() {
}));
});

group('traverses children of Wrapper components', () {
group('and returns props for a', () {
group('composite JS ReactComponent', () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like composite JS ReactElements aren't tested

});
});
});

Copy link
Contributor

Choose a reason for hiding this comment

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

It'd probably be good to also test that getProps w/ traverseWrappers: true doesn't have any issues when passed a non-wrapper component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed

@greglittlefield-wf
Copy link
Contributor

A few comments around tests, but otherwise looks great

@jacehensley-wf
Copy link
Contributor Author

@greglittlefield-wf feedback has been addressed

@greglittlefield-wf
Copy link
Contributor

+1

@leviwith-wf
Copy link
Contributor

QA Resource Approval: +10

  • Testing instruction
  • Dev +1's
  • Dev/QA +10
  • Unit test created/updated
  • All unit tests pass

Merging.

@leviwith-wf leviwith-wf merged commit a0af902 into Workiva:master Feb 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants