Skip to content

Commit

Permalink
Add test history tab to Result page (#276)
Browse files Browse the repository at this point in the history
* Add test history tab to Result page

* Get rid of buggy Tooltip
  • Loading branch information
john-dupuy committed Jan 14, 2022
1 parent af87998 commit c8fef18
Show file tree
Hide file tree
Showing 7 changed files with 400 additions and 64 deletions.
2 changes: 1 addition & 1 deletion backend/ibutsu_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_app(**extra_config):
config.from_mapping(os.environ)
# convert str to bool for USER_LOGIN_ENABLED
if isinstance(config.get("USER_LOGIN_ENABLED", True), str):
config["USER_LOGIN_ENABLED"] = config["USER_LOGIN_ENABLED"][0] in ["y", "t", "1"]
config["USER_LOGIN_ENABLED"] = config["USER_LOGIN_ENABLED"].lower()[0] in ["y", "t", "1"]
if config.get("POSTGRESQL_HOST") and config.get("POSTGRESQL_DATABASE"):
# If you have environment variables, like when running on OpenShift, create the db url
config.update(
Expand Down
19 changes: 16 additions & 3 deletions frontend/src/components/classify-failures.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
FilterTable,
MultiClassificationDropdown,
MetaFilter,
ResultView
} from './index';


Expand Down Expand Up @@ -71,10 +72,22 @@ export class ClassifyFailuresTable extends React.Component {

onCollapse(event, rowIndex, isOpen) {
const { rows } = this.state;

// lazy-load the result view so we don't have to make a bunch of artifact requests
if (isOpen) {
let result = rows[rowIndex].result;
let hideSummary=true;
let hideTestObject=true;
if (result.result === "skipped") {
hideSummary=false;
hideTestObject=false;
}
rows[rowIndex + 1].cells = [{
title: <ResultView hideTestHistory={false} hideSummary={hideSummary} hideTestObject={hideTestObject} testResult={rows[rowIndex].result}/>
}]
}
rows[rowIndex].isOpen = isOpen;
this.setState({
rows
});
this.setState({rows});
}

onTableRowSelect = (event, isSelected, rowId) => {
Expand Down
25 changes: 22 additions & 3 deletions frontend/src/components/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
Tabs,
Tab
} from '@patternfly/react-core';
import { FileAltIcon, FileImageIcon, InfoCircleIcon, CodeIcon } from '@patternfly/react-icons';
import { FileAltIcon, FileImageIcon, InfoCircleIcon, CodeIcon, SearchIcon } from '@patternfly/react-icons';
import { Link } from 'react-router-dom';
import Linkify from 'react-linkify';
import ReactJson from 'react-json-view';
Expand All @@ -29,6 +29,7 @@ import { linkifyDecorator } from './decorators'
import { Settings } from '../settings';
import { getIconForResult, round } from '../utilities';
import { TabTitle } from './tabs';
import { TestHistoryTable } from './test-history';

const MockTest = {
id: null,
Expand Down Expand Up @@ -60,6 +61,7 @@ export class ResultView extends React.Component {
resultId: PropTypes.string,
hideSummary: PropTypes.bool,
hideTestObject: PropTypes.bool,
hideTestHistory: PropTypes.bool,
history: PropTypes.object,
location: PropTypes.object
}
Expand All @@ -71,7 +73,8 @@ export class ResultView extends React.Component {
id: this.props.resultId || null,
artifacts: [],
activeTab: this.getTabIndex(this.getDefaultTab()),
artifactTabs: []
artifactTabs: [],
testHistoryTable: null,
};
if (this.props.history) {
// Watch the history to update tabs
Expand Down Expand Up @@ -103,6 +106,12 @@ export class ResultView extends React.Component {
}
}

updateTab(tabIndex) {
if (tabIndex === 'test-history') {
this.getTestHistoryTable();
}
}

onTabSelect = (event, tabIndex) => {
if (this.props.history) {
const loc = this.props.history.location;
Expand All @@ -113,8 +122,13 @@ export class ResultView extends React.Component {
});
}
this.setState({activeTab: tabIndex});
this.updateTab(tabIndex);
};

getTestHistoryTable = () => {
this.setState({testHistoryTable: <TestHistoryTable testResult={this.state.testResult}/>});
}

getTestResult(resultId) {
HttpClient.get([Settings.serverUrl, 'result', resultId])
.then(response => HttpClient.handleResponse(response))
Expand Down Expand Up @@ -200,7 +214,7 @@ export class ResultView extends React.Component {
}

render() {
let { testResult, artifactTabs, activeTab } = this.state;
let { testResult, artifactTabs, activeTab, testHistoryTable } = this.state;
if (activeTab === null) {
activeTab = this.getDefaultTab();
}
Expand Down Expand Up @@ -487,6 +501,11 @@ export class ResultView extends React.Component {
</Tab>
}
{artifactTabs}
{!this.props.hideTestHistory &&
<Tab eventKey="test-history" title={<TabTitle icon={SearchIcon} text="Test History"/>} style={{backgroundColor: "white"}}>
{testHistoryTable}
</Tab>
}
{!this.props.hideTestObject &&
<Tab eventKey="test-object" title={<TabTitle icon={CodeIcon} text="Test Object" />} style={{backgroundColor: "white"}}>
<Card>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/runsummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export class RunSummary extends React.Component {
passed -= summary.xpasses;
xpassed = summary.xpasses;
}
if (summary.passes) {
passed = summary.passes;
}
return (
<React.Fragment>
{passed > 0 && <span className="pf-c-badge passed" title="Passed">{passed}</span>}
Expand Down
Loading

0 comments on commit c8fef18

Please sign in to comment.