-
Notifications
You must be signed in to change notification settings - Fork 64
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
feat: add ability to run local browsers without specified browserVersion #1046
base: master
Are you sure you want to change the base?
Conversation
189f8f1
to
3ee0266
Compare
export const resolveLatestChromeVersion = _.memoize(async (force = false): Promise<string> => { | ||
if (!force) { | ||
const platform = getBrowserPlatform(); | ||
const existingLocallyBrowserVersion = registry.getMatchedBrowserVersion(BrowserName.CHROME, platform); | ||
|
||
if (existingLocallyBrowserVersion) { | ||
return existingLocallyBrowserVersion; | ||
} | ||
} | ||
|
||
return retryFetch(CHROME_FOR_TESTING_LATEST_STABLE_API_URL) | ||
.then(res => res.text()) | ||
.catch(() => { | ||
throw new Error("Couldn't resolve latest chrome version"); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Достаем либо "какую-то локально имеющуюся".
Если "какой-то" локально нет, ходим в АПИ-шку и достаем последнюю оттуда.
Также всегда ходим в АПИ-шку при явном вызове install-deps
(force === true, если вызвали npx testplane install-deps
)
const CHROME_FOR_TESTING_VERSIONS_API_URL = "https://googlechromelabs.github.io/chrome-for-testing"; | ||
export const CHROME_FOR_TESTING_MILESTONES_API_URL = `${CHROME_FOR_TESTING_VERSIONS_API_URL}/latest-versions-per-milestone.json`; | ||
export const CHROME_FOR_TESTING_LATEST_STABLE_API_URL = `${CHROME_FOR_TESTING_VERSIONS_API_URL}/LATEST_RELEASE_STABLE`; | ||
|
||
export const GECKODRIVER_CARGO_TOML = "https://raw.githubusercontent.com/mozilla/geckodriver/release/Cargo.toml"; | ||
|
||
const FIREFOX_VERSIONS_VERSIONS_API_URL = "https://product-details.mozilla.org/1.0"; | ||
export const FIREFOX_VERSIONS_ALL_VERSIONS_API_URL = `${FIREFOX_VERSIONS_VERSIONS_API_URL}/firefox.json`; | ||
export const FIREFOX_VERSIONS_LATEST_VERSIONS_API_URL = `${FIREFOX_VERSIONS_VERSIONS_API_URL}/firefox_versions.json`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут использую еще пару ручек тех же самых хостов
export const resolveEdgeVersion = _.once(async () => { | ||
const platform = getBrowserPlatform(); | ||
|
||
switch (platform) { | ||
case BrowserPlatform.LINUX: | ||
return resolveLinuxEdgeVersion(); | ||
|
||
case BrowserPlatform.WIN32: | ||
case BrowserPlatform.WIN64: | ||
return resolveWindowsEdgeVersion(); | ||
|
||
case BrowserPlatform.MAC: | ||
case BrowserPlatform.MAC_ARM: | ||
return resolveMacEdgeVersion(); | ||
|
||
default: | ||
throw new Error(`Unsupported platform: "${platform}"`); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут вычисляем, какая версия edge локально установлена на компьютере
export const resolveLatestFirefoxVersion = _.memoize(async (force = false): Promise<string> => { | ||
if (!force) { | ||
const platform = getBrowserPlatform(); | ||
const existingLocallyBrowserVersion = registry.getMatchedBrowserVersion(BrowserName.FIREFOX, platform); | ||
|
||
if (existingLocallyBrowserVersion) { | ||
return existingLocallyBrowserVersion; | ||
} | ||
} | ||
|
||
return retryFetch(FIREFOX_VERSIONS_LATEST_VERSIONS_API_URL) | ||
.then(res => res.json()) | ||
.then(({ LATEST_FIREFOX_VERSION }) => LATEST_FIREFOX_VERSION) | ||
.catch(() => { | ||
throw new Error("Couldn't resolve latest firefox version"); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Аналогично "chrome"
export const resolveSafariVersion = _.once( | ||
() => | ||
new Promise<string>((resolve, reject) => { | ||
const getSafariVersionError = new Error("Couldn't retrive safari version."); | ||
|
||
exec("mdls -name kMDItemVersion /Applications/Safari.app", (err, stdout) => { | ||
if (err) { | ||
reject(getSafariVersionError); | ||
return; | ||
} | ||
|
||
const regExpResult = /kMDItemVersion = "(.*)"/.exec(stdout); | ||
|
||
if (regExpResult && regExpResult[1]) { | ||
resolve(regExpResult[1]); | ||
} else { | ||
reject(getSafariVersionError); | ||
} | ||
}); | ||
}), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Аналогично edge: достаем локально имеющуюся версию safari
3ee0266
to
3291b53
Compare
No description provided.