mirror of
https://github.com/hanzoai/dev-desktop.git
synced 2026-11-20 01:07:23 +00:00
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
import { DEFAULT_HOSTED_APP_URL } from "@hanzodev/shared/connectAuth";
|
|
import { afterEach, expect, it, vi } from "vite-plus/test";
|
|
|
|
import appleAppSiteAssociation from "../web/public/.well-known/apple-app-site-association.json";
|
|
import assetLinks from "../web/public/.well-known/assetlinks.json";
|
|
|
|
// Keep config parsing independent of local env files and build credentials.
|
|
vi.mock("../../scripts/lib/public-config.ts", () => ({
|
|
loadRepoEnv: () => ({ APP_VARIANT: process.env.APP_VARIANT }),
|
|
}));
|
|
|
|
afterEach(() => {
|
|
vi.unstubAllEnvs();
|
|
});
|
|
|
|
async function loadConfig(variant: string | undefined) {
|
|
vi.resetModules();
|
|
vi.stubEnv("APP_VARIANT", variant);
|
|
return (await import("./app.config.ts")).default;
|
|
}
|
|
|
|
it.each(["prod", ""])("rejects APP_VARIANT=%j before selecting production IDs", async (value) => {
|
|
await expect(loadConfig(value)).rejects.toThrow(
|
|
"APP_VARIANT must be development, preview, or production.",
|
|
);
|
|
});
|
|
|
|
it.each([
|
|
[undefined, "ai.hanzo.dev"],
|
|
["development", "ai.hanzo.dev.dev"],
|
|
["preview", "ai.hanzo.dev.preview"],
|
|
["production", "ai.hanzo.dev"],
|
|
])("keeps the iOS and Android identifiers for APP_VARIANT=%j", async (value, identifier) => {
|
|
const config = await loadConfig(value);
|
|
expect(config.ios?.bundleIdentifier).toBe(identifier);
|
|
expect(config.android?.package).toBe(identifier);
|
|
// Copied thread links open this app only while hanzo.bot lists it.
|
|
const host = new URL(DEFAULT_HOSTED_APP_URL).host;
|
|
expect(config.ios?.associatedDomains).toContain(`applinks:${host}`);
|
|
expect(appleAppSiteAssociation.applinks.details[0]?.appIDs).toContain(
|
|
`${config.ios?.appleTeamId}.${identifier}`,
|
|
);
|
|
expect(config.android?.intentFilters?.[0]?.data).toEqual([
|
|
{ scheme: "https", host, pathPrefix: "/threads/" },
|
|
]);
|
|
expect(assetLinks.map((link) => link.target.package_name)).toContain(identifier);
|
|
});
|