Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
feat(eyes-selenium): close batches on getAllTestResults
Browse files Browse the repository at this point in the history
  • Loading branch information
astappiev committed Sep 17, 2019
1 parent af38cfe commit 94c3ffb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/eyes-selenium/lib/runner/ClassicRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class ClassicRunner extends EyesRunner {
for (const testResults of this._allTestResult) {
allResults.push(new TestResultContainer(testResults));
}

await this._closeAllBatches();
return new TestResultsSummary(allResults);
}
}
Expand Down
19 changes: 19 additions & 0 deletions packages/eyes-selenium/lib/runner/EyesRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ class EyesRunner {
async getAllTestResults(shouldThrowException) { // eslint-disable-line no-unused-vars
throw new TypeError('The method is not implemented!');
}

/**
* @protected
* @return {Promise<void>}
*/
async _closeAllBatches() {
if (this._eyesInstances.length > 0) {
const batchIds = new Set();
for (const eyesInstance of this._eyesInstances) {
const batchId = eyesInstance.getBatch().getId();
if (!batchIds.has(batchId)) {
batchIds.add(batchId);
}
}

const promises = Array.from(batchIds).map(batchId => this._eyesInstances[0]._serverConnector.deleteBatchSessions(batchId));
await Promise.all(promises);
}
}
}

exports.EyesRunner = EyesRunner;
7 changes: 2 additions & 5 deletions packages/eyes-selenium/lib/runner/VisualGridRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ class VisualGridRunner extends EyesRunner {
* @return {Promise<TestResultsSummary>}
*/
async getAllTestResults(shouldThrowException = true) {
if (this._eyesInstances.length === 1) {
return this._eyesInstances[0].closeAndReturnResults(shouldThrowException);
}

if (this._eyesInstances.length > 1) {
if (this._eyesInstances.length > 0) {
const resultsPromise = [];
const allResults = [];

Expand All @@ -50,6 +46,7 @@ class VisualGridRunner extends EyesRunner {
}
}

await this._closeAllBatches();
return new TestResultsSummary(allResults);
}

Expand Down

0 comments on commit 94c3ffb

Please sign in to comment.