| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { |
| 4 | BRAND_ASSET_PATHS, |
| 5 | DEVELOPMENT_ICON_OVERRIDES, |
| 6 | DEVELOPMENT_PUBLIC_ICON_OVERRIDES, |
| 7 | resolveWebAssetBrandForChannel, |
| 8 | resolveWebAssetBrandForPackageVersion, |
| 9 | resolveWebIconOverrides, |
| 10 | } from "./brand-assets.ts"; |
| 11 | |
| 12 | describe("brand-assets", () => { |
| 13 | it("maps production web assets into the server package", () => { |
| 14 | expect(resolveWebIconOverrides("production", "dist/client")).toEqual([ |
| 15 | { |
| 16 | sourceRelativePath: BRAND_ASSET_PATHS.productionWebFaviconIco, |
| 17 | targetRelativePath: "dist/client/favicon.ico", |
| 18 | }, |
| 19 | { |
| 20 | sourceRelativePath: BRAND_ASSET_PATHS.productionWebFavicon16Png, |
| 21 | targetRelativePath: "dist/client/favicon-16x16.png", |
| 22 | }, |
| 23 | { |
| 24 | sourceRelativePath: BRAND_ASSET_PATHS.productionWebFavicon32Png, |
| 25 | targetRelativePath: "dist/client/favicon-32x32.png", |
| 26 | }, |
| 27 | { |
| 28 | sourceRelativePath: BRAND_ASSET_PATHS.productionWebAppleTouchIconPng, |
| 29 | targetRelativePath: "dist/client/apple-touch-icon.png", |
| 30 | }, |
| 31 | ]); |
| 32 | }); |
| 33 | |
| 34 | it("maps server build web assets to development icons", () => { |
| 35 | expect(DEVELOPMENT_ICON_OVERRIDES[0]).toEqual({ |
| 36 | sourceRelativePath: BRAND_ASSET_PATHS.developmentWebFaviconIco, |
| 37 | targetRelativePath: "dist/client/favicon.ico", |
| 38 | }); |
| 39 | }); |
| 40 | |
| 41 | it("maps development web assets to the public splash and favicon files", () => { |
| 42 | expect(DEVELOPMENT_PUBLIC_ICON_OVERRIDES).toEqual([ |
| 43 | { |
| 44 | sourceRelativePath: BRAND_ASSET_PATHS.developmentWebFaviconIco, |
| 45 | targetRelativePath: "apps/web/public/favicon.ico", |
| 46 | }, |
| 47 | { |
| 48 | sourceRelativePath: BRAND_ASSET_PATHS.developmentWebFavicon16Png, |
| 49 | targetRelativePath: "apps/web/public/favicon-16x16.png", |
| 50 | }, |
| 51 | { |
| 52 | sourceRelativePath: BRAND_ASSET_PATHS.developmentWebFavicon32Png, |
| 53 | targetRelativePath: "apps/web/public/favicon-32x32.png", |
| 54 | }, |
| 55 | { |
| 56 | sourceRelativePath: BRAND_ASSET_PATHS.developmentWebAppleTouchIconPng, |
| 57 | targetRelativePath: "apps/web/public/apple-touch-icon.png", |
| 58 | }, |
| 59 | ]); |
| 60 | }); |
| 61 | |
| 62 | it("can target hosted web dist directly", () => { |
| 63 | expect(resolveWebIconOverrides("production", "apps/web/dist")).toContainEqual({ |
| 64 | sourceRelativePath: BRAND_ASSET_PATHS.productionWebAppleTouchIconPng, |
| 65 | targetRelativePath: "apps/web/dist/apple-touch-icon.png", |
| 66 | }); |
| 67 | }); |
| 68 | |
| 69 | it("maps hosted nightly web assets to nightly icons", () => { |
| 70 | expect(resolveWebIconOverrides("nightly", "apps/web/dist")).toContainEqual({ |
| 71 | sourceRelativePath: BRAND_ASSET_PATHS.nightlyWebFaviconIco, |
| 72 | targetRelativePath: "apps/web/dist/favicon.ico", |
| 73 | }); |
| 74 | }); |
| 75 | |
| 76 | it("maps hosted release channels to web asset brands", () => { |
| 77 | expect(resolveWebAssetBrandForChannel("latest")).toBe("production"); |
| 78 | expect(resolveWebAssetBrandForChannel("nightly")).toBe("nightly"); |
| 79 | }); |
| 80 | |
| 81 | it("maps package versions to web asset brands", () => { |
| 82 | expect(resolveWebAssetBrandForPackageVersion("0.0.29")).toBe("production"); |
| 83 | expect(resolveWebAssetBrandForPackageVersion("0.0.29-nightly.20260723.882")).toBe("nightly"); |
| 84 | expect(resolveWebAssetBrandForPackageVersion("0.0.29-preview.20260723.882")).toBe("nightly"); |
| 85 | }); |
| 86 | }); |