Skip to content

Commit

Permalink
fix: rename property "reason" to "error" and "skipReason"
Browse files Browse the repository at this point in the history
  • Loading branch information
CatWithApple committed Jan 21, 2019
1 parent bdf4fdd commit 05cd649
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 53 deletions.
4 changes: 2 additions & 2 deletions lib/report-builder-factory/report-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = class ReportBuilder {

return this._addTestResult(formattedResult, {
status: SKIPPED,
reason: comment
skipReason: comment
});
}

Expand Down Expand Up @@ -84,7 +84,7 @@ module.exports = class ReportBuilder {
_addErrorResult(formattedResult) {
return this._addTestResult(formattedResult, {
status: ERROR,
reason: formattedResult.error
error: formattedResult.error
});
}

Expand Down
4 changes: 2 additions & 2 deletions lib/static/components/section/body/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class Body extends Component {

const tabs = activeResult.imagesInfo.map((imageInfo, idx) => {
const {stateName} = imageInfo;
const reason = imageInfo.reason || activeResult.reason;
const state = Object.assign({image: true, reason}, imageInfo);
const error = imageInfo.error || activeResult.error;
const state = Object.assign({image: true, error}, imageInfo);

return this._drawTab(state, stateName || idx);
});
Expand Down
6 changes: 3 additions & 3 deletions lib/static/components/section/section-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ export class SectionBrowser extends SectionBase {
}

_generateSkippedTitle() {
const {name, result: {reason}} = this.props.browser;
const {name, result: {skipReason}} = this.props.browser;
return <Fragment>
[skipped] {name}
{reason && ', reason: '}
{reason && Parser(reason)}
{skipReason && ', reason: '}
{skipReason && Parser(skipReason)}
</Fragment>;
}
}
Expand Down
10 changes: 5 additions & 5 deletions lib/static/components/state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class State extends Component {
state: PropTypes.shape({
status: PropTypes.string,
image: PropTypes.bool,
reason: PropTypes.object,
error: PropTypes.object,
expectedImg: PropTypes.object,
actualImg: PropTypes.object,
diffImg: PropTypes.object
Expand Down Expand Up @@ -53,17 +53,17 @@ class State extends Component {
}

render() {
const {status, reason, image, expectedImg, actualImg, diffImg, stateName} = this.props.state;
const {status, error, image, expectedImg, actualImg, diffImg, stateName} = this.props.state;

let elem = null;

if (isErroredStatus(status)) {
elem = <StateError image={Boolean(image)} actualImg={actualImg} reason={reason}/>;
elem = <StateError image={Boolean(image)} actualImg={actualImg} error={error}/>;
} else if (isSuccessStatus(status) || isUpdatedStatus(status) || (isIdleStatus(status) && get(expectedImg, 'path'))) {
elem = <StateSuccess status={status} expectedImg={expectedImg} />;
} else if (isFailStatus(status)) {
elem = reason
? <StateError image={Boolean(image)} actualImg={actualImg} reason={reason}/>
elem = error
? <StateError image={Boolean(image)} actualImg={actualImg} error={error}/>
: <StateFail expectedImg={expectedImg} actualImg={actualImg} diffImg={diffImg}/>;
}

Expand Down
14 changes: 7 additions & 7 deletions lib/static/components/state/state-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import Screenshot from './screenshot';
export default class StateError extends Component {
static propTypes = {
image: PropTypes.bool.isRequired,
reason: PropTypes.object.isRequired,
error: PropTypes.object.isRequired,
actualImg: PropTypes.object
};

render() {
const {image, reason, actualImg} = this.props;
const {image, error, actualImg} = this.props;

return (
<div className="image-box__image">
<div className="reason">{reasonToElements(reason)}</div>
<div className="error">{errorToElements(error)}</div>
{this._drawImage(image, actualImg)}
</div>
);
Expand All @@ -28,11 +28,11 @@ export default class StateError extends Component {
}
}

function reasonToElements(reason) {
return map(reason, (value, key) => {
function errorToElements(error) {
return map(error, (value, key) => {
return (
<div key={key} className="reason__item">
<span className="reason__item-key">{key}</span>: {value}
<div key={key} className="error__item">
<span className="error__item-key">{key}</span>: {value}
</div>
);
});
Expand Down
6 changes: 3 additions & 3 deletions lib/static/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function hasFailedImages(result) {
}

function hasNoRefImageErrors({imagesInfo = []}) {
return Boolean(imagesInfo.filter((v) => get(v, 'reason.stack', '').startsWith(NO_REF_IMAGE_ERROR)).length);
return Boolean(imagesInfo.filter((v) => get(v, 'error.stack', '').startsWith(NO_REF_IMAGE_ERROR)).length);
}

function hasFails(node) {
Expand All @@ -28,8 +28,8 @@ function isSuiteFailed(suite) {
return isFailStatus(suite.status) || isErroredStatus(suite.status);
}

function isAcceptable({status, reason = ''}) {
const stack = reason && reason.stack;
function isAcceptable({status, error = {}}) {
const stack = error.stack || '';

return isErroredStatus(status) && stack.startsWith(NO_REF_IMAGE_ERROR) || isFailStatus(status);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,14 @@
font-weight: bold;
}

.reason {
.error {
background: #f6f5f3;
padding: 5px;
margin-bottom: 5px;
font: 13px Consolas, Helvetica, monospace;
}

.reason__item-key {
.error__item-key {
font-weight: bold;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/test-adapter/gemini-test-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ module.exports = class GeminiTestResultAdapter extends TestAdapter {
}

getImagesInfo(status) {
const reason = _.isEmpty(this.error) ? null : this.error;
const error = _.isEmpty(this.error) ? null : this.error;

this.imagesInfo = status === IDLE
? [{status, expectedImg: this.getRefImg()}]
: [].concat(_.extend({status, reason}, getImagesFor(status, this)));
: [].concat(_.extend({status, error}, getImagesFor(status, this)));

return this.imagesInfo;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/test-adapter/hermione-test-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = class HermioneTestResultAdapter extends TestAdapter {
}

this.imagesInfo = this.assertViewResults.map((assertResult) => {
let status, reason;
let status, error;

if (!(assertResult instanceof Error)) {
status = SUCCESS;
Expand All @@ -50,18 +50,18 @@ module.exports = class HermioneTestResultAdapter extends TestAdapter {

if (this.isNoRefImageError(assertResult)) {
status = ERROR;
reason = _.pick(assertResult, ['message', 'stack']);
error = _.pick(assertResult, ['message', 'stack']);
}

const {stateName, refImg} = assertResult;

return _.extend({stateName, refImg, status, reason}, getImagesFor(status, this, stateName));
return _.extend({stateName, refImg, status, error}, getImagesFor(status, this, stateName));
});

// common screenshot on test fail
if (this.screenshot) {
const errorImage = _.extend(
{status: ERROR, reason: this.error},
{status: ERROR, error: this.error},
getImagesFor(ERROR, this)
);

Expand Down
6 changes: 3 additions & 3 deletions test/lib/report-builder-factory/report-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ describe('ReportBuilder', () => {

assert.match(getReportBuilderResult_(reportBuilder), {
status: ERROR,
reason: 'some-stack-trace'
error: 'some-stack-trace'
});
});

Expand Down Expand Up @@ -294,7 +294,7 @@ describe('ReportBuilder', () => {
status: ERROR,
imagesInfo: [{
stateName: 'plain', status: ERROR,
reason: {stack: `${NO_REF_IMAGE_ERROR}: ...`}
error: {stack: `${NO_REF_IMAGE_ERROR}: ...`}
}]
});

Expand All @@ -311,7 +311,7 @@ describe('ReportBuilder', () => {
status: ERROR,
imagesInfo: [{
stateName: 'plain', status: ERROR,
reason: {stack: `${NO_REF_IMAGE_ERROR}: ...`}
error: {stack: `${NO_REF_IMAGE_ERROR}: ...`}
}]
});

Expand Down
18 changes: 9 additions & 9 deletions test/lib/static/components/section/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('<Body />', () => {

it('should call "acceptTest" action on Accept button click', () => {
const retries = [];
const imagesInfo = [{status: ERROR, actualImg: mkImg_(), reason: {}, image: true}];
const imagesInfo = [{status: ERROR, actualImg: mkImg_(), error: {}, image: true}];
const testResult = mkTestResult_({name: 'bro', imagesInfo});
utilsStub.isAcceptable.withArgs(imagesInfo[0]).returns(true);

Expand All @@ -60,8 +60,8 @@ describe('<Body />', () => {

it('should render state for each state image', () => {
const imagesInfo = [
{stateName: 'plain1', status: ERROR, actualImg: mkImg_(), reason: {}},
{stateName: 'plain2', status: ERROR, actualImg: mkImg_(), reason: {}}
{stateName: 'plain1', status: ERROR, actualImg: mkImg_(), error: {}},
{stateName: 'plain2', status: ERROR, actualImg: mkImg_(), error: {}}
];
const testResult = mkTestResult_({name: 'bro', imagesInfo});

Expand All @@ -70,7 +70,7 @@ describe('<Body />', () => {
assert.lengthOf(component.find('.tab'), 2);
});

it('should not render state if state images does not exist and test passed succesfully', () => {
it('should not render state if state images does not exist and test passed successfully', () => {
const testResult = mkTestResult_({status: SUCCESS});

const component = mkConnectedComponent(<Body result={testResult} suite={{name: 'some-suite'}} />);
Expand All @@ -80,7 +80,7 @@ describe('<Body />', () => {

it('should render additional tab if test errored without screenshot', () => {
const imagesInfo = [{stateName: 'plain1', status: SUCCESS, expectedImg: mkImg_()}];
const testResult = mkTestResult_({status: ERROR, multipleTabs: true, reason: {}, imagesInfo});
const testResult = mkTestResult_({status: ERROR, multipleTabs: true, error: {}, imagesInfo});

const component = mkConnectedComponent(<Body result={testResult} suite={{name: 'some-suite'}} />);

Expand All @@ -90,7 +90,7 @@ describe('<Body />', () => {
describe('errored additional tab', () => {
it('should render if test errored without screenshot and tool can use multi tabs', () => {
const imagesInfo = [{stateName: 'plain1', status: SUCCESS, expectedImg: mkImg_()}];
const testResult = mkTestResult_({status: ERROR, multipleTabs: true, reason: {}, imagesInfo});
const testResult = mkTestResult_({status: ERROR, multipleTabs: true, error: {}, imagesInfo});

const component = mkConnectedComponent(<Body result={testResult} suite={{name: 'some-suite'}} />);

Expand All @@ -99,7 +99,7 @@ describe('<Body />', () => {

it('should not render if tool does not use multi tabs', () => {
const imagesInfo = [{stateName: 'plain1', status: SUCCESS, expectedImg: mkImg_()}];
const testResult = mkTestResult_({status: ERROR, multipleTabs: false, reason: {}, screenshot: 'some-screen', imagesInfo});
const testResult = mkTestResult_({status: ERROR, multipleTabs: false, error: {}, screenshot: 'some-screen', imagesInfo});

const component = mkConnectedComponent(<Body result={testResult} suite={{name: 'some-suite'}} />);

Expand All @@ -108,7 +108,7 @@ describe('<Body />', () => {

it('should not render if test errored with screenshot', () => {
const imagesInfo = [{stateName: 'plain1', status: SUCCESS, expectedImg: mkImg_()}];
const testResult = mkTestResult_({status: ERROR, multipleTabs: true, reason: {}, screenshot: 'some-screen', imagesInfo});
const testResult = mkTestResult_({status: ERROR, multipleTabs: true, error: {}, screenshot: 'some-screen', imagesInfo});

const component = mkConnectedComponent(<Body result={testResult} suite={{name: 'some-suite'}} />);

Expand All @@ -118,7 +118,7 @@ describe('<Body />', () => {
[SUCCESS, FAIL].forEach((status) => {
it(`should not render if test ${status}ed`, () => {
const imagesInfo = [{stateName: 'plain1', status: SUCCESS, expectedImg: mkImg_()}];
const testResult = mkTestResult_({status, multipleTabs: true, reason: {}, imagesInfo});
const testResult = mkTestResult_({status, multipleTabs: true, error: {}, imagesInfo});

const component = mkConnectedComponent(<Body result={testResult} suite={{name: 'some-suite'}} />);

Expand Down
14 changes: 7 additions & 7 deletions test/lib/static/components/section/section-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ const skipStatus = 'skipped';

const browserRetries = [
mkTestResult_({
reason: {
error: {
message: 'messageStub',
stack: 'stackStub'
},
status: 'error'
})
];

function mkSectionBrowserComponent({name, retries = [], reason = null, status = '', initialState}) {
function mkSectionBrowserComponent({name, retries = [], skipReason = null, status = '', initialState}) {
const browser = mkBrowserResult({
name,
result: mkTestResult_({
reason,
skipReason,
status,
imagesInfo: [
{
status,
reason: {
error: {
message: 'messageStub',
stack: 'stackStub'
},
Expand Down Expand Up @@ -69,7 +69,7 @@ describe('<SectionBrowser/>', () => {
it('should show reason for skipped test', () => {
const component = mkSectionBrowserComponent({
name: browserName,
reason: skipReason,
skipReason,
status: skipStatus
});

Expand Down Expand Up @@ -105,7 +105,7 @@ describe('<SectionBrowser/>', () => {
it('should show reason for skipped test with retries', () => {
const component = mkSectionBrowserComponent({
name: browserName,
reason: skipReason,
skipReason,
retries: browserRetries,
status: skipStatus
});
Expand All @@ -124,7 +124,7 @@ describe('<SectionBrowser/>', () => {
it('should show attempts for skipped test with retries', () => {
const component = mkSectionBrowserComponent({
name: browserName,
reason: skipReason,
skipReason,
retries: browserRetries,
status: skipStatus,
initialState: {view: {expand: 'all'}}
Expand Down
8 changes: 4 additions & 4 deletions test/lib/test-adapter/gemini-test-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('gemini test adapter', () => {
});
});

it('with empty "reason"', () => {
it('with empty "error"', () => {
const geminiTestAdapter = new StubGeminiTestResultAdapter({});
serverUtilsStub.getImagesFor
.withArgs('some-status', geminiTestAdapter)
Expand All @@ -69,11 +69,11 @@ describe('gemini test adapter', () => {
geminiTestAdapter.getImagesInfo('some-status');

assert.deepEqual(geminiTestAdapter.imagesInfo, [
{status: 'some-status', reason: null, expectedImg: 'image-data'}
{status: 'some-status', error: null, expectedImg: 'image-data'}
]);
});

it('with "reason"', () => {
it('with "error"', () => {
const geminiTestAdapter = new StubGeminiTestResultAdapter({message: 'msg', stack: 'stck'});
serverUtilsStub.getImagesFor
.withArgs('some-status', geminiTestAdapter)
Expand All @@ -82,7 +82,7 @@ describe('gemini test adapter', () => {
geminiTestAdapter.getImagesInfo('some-status');

assert.deepEqual(geminiTestAdapter.imagesInfo, [
{status: 'some-status', reason: {message: 'msg', stack: 'stck'}, expectedImg: 'image-data'}
{status: 'some-status', error: {message: 'msg', stack: 'stck'}, expectedImg: 'image-data'}
]);
});
});
Expand Down

0 comments on commit 05cd649

Please sign in to comment.