Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Jun 27, 2018
1 parent 420aca0 commit 14b17bb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
20 changes: 15 additions & 5 deletions src/screenshots/capturer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,21 @@ export default class Capturer {
};
}

_joinWithBaseScreenshotPath (path) {
return joinPath(this.baseScreenshotsPath, path);
}

_updateScreenshotPathForTestEntry (customPath, screenshotPath) {
// NOTE: if test contains takeScreenshot action with custom path
// we should specify the most common screenshot folder in report
let screenshotPathForTestEntry = this.baseScreenshotsPath;

if (!customPath)
screenshotPathForTestEntry = dirname(screenshotPath);
if (!customPath) {
const pathForReport = this.pathPattern.getPathForReport();

screenshotPathForTestEntry = this._joinWithBaseScreenshotPath(pathForReport);
}


this.testEntry.path = screenshotPathForTestEntry;
}
Expand All @@ -74,15 +82,17 @@ export default class Capturer {
}

_getCustomScreenshotPath (customPath) {
return joinPath(this.baseScreenshotsPath, correctFilePath(customPath));
const correctedCustomPath = correctFilePath(customPath);

return this._joinWithBaseScreenshotPath(correctedCustomPath);
}

_getScreenshotPath (forError) {
const parsedPath = this.pathPattern.getPath(forError);
const path = this.pathPattern.getPath(forError);

this._incrementFileIndexes(forError);

return joinPath(this.baseScreenshotsPath, parsedPath);
return this._joinWithBaseScreenshotPath(path);
}

_getThumbnailPath (screenshotPath) {
Expand Down
11 changes: 9 additions & 2 deletions src/screenshots/path-pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ const PLACEHOLDERS = {
OS_VERSION: '${OS_VERSION}'
};

const DEFAULT_PATH_PATTERN = `${PLACEHOLDERS.DATE}_${PLACEHOLDERS.TIME}\\test-${PLACEHOLDERS.TEST_INDEX}\\${PLACEHOLDERS.USERAGENT}\\${PLACEHOLDERS.FILE_INDEX}.${SCRENSHOT_EXTENTION}`;
const QUARANTINE_MODE_DEFAULT_PATH_PATTERN = `${PLACEHOLDERS.DATE}_${PLACEHOLDERS.TIME}\\test-${PLACEHOLDERS.TEST_INDEX}\\run-${PLACEHOLDERS.QUARANTINE_ATTEMPT}\\${PLACEHOLDERS.USERAGENT}\\${PLACEHOLDERS.FILE_INDEX}.${SCRENSHOT_EXTENTION}`;
const DEFAULT_PATH_PATTERN_FOR_REPORT = `${PLACEHOLDERS.DATE}_${PLACEHOLDERS.TIME}\\test-${PLACEHOLDERS.TEST_INDEX}`;
const DEFAULT_PATH_PATTERN = `${DEFAULT_PATH_PATTERN_FOR_REPORT}\\${PLACEHOLDERS.USERAGENT}\\${PLACEHOLDERS.FILE_INDEX}.${SCRENSHOT_EXTENTION}`;
const QUARANTINE_MODE_DEFAULT_PATH_PATTERN = `${DEFAULT_PATH_PATTERN_FOR_REPORT}\\run-${PLACEHOLDERS.QUARANTINE_ATTEMPT}\\${PLACEHOLDERS.USERAGENT}\\${PLACEHOLDERS.FILE_INDEX}.${SCRENSHOT_EXTENTION}`;

export default class PathPattern {
constructor (pattern, data) {
Expand Down Expand Up @@ -109,6 +110,12 @@ export default class PathPattern {
return correctFilePath(path, SCRENSHOT_EXTENTION);
}

getPathForReport () {
const path = PathPattern._buildPath(DEFAULT_PATH_PATTERN_FOR_REPORT, this.placeholderToDataMap);

return correctFilePath(path);
}

// For testing purposes
static get PLACEHOLDERS () {
return PLACEHOLDERS;
Expand Down
4 changes: 2 additions & 2 deletions test/functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ testingEnvironments[testingEnvironmentNames.localBrowsers] = {
platform: 'Windows 10',
browserName: 'chrome',
alias: 'chrome'
}/*,
},
{
platform: 'Windows 10',
browserName: 'ie',
Expand All @@ -112,7 +112,7 @@ testingEnvironments[testingEnvironmentNames.localBrowsers] = {
platform: 'Windows 10',
browserName: 'firefox',
alias: 'firefox'
}*/
}
]
};

Expand Down

0 comments on commit 14b17bb

Please sign in to comment.