feat: complete TASK-WP0-03 browser gate
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
export const testBrowserSupportRelease = {
|
||||
appVersion: "1.2.3-test",
|
||||
browsers: [
|
||||
{ brand: "Google Chrome", fullVersion: "150.0.7339.1" },
|
||||
{ brand: "Microsoft Edge", fullVersion: "150.0.4078.99" },
|
||||
],
|
||||
} as const;
|
||||
|
||||
interface BrowserIdentityFixture {
|
||||
brand: string;
|
||||
fullVersion: string;
|
||||
platform?: string;
|
||||
}
|
||||
|
||||
function major(version: string) {
|
||||
return version.split(".")[0];
|
||||
}
|
||||
|
||||
function serialize(values: Array<{ brand: string; version: string }>) {
|
||||
return values.map(({ brand, version }) => `"${brand}";v="${version}"`).join(", ");
|
||||
}
|
||||
|
||||
export function browserSupportFixture(input: BrowserIdentityFixture) {
|
||||
const platform = input.platform ?? "Windows";
|
||||
const brands = [
|
||||
{ brand: "Not_A Brand", version: "99" },
|
||||
{ brand: "Chromium", version: major(input.fullVersion) },
|
||||
{ brand: input.brand, version: major(input.fullVersion) },
|
||||
];
|
||||
const fullVersionList = [
|
||||
{ brand: "Not_A Brand", version: "99.0.0.0" },
|
||||
{ brand: "Chromium", version: input.fullVersion },
|
||||
{ brand: input.brand, version: input.fullVersion },
|
||||
];
|
||||
return {
|
||||
body: {
|
||||
brands,
|
||||
full_version_list: fullVersionList,
|
||||
platform,
|
||||
},
|
||||
headers: {
|
||||
host: "127.0.0.1:43121",
|
||||
origin: "http://127.0.0.1:43121",
|
||||
"sec-ch-ua": serialize(brands),
|
||||
"sec-ch-ua-full-version-list": serialize(fullVersionList),
|
||||
"sec-ch-ua-platform": `"${platform}"`,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user