• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dataunitylab / relational-playground / #109

10 Sep 2025 06:35PM UTC coverage: 78.51% (+0.1%) from 78.407%
#109

push

michaelmior
Fix SqlEditor test for React context refactoring

Signed-off-by: Michael Mior <mmior@mail.rit.edu>

526 of 743 branches covered (70.79%)

Branch coverage included in aggregate %.

1034 of 1244 relevant lines covered (83.12%)

14373.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.29
/src/CurrentRelExpr.js
1
// @flow
2
import React, {useState} from 'react';
3
import {useDispatch, useSelector} from 'react-redux';
4
import {changeExpr} from './modules/data';
5
import RelExpr from './RelExpr';
6
import RelExprTree from './RelExprTree';
7
import {useReactGA} from './contexts/ReactGAContext';
8

9
import type {StatelessFunctionalComponent} from 'react';
10
import {disableOptimization, enableOptimization} from './modules/relexp';
11

12
import type {State} from './modules/relexp';
13

14
type Props = {
15
  ReactGA?: any, // For backwards compatibility with tests
16
};
17

18
const CurrentRelExpr: StatelessFunctionalComponent<Props> = (props) => {
2✔
19
  const dispatch = useDispatch();
4✔
20
  const expr = useSelector<{relexp: State}, _>((state) => state.relexp.expr);
6✔
21
  const [showTree, setShowTree] = useState(false);
4✔
22
  const optimized = useSelector<{relexp: State}, _>(
4✔
23
    (state) => state.relexp.optimized
6✔
24
  );
25
  const contextReactGA = useReactGA();
4✔
26
  const ReactGA = props.ReactGA || contextReactGA;
4✔
27

28
  function handleTreeInputChange(event: SyntheticInputEvent<HTMLInputElement>) {
29
    if (ReactGA) {
2!
30
      ReactGA.event({
2✔
31
        category: 'Toggle Expression Display',
32
        action: event.target.checked ? 'tree' : 'linear',
2✔
33
      });
34
    }
35
    setShowTree(event.target.checked);
2✔
36
  }
37

38
  function handleOptimizeInputChange(
39
    event: SyntheticInputEvent<HTMLInputElement>
40
  ) {
41
    if (event.target.checked) {
2✔
42
      dispatch(enableOptimization('join'));
1✔
43
    } else {
44
      dispatch(disableOptimization());
1✔
45
    }
46
  }
47

48
  const relExp = showTree ? (
4✔
49
    <RelExprTree
50
      expr={expr}
51
      changeExpr={(data, element) => dispatch(changeExpr(data, element))}
×
52
    />
53
  ) : (
54
    <RelExpr
55
      expr={expr}
56
      changeExpr={(data, element) => dispatch(changeExpr(data, element))}
×
57
    />
58
  );
59

60
  return (
4✔
61
    <div className="relExprContainer">
62
      <div className="toggle">
63
        <label>
64
          Tree view
65
          <input
66
            type="checkbox"
67
            checked={showTree}
68
            onChange={handleTreeInputChange}
69
          />
70
        </label>
71
      </div>
72
      <div className="toggle">
73
        <label>
74
          Query Optimization
75
          <input
76
            type="checkbox"
77
            checked={optimized}
78
            onChange={handleOptimizeInputChange}
79
          />
80
        </label>
81
      </div>
82

83
      {/* Relational algebra expression display */}
84
      <div className="expr">{relExp}</div>
85
    </div>
86
  );
87
};
88

89
export default CurrentRelExpr;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc