|
6 | 6 | import { buildRemoteOpenUrl, EnvironmentId } from "@t3tools/contracts"; |
7 | 7 | import { describe, expect, it } from "vite-plus/test"; |
8 | 8 |
|
9 | | -import { resolveRemoteOpenState } from "./remoteOpen"; |
| 9 | +import { remoteFallbackEditors, resolveRemoteOpenState } from "./remoteOpen"; |
10 | 10 |
|
11 | 11 | const environmentId = EnvironmentId.make("environment-1"); |
12 | 12 |
|
@@ -179,6 +179,46 @@ describe("resolveRemoteOpenState", () => { |
179 | 179 | }); |
180 | 180 | }); |
181 | 181 |
|
| 182 | +describe("remoteFallbackEditors", () => { |
| 183 | + it.each([ |
| 184 | + { |
| 185 | + // iPadOS Safari requests the desktop site with a Macintosh user agent by default. |
| 186 | + device: "iPad with a desktop user agent", |
| 187 | + userAgent: |
| 188 | + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15", |
| 189 | + platform: "MacIntel", |
| 190 | + maxTouchPoints: 5, |
| 191 | + }, |
| 192 | + { |
| 193 | + device: "iPhone", |
| 194 | + userAgent: |
| 195 | + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1", |
| 196 | + platform: "iPhone", |
| 197 | + maxTouchPoints: 5, |
| 198 | + }, |
| 199 | + { |
| 200 | + device: "Android phone", |
| 201 | + userAgent: |
| 202 | + "Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36", |
| 203 | + platform: "Linux armv81", |
| 204 | + maxTouchPoints: 5, |
| 205 | + }, |
| 206 | + ])("offers no desktop editor for remote links on an $device", ({ device: _, ...identity }) => { |
| 207 | + expect(remoteFallbackEditors(identity)).toEqual([]); |
| 208 | + }); |
| 209 | + |
| 210 | + it("keeps the VS Code fallback for remote links on a Mac", () => { |
| 211 | + expect( |
| 212 | + remoteFallbackEditors({ |
| 213 | + userAgent: |
| 214 | + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15", |
| 215 | + platform: "MacIntel", |
| 216 | + maxTouchPoints: 0, |
| 217 | + }), |
| 218 | + ).toEqual(["vscode"]); |
| 219 | + }); |
| 220 | +}); |
| 221 | + |
182 | 222 | describe("buildRemoteOpenUrl", () => { |
183 | 223 | it("roots Windows paths", () => { |
184 | 224 | expect( |
|
0 commit comments