This commit is contained in:
Aleck Greenham
2017-05-06 16:32:17 +01:00
7 changed files with 155 additions and 64 deletions

View File

@@ -14,13 +14,14 @@ export function setSuiteStatus({ suiteId, status, time, message, progress }) {
};
}
export function setTestStatus({ testId, status, time = 0, message = null }) {
export function setTestStatus({ testId, status, stackTrace, time = 0, message = null }) {
return {
type: TEST_SET_STATUS,
testId,
status,
message,
stackTrace,
time,
};
}

View File

@@ -12,6 +12,7 @@ function testsReducers(state = initState.tests, action: Object): State {
flattened[`${action.testId}.status`] = action.status;
flattened[`${action.testId}.message`] = action.message;
flattened[`${action.testId}.time`] = action.time;
flattened[`${action.testId}.stackTrace`] = action.stackTrace;
return unflatten(flattened);
}

View File

@@ -51,35 +51,28 @@ class Test extends React.Component {
setParams({ test });
}
renderError() {
const { test: { message } } = this.props;
if (message) {
return (
<ScrollView>
<Text style={styles.codeHeader}>Test Error</Text>
<Text style={styles.code}>
<Text>{message}</Text>
</Text>
</ScrollView>
);
}
return null;
}
render() {
const { test: { func, status, time } } = this.props;
const { test: { stackTrace, description, func, status, time }, testContextName } = this.props;
return (
<View style={styles.container}>
{Test.renderBanner({ status, time })}
<View style={styles.content}>
{this.renderError()}
<Text style={styles.codeHeader}>Test Code Preview</Text>
<ScrollView>
<Text style={styles.code}>
<View >
<ScrollView style={styles.sectionContainer}>
<Text style={styles.heading}>{testContextName}</Text>
<Text style={styles.description}>{description}</Text>
</ScrollView>
<ScrollView style={styles.sectionContainer}>
<Text style={styles.heading}>Test Error</Text>
<Text style={styles.description}>
<Text>{stackTrace || 'None.'}</Text>
</Text>
</ScrollView>
<Text style={styles.heading}>
Test Code Preview
</Text>
<ScrollView style={styles.sectionContainer}>
<Text style={styles.description}>
{beautify(removeLastLine(removeFirstLine(func.toString())), { indent_size: 4, break_chained_methods: true })}
</Text>
</ScrollView>
@@ -93,10 +86,13 @@ Test.propTypes = {
test: PropTypes.shape({
status: PropTypes.string,
time: PropTypes.number,
message: PropTypes.string,
func: PropTypes.function,
stackTrace: PropTypes.function,
description: PropTypes.string,
}).isRequired,
testContextName: PropTypes.string,
navigation: PropTypes.shape({
setParams: PropTypes.func.isRequired,
}).isRequired,
@@ -107,27 +103,32 @@ const styles = StyleSheet.create({
flex: 1,
backgroundColor: '#ffffff',
},
content: {},
code: {
backgroundColor: '#3F373A',
color: '#c3c3c3',
padding: 5,
fontSize: 12,
sectionContainer: {
minHeight: 100,
},
codeHeader: {
fontWeight: '600',
fontSize: 18,
backgroundColor: '#000',
color: '#fff',
heading: {
padding: 5,
backgroundColor: '#0288d1',
fontWeight: '600',
color: '#ffffff',
fontSize: 16,
},
description: {
padding: 5,
fontSize: 14,
},
});
function select({ tests }, { navigation: { state: { params: { testId } } } }) {
function select({ tests, testContexts }, { navigation: { state: { params: { testId } } } }) {
const test = tests[testId];
let testContext = testContexts[test.testContextId];
while(testContext.parentContextId && testContexts[testContext.parentContextId].parentContextId) {
testContext = testContexts[testContext.parentContextId];
}
return {
test,
testContextName: testContext.name,
};
}