The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { detectPlatform, getMobileStoreUrl } from "./platform"; |
| 4 | import { ANDROID_PLAY_STORE_URL, IOS_APP_STORE_URL } from "./site"; |
| 5 | |
| 6 | it.each([ |
| 7 | { |
| 8 | // Android user agents also contain "Linux". |
| 9 | name: "Android", |
| 10 | userAgent: |
| 11 | "Mozilla/5.0 (Linux; Android 15; Pixel 9) AppleWebKit/537.36 Chrome/140.0.0.0 Mobile Safari/537.36", |
| 12 | maxTouchPoints: 5, |
| 13 | os: "android", |
| 14 | storeUrl: ANDROID_PLAY_STORE_URL, |
| 15 | }, |
| 16 | { |
| 17 | name: "iPhone", |
| 18 | userAgent: |
| 19 | "Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1", |
| 20 | maxTouchPoints: 5, |
| 21 | os: "ios", |
| 22 | storeUrl: IOS_APP_STORE_URL, |
| 23 | }, |
| 24 | { |
| 25 | // iPad Safari sends a desktop Mac user agent by default. |
| 26 | name: "iPad with a desktop user agent", |
| 27 | userAgent: |
| 28 | "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15", |
| 29 | maxTouchPoints: 5, |
| 30 | os: "ios", |
| 31 | storeUrl: IOS_APP_STORE_URL, |
| 32 | }, |
| 33 | { |
| 34 | name: "macOS", |
| 35 | userAgent: |
| 36 | "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15", |
| 37 | maxTouchPoints: 0, |
| 38 | os: "mac", |
| 39 | storeUrl: null, |
| 40 | }, |
| 41 | ])("$name visitors get the $os download", ({ userAgent, maxTouchPoints, os, storeUrl }) => { |
| 42 | const platform = detectPlatform(userAgent, maxTouchPoints); |
| 43 | expect(platform?.os).toBe(os); |
| 44 | expect(platform && getMobileStoreUrl(platform)).toBe(storeUrl); |
| 45 | }); |