Skip to content

Commit

Permalink
Fixed bug in test filters and as a result couldn't filter passed/fail…
Browse files Browse the repository at this point in the history
…ed methonds anymore.
  • Loading branch information
kajdreef committed Oct 26, 2020
1 parent 3b800b1 commit 5386f3d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
11 changes: 5 additions & 6 deletions src/components/common/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import Tooltip from '@material-ui/core/Tooltip';
import HelpIcon from '@material-ui/icons/Help';
import './Menu.scss'

const Menu = ({ title = "", description=[], onChange = (e) => console.log(e), entries = [] }) => {
console.log(description)

const Menu = ({ title = "", description=[], onChange=(e) => console.log(e), entries = [] }) => {
let tooltip = description.length === 0 ? null : (
<Tooltip title={
<Tooltip
title={
<div className="content"> {
description.map(line => (<div>{line}</div>))}
description.map((line, index) => (<div key={index}>{line}</div>))}
</div>}>
<HelpIcon fontSize="small" />
</Tooltip>
Expand All @@ -21,7 +20,7 @@ const Menu = ({ title = "", description=[], onChange = (e) => console.log(e), en
<select onChange={onChange}>
<option> -- select an option -- </option>
{entries.map((entry) => (
<option key={entry.key} value={entry.key}>{entry.value}</option>
<option key={entry.key} value={entry.value}>{entry.value}</option>
))}
</select>
</div>
Expand Down
9 changes: 7 additions & 2 deletions src/components/filters/test_filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export function filter_by_test_passed(current_state, all_data, value) {

let new_state;
switch (value) {
case 1: // Present only passing methods
case TEST_RESULT.PASS:
console.info(`Filter all test methods that fail Index: ${value}, was chosen.`);
new_state = test_filter(current_state, (edge) => edge.test_result)
break;
case 2: // Present only failing methods
case TEST_RESULT.FAIL:
console.info(`Filter all test methods that pass Index: ${value}, was chosen.`);
new_state = test_filter(current_state, (edge) => !edge.test_result)
break;
Expand Down Expand Up @@ -165,3 +165,8 @@ export const TEST_TYPES = {
INTEGRATION: 'Integration',
SYSTEM: 'System',
}

export const TEST_RESULT = {
PASS: 'Only Pass',
FAIL: 'Only Fail'
}
16 changes: 7 additions & 9 deletions src/components/routes/TestMatrixView.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import ResultTextBox from '../common/ResultTextBox';
import './TestMatrixView.scss';

// Filter functions
import { filter_by_num_method_covered, filter_by_test_passed, filter_by_coexecuted_tests, filter_by_test_type, TEST_TYPES} from '../filters/test_filters';
import { filter_by_num_method_covered, filter_by_test_passed, filter_by_coexecuted_tests, filter_by_test_type, TEST_TYPES, TEST_RESULT} from '../filters/test_filters';
import { filter_method_by_number_of_times_tested, filter_by_coexecuted_methods } from '../filters/method_filters';
import { process_data, FunctionMap } from '../filters/data_processor';

Expand Down Expand Up @@ -79,7 +79,7 @@ class TestMatrixView extends Component {
return await json(`${API_ROOT}/commits/${project_name}`)
.then(response => {
let commits = response.commits.map(commit => {
return { value: commit.sha, display: commit.sha }
return { key: commit.id, value: commit.sha, display: commit.sha }
});
return commits;
})
Expand All @@ -89,7 +89,7 @@ class TestMatrixView extends Component {
return await json(`${API_ROOT}/projects`)
.then(response => {
let projects = response.projects.map(project => {
return { value: project.project_name, display: project.project_name }
return { key: project.id, value: project.project_name};
});

return projects;
Expand Down Expand Up @@ -222,9 +222,7 @@ class TestMatrixView extends Component {
"- System: Only tests that cover methods across multiple packages."
]}
onChange={(event) => {

const test_type = event.target.value;
console.log(event.target)
let new_filter_map = new FunctionMap(current_filter_map);
new_filter_map.add_function("filter_by_test_type", filter_by_test_type, test_type)

Expand All @@ -233,17 +231,17 @@ class TestMatrixView extends Component {
})
}} />
<Menu title="Test Pass Filter"
entries={[{ key: 0, value: "All" }, { key: 1, value: "Only Pass" }, { key: 2, value: "Only Fail" }]}
entries={[{ key: 0, value: "All" }, { key: 1, value: TEST_RESULT.PASS }, { key: 2, value: TEST_RESULT.FAIL }]}
description={[
"Filter based on the result of each test case:",
"- All: Present all test cases regardless on passed or failed",
"- Only Pass: Present only passed test cases",
"- Only Fail: Present only failed test cases",
]}
onChange={(event) => {
const index = parseInt(event.target.value);
onChange={(event, index) => {
const test_result = event.target.value;
let new_filter_map = new FunctionMap(current_filter_map);
new_filter_map.add_function("filter_by_test_passed", filter_by_test_passed, index)
new_filter_map.add_function("filter_by_test_passed", filter_by_test_passed, test_result)

this.setState({
history: this.state.history.concat(new_filter_map)
Expand Down

0 comments on commit 5386f3d

Please sign in to comment.