Skip to content

Commit

Permalink
fix: set actual path to image for update-reference handler
Browse files Browse the repository at this point in the history
  • Loading branch information
DudaGod committed Apr 10, 2018
1 parent 4c1da22 commit 6c17994
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/gui/tool-runner-factory/gemini/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ module.exports = class GeminiRunner extends BaseToolRunner {
const searchBy = _.pick(test, ['suite', 'state', 'browserId']);
const currentState = _.find(this._collectionStates, searchBy);
const imagePath = this._tool.getScreenshotPath(currentState.suite, test.state.name, test.browserId);
const {metaInfo: {sessionId, url: fullUrl}, attempt} = test;
const {metaInfo: {sessionId, url: fullUrl}, attempt, actualPath} = test;

const testResult = {
suite: _.pick(currentState.suite, ['name', 'path', 'url']),
state: _.pick(currentState.state, 'name'),
browserId: currentState.browserId
};

return _.merge(testResult, {imagePath, sessionId, attempt, suite: {fullUrl}, updated: true});
return _.merge(testResult, {imagePath, sessionId, attempt, actualPath, suite: {fullUrl}, updated: true});
}
};

Expand Down
2 changes: 1 addition & 1 deletion lib/gui/tool-runner-factory/gemini/report-subscriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ module.exports = (gemini, reportBuilder, client, reportPath) => {
const result = reportBuilder.addUpdated(data);
const testResult = prepareTestResult(data);

updateReferenceImage(result, reportPath)
updateReferenceImage(_.extend(result, {actualPath: data.actualPath}), reportPath)
.then(() => client.emit(clientEvents.UPDATE_RESULT, testResult));
});

Expand Down
4 changes: 2 additions & 2 deletions lib/gui/tool-runner-factory/hermione/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = class HermioneRunner extends BaseToolRunner {
}

_prepareUpdateResult(test) {
const {suite, state, browserId, attempt} = test;
const {suite, state, browserId, attempt, actualPath} = test;

// https://github.com/mochajs/mocha/blob/v2.4.5/lib/runnable.js#L165
const fullTitle = `${suite.path.join(' ')} ${state.name}`;
Expand All @@ -65,7 +65,7 @@ module.exports = class HermioneRunner extends BaseToolRunner {
const {sessionId, url} = test.metaInfo;
const imagePath = this._tool.config.browsers[browserId].getScreenshotPath(testResult, test.assertViewState);

return _.merge({}, testResult, {imagePath, sessionId, attempt, meta: {url}, updated: true});
return _.merge({}, testResult, {imagePath, sessionId, attempt, actualPath, meta: {url}, updated: true});
}
};

Expand Down
2 changes: 1 addition & 1 deletion lib/gui/tool-runner-factory/hermione/report-subscriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = (hermione, reportBuilder, client, reportPath) => {
const result = reportBuilder.addUpdated(data);
const testResult = prepareTestResult(data);

updateReferenceImage(result, reportPath)
updateReferenceImage(_.extend(result, {actualPath: data.actualPath}), reportPath)
.then(() => client.emit(clientEvents.UPDATE_RESULT, testResult));
});

Expand Down
5 changes: 4 additions & 1 deletion lib/reporter-helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const path = require('path');
const fs = require('fs-extra');
const utils = require('./server-utils');

Expand Down Expand Up @@ -33,7 +34,9 @@ exports.saveTestCurrentImage = (testResult, reportPath) => {
};

exports.updateReferenceImage = (testResult, reportPath) => {
const src = utils.getCurrentAbsolutePath(testResult, reportPath);
const src = testResult.actualPath
? path.resolve(reportPath, testResult.actualPath)
: utils.getCurrentAbsolutePath(testResult, reportPath);

return Promise.all([
utils.copyImageAsync(src, testResult.imagePath),
Expand Down
7 changes: 6 additions & 1 deletion lib/static/modules/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ function formatTests(test) {
const {suitePath, name, acceptTestAttempt} = test;

return flatMap(test.browsers, (browser) => {
const {actualPath} = acceptTestAttempt >= 0
? browser.retries.concat(browser.result)[acceptTestAttempt]
: browser.result;

const {metaInfo, assertViewState, attempt} = browser.result;

return {
Expand All @@ -122,7 +126,8 @@ function formatTests(test) {
browserId: browser.name,
metaInfo,
assertViewState,
attempt: acceptTestAttempt >= 0 ? acceptTestAttempt : attempt
attempt,
actualPath
};
});
}
Expand Down

0 comments on commit 6c17994

Please sign in to comment.