kgabryje commented on a change in pull request #11012:
URL:
https://github.com/apache/incubator-superset/pull/11012#discussion_r494916944
##########
File path: superset-frontend/src/components/AlteredSliceTag.jsx
##########
@@ -103,10 +138,7 @@ export default class AlteredSliceTag extends
React.Component {
if (value === null) {
return 'null';
}
- if (
- this.state.controlsMap[key] &&
- this.state.controlsMap[key].type === 'AdhocFilterControl'
- ) {
+ if (controlsMap[key] && controlsMap[key].type === 'AdhocFilterControl') {
Review comment:
👍
##########
File path:
superset-frontend/spec/javascripts/components/AlteredSliceTag_spec.jsx
##########
@@ -112,6 +113,28 @@ const expectedDiffs = {
},
};
+const expectedRows = [
+ {
+ control: 'Fake Filters',
+ before: 'a == hello',
+ after: 'b in [hello, my, name]',
+ },
+ {
+ control: 'Value bounds',
+ before: 'Min: 10, Max: 20',
+ after: 'Min: 15, Max: 16',
+ },
+ {
+ control: 'Fake Collection Control',
+ before: '{"1":"a","b":["6","g"]}',
+ after: '{"1":"a","b":[9,"15"],"t":"gggg"}',
+ },
+ { control: 'bool', before: 'false', after: 'true' },
+ { control: 'gucci', before: '1, 2, 3, 4', after: 'a, b, c, d' },
+ { control: 'never', before: 5, after: 10 },
+ { control: 'ever', before: '{"a":"b","c":"d"}', after: '{"x":"y","z":"z"}' },
+];
+
Review comment:
I moved all mocked values from AlteredSliceTag_spec.jsx to separate file
##########
File path: superset-frontend/src/components/AlteredSliceTag.jsx
##########
@@ -65,7 +65,18 @@ export default class AlteredSliceTag extends React.Component
{
return;
}
const diffs = this.getDiffs(newProps);
- this.setState({ diffs, hasDiffs: !isEmpty(diffs) });
+ this.setState(prevState => ({
+ rows: this.getRowsFromDiffs(diffs, prevState.controlsMap),
+ hasDiffs: !isEmpty(diffs),
+ }));
+ }
+
+ getRowsFromDiffs(diffs, controlsMap = this.state.controlsMap) {
Review comment:
I agree, that test made little sense. I changed the logic so that we spy
on `getRowsFromDiffs` to check if it was called and if `state.rows` equals a
mocked return value from `getRowsFromDiffs`.
Is that what you meant?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]