eschutho commented on a change in pull request #11012:
URL: 
https://github.com/apache/incubator-superset/pull/11012#discussion_r494608199



##########
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:
       not sure what our overall philosophy is on snapshots, but moving this to 
a snapshot could clean up this file a bit. Just a thought.

##########
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:
       is this default arg only used in the test? If so, it may be simpler to 
just use a static value in the test or just spy on this method and see if it 
got called. I'm not sure if testing against the value from this method adds 
much value in the test if the test is for checking that 
`UNSAFE_componentWillReceiveProps` called this action. If you are looking to 
see what the value is from this method, then making a separate unit test just 
for this method would be better, imo. 

##########
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:
       you could use optional chaining here if you wanted to clean this up 
more. 




----------------------------------------------------------------
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]

Reply via email to