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

feat: add ability to run local browsers without specified browserVersion #1046

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

KuznetsovRoman
Copy link
Member

No description provided.

@KuznetsovRoman KuznetsovRoman force-pushed the TESTPLANE-386.latest_local_browser branch 2 times, most recently from 189f8f1 to 3ee0266 Compare December 26, 2024 13:09
Comment on lines +80 to +95
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");
});
});
Copy link
Member Author

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)

Comment on lines +3 to +11
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`;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут использую еще пару ручек тех же самых хостов

Comment on lines +49 to +67
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}"`);
}
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут вычисляем, какая версия edge локально установлена на компьютере

Comment on lines +71 to +87
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");
});
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аналогично "chrome"

Comment on lines +4 to +24
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);
}
});
}),
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аналогично edge: достаем локально имеющуюся версию safari

@KuznetsovRoman KuznetsovRoman force-pushed the TESTPLANE-386.latest_local_browser branch from 3ee0266 to 3291b53 Compare December 26, 2024 17:35
Copy link
Member

@DudaGod DudaGod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like good (just clurify: i didn't see previous PRs with implementation local browsers).

test/src/browser-installer/safari/browser.ts Outdated Show resolved Hide resolved
@KuznetsovRoman KuznetsovRoman force-pushed the TESTPLANE-386.latest_local_browser branch 2 times, most recently from f665bb1 to 63f96ba Compare January 13, 2025 02:22
@KuznetsovRoman KuznetsovRoman force-pushed the TESTPLANE-386.latest_local_browser branch from 63f96ba to 7827fd0 Compare January 13, 2025 02:23
@KuznetsovRoman KuznetsovRoman merged commit b946892 into master Jan 13, 2025
2 checks passed
@KuznetsovRoman KuznetsovRoman deleted the TESTPLANE-386.latest_local_browser branch January 13, 2025 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants