Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pplt 2492 #1395

Closed
wants to merge 5 commits into from
Closed
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
3 changes: 2 additions & 1 deletion packages/webdriver-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"dependencies": {
"@percy/config": "1.27.3",
"@percy/sdk-utils": "1.27.3"
"@percy/sdk-utils": "1.27.3",
"colors": "^1.4.0"
}
}
4 changes: 4 additions & 0 deletions packages/webdriver-utils/src/providers/genericProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import MetaDataResolver from '../metadata/metaDataResolver.js';
import Tile from '../util/tile.js';
import Driver from '../driver.js';
import Cache from '../util/cache.js';
import CapabilitiesValidator from '../util/capabilityValidator.js';
const { request } = utils;

const DEVICES_CONFIG_URL = 'https://storage.googleapis.com/percy-utils/devices.json';
Expand Down Expand Up @@ -47,6 +48,9 @@ export default class GenericProvider {
log.debug(`Passed capabilities -> ${JSON.stringify(this.capabilities)}`);
const caps = await this.driver.getCapabilites();
log.debug(`Fetched capabilities -> ${JSON.stringify(caps)}`);
log.debug('Validating Capabilites');
const validator = new CapabilitiesValidator(caps);
validator.validateBrowserOSVersions();
this.metaData = await MetaDataResolver.resolve(this.driver, caps, this.capabilities);
}

Expand Down
65 changes: 65 additions & 0 deletions packages/webdriver-utils/src/util/capabilityValidator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import fs from 'fs';
import path from 'path';
import colors from 'colors/safe.js';

export default class CapabilitiesValidator {
constructor(capabilities) {
this.capabilities = capabilities;
}

validateBrowserOSVersions() {
const cwd = process.cwd();
const excludeBrowserData = JSON.parse(
fs.readFileSync(
path.join(
cwd,
'packages/webdriver-utils/src/util/exclude_browsers.json'
)
)
);

const { os, osVersion, browserName, browserVersion } = this.capabilities;

if (!os || !osVersion || !browserName || !browserVersion) {
colors.yellow(
console.warn(
`OS/Browser Combination ${os}: ${osVersion}: ${browserName} ${browserName} is not supported in Percy`
)
);
}
if (excludeBrowserData?.os[os]) {
const osData = excludeBrowserData?.os[os];
if (osData?.os_versions) {
const osExists = osData.os_versions.some((element) => {
return element === osVersion;
});
if (osExists) {
colors.yellow(
console.warn(
`OS Version ${os}: ${osVersion} is not supported in Percy`
)
);
}
}
if (osData?.browsers) {
const browserData = osData?.browsers[browserName.toLowerCase()];
if (browserData && browserData.min_version === 'all') {
console.warn(
colors.yellow(
`Browser ${browserName} is not supported in Percy on ${os} ${osVersion}`
)
);
} else if (
browserData &&
parseInt(browserVersion, 10) < parseInt(browserData.min_version, 10)
) {
console.warn(
colors.yellow(
`Browser Version ${browserName}: ${browserVersion} is not supported in Percy on ${os} ${osVersion}`
)
);
}
}
}
}
}
35 changes: 35 additions & 0 deletions packages/webdriver-utils/src/util/exclude_browsers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"os": {
"OS X": {
"os_versions": ["Snow Leopard", "Lion", "Mountain Lion", "Mavericks", "Yosemite", "El Capitan", "Sierra", "High Sierra", "Mojave"],
"browsers": {
"chrome": {
"min_version": "92"
},
"firefox": {
"min_version": "92"
},
"edge": {
"min_version": "92"
}
}
},
"Windows": {
"os_versions": ["8.1", "8.0", "7", "XP"],
"browsers": {
"chrome": {
"min_version": "92"
},
"firefox": {
"min_version": "92"
},
"edge": {
"min_version": "92"
},
"ie": {
"min_version": "all"
}
}
}
}
}
Loading