8000 fix: enable correct suite through suite collection api by sipayRT · Pull Request #760 · gemini-testing/gemini · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.
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
7 changes: 4 additions & 3 deletions lib/suite-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ module.exports = class SuiteCollection {
}

_disableEntity(obj, browser) {
this._originalBrowsers[obj.fullName] = obj.browsers;
this._originalBrowsers[obj.fullName + obj.file] = obj.browsers;
obj.browsers = browser ? _.without(obj.browsers, browser) : [];
}

_enableEntity(obj, browser) {
if (!browser && this._originalBrowsers[obj.fullName]) {
obj.browsers = _.union(obj.browsers, this._originalBrowsers[obj.fullName]);
const suiteKey = obj.fullName + obj.file;
if (!browser && this._originalBrowsers[suiteKey]) {
obj.browsers = _.union(obj.browsers, this._originalBrowsers[suiteKey]);
}

if (browser) {
Expand Down
21 changes: 21 additions & 0 deletions test/unit/suite-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const proxyquire = require('proxyquire');
const mkTree = require('../util').makeSuiteTree;
const mkSuite = require('../util').makeSuiteStub;

describe('suite-collection', () => {
const sandbox = sinon.sandbox.create();
Expand Down Expand Up @@ -385,6 +386,26 @@ describe('suite-collection', () => {
assert.deepEqual(tree.child.browsers, ['b1', 'b2']);
});

it('should enable only current suite if there are the same suites exists in the tree', () => {
const suite1 = mkSuite({
name: 'suite',
browsers: ['b1', 'b2'],
file: 'some/path.js'
});
const suite2 = mkSuite({
name: 'suite',
browsers: ['b3', 'b4'],
file: 'another/path.js'
});

new SuiteCollection([suite1, suite2])
.disableAll()
.enable(suite1);

assert.deepEqual(suite1.browsers, ['b1', 'b2']);
assert.deepEqual(suite2.browsers, []);
});

it('should fail on attempt to enable unknown suite', () => {
const tree = mkTree({
suite: []
Expand Down
1 change: 1 addition & 0 deletions test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function makeSuiteStub(opts) {
suite.addState(state);
});
suite.url = opts.url;
suite.file = opts.file;

return suite;
}
Expand Down
0