|
1 | 1 | import { createHash } from "node:crypto"; |
2 | 2 | import { expect, test } from "@playwright/test"; |
| 3 | +import { |
| 4 | + BUZZ_ANDROID_PLAY_STORE_URL, |
| 5 | + BUZZ_IOS_APP_STORE_URL, |
| 6 | + BUZZ_RELEASES_URL, |
| 7 | +} from "../../src/shared/lib/buzz-download"; |
3 | 8 |
|
4 | 9 | test("home page loads with Buzz branding", async ({ page }) => { |
5 | 10 | await page.goto("/"); |
@@ -260,40 +265,44 @@ test("invite asks Safari users to choose their Mac download", async ({ |
260 | 265 | await context.close(); |
261 | 266 | }); |
262 | 267 |
|
263 | | -test("invite download falls back for mobile and non-desktop devices", async ({ |
| 268 | +test("invite download links to the appropriate platform destination", async ({ |
264 | 269 | browser, |
265 | 270 | }) => { |
266 | | - const unsupportedDevices = [ |
| 271 | + const devices = [ |
267 | 272 | { |
268 | 273 | name: "iPhone Safari", |
| 274 | + expectedUrl: BUZZ_IOS_APP_STORE_URL, |
269 | 275 | platform: "iPhone", |
270 | 276 | userAgent: |
271 | 277 | "Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15", |
272 | 278 | maxTouchPoints: 5, |
273 | 279 | }, |
274 | 280 | { |
275 | 281 | name: "iPadOS desktop mode", |
| 282 | + expectedUrl: BUZZ_IOS_APP_STORE_URL, |
276 | 283 | platform: "MacIntel", |
277 | 284 | userAgent: |
278 | 285 | "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15", |
279 | 286 | maxTouchPoints: 5, |
280 | 287 | }, |
281 | 288 | { |
282 | 289 | name: "Android phone", |
| 290 | + expectedUrl: BUZZ_ANDROID_PLAY_STORE_URL, |
283 | 291 | platform: "Linux armv8l", |
284 | 292 | userAgent: |
285 | 293 | "Mozilla/5.0 (Linux; Android 15; Pixel 9 Pro) AppleWebKit/537.36 Mobile", |
286 | 294 | maxTouchPoints: 5, |
287 | 295 | }, |
288 | 296 | { |
289 | 297 | name: "ChromeOS", |
| 298 | + expectedUrl: BUZZ_RELEASES_URL, |
290 | 299 | platform: "Linux x86_64", |
291 | 300 | userAgent: "Mozilla/5.0 (X11; CrOS x86_64 16093.68.0) AppleWebKit/537.36", |
292 | 301 | maxTouchPoints: 0, |
293 | 302 | }, |
294 | 303 | ]; |
295 | 304 |
|
296 | | - for (const device of unsupportedDevices) { |
| 305 | + for (const device of devices) { |
297 | 306 | const context = await browser.newContext({ userAgent: device.userAgent }); |
298 | 307 | await context.addInitScript(({ platform, maxTouchPoints }) => { |
299 | 308 | Object.defineProperties(navigator, { |
@@ -343,7 +352,7 @@ test("invite download falls back for mobile and non-desktop devices", async ({ |
343 | 352 | await expect( |
344 | 353 | page.getByRole("link", { name: "Download it now" }), |
345 | 354 | device.name, |
346 | | - ).toHaveAttribute("href", "https://github.com/block/buzz/releases"); |
| 355 | + ).toHaveAttribute("href", device.expectedUrl); |
347 | 356 | await context.close(); |
348 | 357 | } |
349 | 358 | }); |
0 commit comments