mirror of
https://github.com/block/buzz.git
synced 2026-10-27 04:30:52 +00:00
fix: resolve invite downloads by platform (#2001)
Signed-off-by: npub1dccv64krpcpse5cmkzfeh998cftungyatw3djt8jwdw6g43f7fyqzzmrf7 <6e30cd56c30e030cd31bb0939b94a7c257c9a09d5ba2d92cf2735da45629f248@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1dccv64krpcpse5cmkzfeh998cftungyatw3djt8jwdw6g43f7fyqzzmrf7 <6e30cd56c30e030cd31bb0939b94a7c257c9a09d5ba2d92cf2735da45629f248@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
@@ -27,8 +27,51 @@ test("invite requires age and legal consent before opening Buzz", async ({
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.route("https://api.github.com/**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
headers: { "Access-Control-Allow-Origin": "*" },
|
||||
body: JSON.stringify([
|
||||
{ draft: false, prerelease: false, assets: [] },
|
||||
{
|
||||
draft: false,
|
||||
prerelease: false,
|
||||
assets: [
|
||||
{
|
||||
name: "Buzz_0.4.9_aarch64.dmg",
|
||||
browser_download_url:
|
||||
"https://github.com/block/buzz/releases/download/v0.4.9/Buzz_0.4.9_aarch64.dmg",
|
||||
},
|
||||
{
|
||||
name: "Buzz_0.4.9_x64.dmg",
|
||||
browser_download_url:
|
||||
"https://github.com/block/buzz/releases/download/v0.4.9/Buzz_0.4.9_x64.dmg",
|
||||
},
|
||||
{
|
||||
name: "Buzz_0.4.9_amd64.AppImage",
|
||||
browser_download_url:
|
||||
"https://github.com/block/buzz/releases/download/v0.4.9/Buzz_0.4.9_amd64.AppImage",
|
||||
},
|
||||
{
|
||||
name: "Buzz_0.4.9_x64-setup_alpha-unsigned.exe",
|
||||
browser_download_url:
|
||||
"https://github.com/block/buzz/releases/download/v0.4.9/Buzz_0.4.9_x64-setup_alpha-unsigned.exe",
|
||||
},
|
||||
],
|
||||
},
|
||||
]),
|
||||
});
|
||||
});
|
||||
await page.goto("/invite/demo-code");
|
||||
|
||||
await expect(
|
||||
page.getByRole("link", { name: "Download it now" }),
|
||||
).toHaveAttribute(
|
||||
"href",
|
||||
"https://github.com/block/buzz/releases/download/v0.4.9/Buzz_0.4.9_x64-setup_alpha-unsigned.exe",
|
||||
);
|
||||
|
||||
const ageConfirmation = page.getByLabel("I am 18 years of age or older.");
|
||||
const agreementConfirmation = page.getByLabel(
|
||||
"I agree to the Buzz Terms of Service and Privacy Policy.",
|
||||
@@ -73,3 +116,91 @@ test("invite requires age and legal consent before opening Buzz", async ({
|
||||
expect(consentBox?.y).toBeLessThan(acceptButtonBox?.y ?? 0);
|
||||
expect(consentBox?.width).toBe(acceptButtonBox?.width);
|
||||
});
|
||||
|
||||
test("invite download falls back for mobile and non-desktop devices", async ({
|
||||
browser,
|
||||
}) => {
|
||||
const unsupportedDevices = [
|
||||
{
|
||||
name: "iPhone Safari",
|
||||
platform: "iPhone",
|
||||
userAgent:
|
||||
"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15",
|
||||
maxTouchPoints: 5,
|
||||
},
|
||||
{
|
||||
name: "iPadOS desktop mode",
|
||||
platform: "MacIntel",
|
||||
userAgent:
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15",
|
||||
maxTouchPoints: 5,
|
||||
},
|
||||
{
|
||||
name: "Android phone",
|
||||
platform: "Linux armv8l",
|
||||
userAgent:
|
||||
"Mozilla/5.0 (Linux; Android 15; Pixel 9 Pro) AppleWebKit/537.36 Mobile",
|
||||
maxTouchPoints: 5,
|
||||
},
|
||||
{
|
||||
name: "ChromeOS",
|
||||
platform: "Linux x86_64",
|
||||
userAgent: "Mozilla/5.0 (X11; CrOS x86_64 16093.68.0) AppleWebKit/537.36",
|
||||
maxTouchPoints: 0,
|
||||
},
|
||||
];
|
||||
|
||||
for (const device of unsupportedDevices) {
|
||||
const context = await browser.newContext({ userAgent: device.userAgent });
|
||||
await context.addInitScript(({ platform, maxTouchPoints }) => {
|
||||
Object.defineProperties(navigator, {
|
||||
platform: { configurable: true, value: platform },
|
||||
maxTouchPoints: { configurable: true, value: maxTouchPoints },
|
||||
userAgentData: {
|
||||
configurable: true,
|
||||
value: { platform, mobile: maxTouchPoints > 0 },
|
||||
},
|
||||
});
|
||||
}, device);
|
||||
const page = await context.newPage();
|
||||
await page.route("**/api/join-policy", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ policy: null }),
|
||||
});
|
||||
});
|
||||
await page.route("https://api.github.com/**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
headers: { "Access-Control-Allow-Origin": "*" },
|
||||
body: JSON.stringify([
|
||||
{
|
||||
draft: false,
|
||||
prerelease: false,
|
||||
assets: [
|
||||
{
|
||||
name: "Buzz_0.4.9_x64.dmg",
|
||||
browser_download_url:
|
||||
"https://github.com/block/buzz/releases/download/v0.4.9/Buzz_0.4.9_x64.dmg",
|
||||
},
|
||||
{
|
||||
name: "Buzz_0.4.9_amd64.AppImage",
|
||||
browser_download_url:
|
||||
"https://github.com/block/buzz/releases/download/v0.4.9/Buzz_0.4.9_amd64.AppImage",
|
||||
},
|
||||
],
|
||||
},
|
||||
]),
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto("/invite/demo-code");
|
||||
await expect(
|
||||
page.getByRole("link", { name: "Download it now" }),
|
||||
device.name,
|
||||
).toHaveAttribute("href", "https://github.com/block/buzz/releases");
|
||||
await context.close();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user