Skip to content
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
8 changes: 2 additions & 6 deletions lib/view-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports = class ViewModel {

_addTestResult(result, props) {
const browserId = result.browserId;
const rootUrl = this._getRootUrlforBrowser(browserId);
const browserConfig = this._config.forBrowser(browserId);
const suite = result.suite;
const metaInfo = {
url: suite.fullUrl,
Expand All @@ -101,7 +101,7 @@ module.exports = class ViewModel {
};

const testResult = _.assign({
suiteUrl: rootUrl + suite.url,
suiteUrl: browserConfig.getAbsoluteUrl(suite.url),
name: browserId,
metaInfo: JSON.stringify(metaInfo, null, 4) || 'Meta info is not available'
}, props);
Expand All @@ -126,10 +126,6 @@ module.exports = class ViewModel {
stateInBrowser.result = testResult;
}

_getRootUrlforBrowser(browserId) {
return this._config.forBrowser(browserId).rootUrl;
}

static hasFails(node) {
return walk(node, ViewModel.hasFails, node.result && (node.result.error || node.result.fail));
}
Expand Down
3 changes: 2 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ describe('HTML Reporter', () => {
emitter = new QEmitter();
emitter.config = {
forBrowser: sinon.stub().returns({
rootUrl: 'browser/root/url'
rootUrl: 'browser/root/url',
getAbsoluteUrl: _.noop
})
};
emitter.events = events;
Expand Down
18 changes: 16 additions & 2 deletions test/lib/view-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const ViewModel = require('../../lib/view-model');
describe('ViewModel', () => {
const sandbox = sinon.sandbox.create();

const mkViewModel_ = () =>{
const config = {forBrowser: sandbox.stub().returns({})};
const mkViewModel_ = (options) =>{
options = _.defaults(options || {}, {getAbsoluteUrl: _.noop});
const browserConfigStub = {getAbsoluteUrl: options.getAbsoluteUrl};
const config = {forBrowser: sandbox.stub().returns(browserConfigStub)};
return new ViewModel(config);
};

Expand Down Expand Up @@ -141,4 +143,16 @@ describe('ViewModel', () => {
assert.match(getModelResult_(model), {error: true});
});
});

it('should resolve absolute suite url', () => {
const model = mkViewModel_({
getAbsoluteUrl: sandbox.stub().withArgs('/some/url').returns('http://expected.url')
});

model.addSuccess(stubTest_({suite: {url: '/some/url'}}));

const suiteUrl = getModelResult_(model).suiteUrl;

assert.equal(suiteUrl, 'http://expected.url');
});
});