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

chore(selenium): add beta suffix + add release data to report #1957

Open
wants to merge 3 commits into
base: collect-beta-browsers
Choose a base branch
from
Open
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
25 changes: 21 additions & 4 deletions scripts/selenium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {RESULTS_DIR} from "../lib/constants.js";
import filterVersionsLib from "../lib/filter-versions.js";
import getSecrets from "../lib/secrets.js";

import type {BrowserName} from "@mdn/browser-compat-data";
import type {BrowserName, BrowserStatement} from "@mdn/browser-compat-data";

import "../lib/selenium-keepalive.js";

Expand Down Expand Up @@ -122,6 +122,16 @@ const earliestBrowserVersions = {
safari: "5.1",
};

/**
* Checks if a browser version has beta status.
* @param browser - The browser name.
* @param version - The browser version.
* @returns True if the version has beta status, false otherwise.
*/
const isBeta = (browser: BrowserName, version: string): boolean => {
return (bcdBrowsers[browser] as BrowserStatement).releases[version]?.status === 'beta';
}

/**
* Returns a formatted string representing the browser name, version, and operating system.
* @param browser - The browser name.
Expand All @@ -134,6 +144,9 @@ const prettyName = (
version: string,
os: string,
): string => {
if (isBeta(browser, version)) {
version = `${version}-beta`;
}
return `${bcdBrowsers[browser].name} ${version} on ${os}`;
};

Expand Down Expand Up @@ -646,10 +659,14 @@ const run = async (
const downloadUrl = await downloadEl.getAttribute("href");

if (!ctx.testenv) {
const filename = path.basename(new URL(downloadUrl).pathname);
let filename = path.basename(new URL(downloadUrl).pathname);
if (isBeta(browser, version)) {
filename = filename.replace(browser, `${browser}-beta`);
}
log(task, `Downloading ${filename} ...`);
const report = await (await fetch(downloadUrl)).buffer();
await fs.writeFile(path.join(RESULTS_DIR, filename), report);
const report = await (await fetch(downloadUrl)).json() as any;
report['release'] = bcdBrowsers[browser].releases[version];
await fs.writeFile(path.join(RESULTS_DIR, filename), JSON.stringify(report));
}
} finally {
driver.quit().catch(() => {});
Expand Down
Loading