Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test history tab to Result page #276

Merged
merged 2 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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