The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { DEFAULT_HOSTED_APP_URL } from "@t3tools/shared/connectAuth"; |
| 2 | import { afterEach, expect, it, vi } from "vite-plus/test"; |
| 3 | |
| 4 | import appleAppSiteAssociation from "../web/public/.well-known/apple-app-site-association.json"; |
| 5 | import assetLinks from "../web/public/.well-known/assetlinks.json"; |
| 6 | |
| 7 | // Keep config parsing independent of local env files and build credentials. |
| 8 | vi.mock("../../scripts/lib/public-config.ts", () => ({ |
| 9 | loadRepoEnv: () => ({ APP_VARIANT: process.env.APP_VARIANT }), |
| 10 | })); |
| 11 | |
| 12 | afterEach(() => { |
| 13 | vi.unstubAllEnvs(); |
| 14 | }); |
| 15 | |
| 16 | async function loadConfig(variant: string | undefined) { |
| 17 | vi.resetModules(); |
| 18 | vi.stubEnv("APP_VARIANT", variant); |
| 19 | return (await import("./app.config.ts")).default; |
| 20 | } |
| 21 | |
| 22 | it.each(["prod", ""])("rejects APP_VARIANT=%j before selecting production IDs", async (value) => { |
| 23 | await expect(loadConfig(value)).rejects.toThrow( |
| 24 | "APP_VARIANT must be development, preview, or production.", |
| 25 | ); |
| 26 | }); |
| 27 | |
| 28 | it.each([ |
| 29 | [undefined, "com.t3tools.t3code"], |
| 30 | ["development", "com.t3tools.t3code.dev"], |
| 31 | ["preview", "com.t3tools.t3code.preview"], |
| 32 | ["production", "com.t3tools.t3code"], |
| 33 | ])("keeps the iOS and Android identifiers for APP_VARIANT=%j", async (value, identifier) => { |
| 34 | const config = await loadConfig(value); |
| 35 | expect(config.ios?.bundleIdentifier).toBe(identifier); |
| 36 | expect(config.android?.package).toBe(identifier); |
| 37 | // Copied thread links open this app only while app.t3.codes lists it. |
| 38 | const host = new URL(DEFAULT_HOSTED_APP_URL).host; |
| 39 | expect(config.ios?.associatedDomains).toContain(`applinks:${host}`); |
| 40 | expect(appleAppSiteAssociation.applinks.details[0]?.appIDs).toContain( |
| 41 | `${config.ios?.appleTeamId}.${identifier}`, |
| 42 | ); |
| 43 | expect(config.android?.intentFilters?.[0]?.data).toEqual([ |
| 44 | { scheme: "https", host, pathPrefix: "/threads/" }, |
| 45 | ]); |
| 46 | expect(assetLinks.map((link) => link.target.package_name)).toContain(identifier); |
| 47 | }); |