|
| 1 | +import { describe, expect, it } from "vite-plus/test"; |
| 2 | +import type { ExtensionManifest } from "../types/extension-manifest"; |
| 3 | +import { buildInstalledExtensionsMap } from "./extension-store-bootstrap"; |
| 4 | +import type { AvailableExtension } from "./extension-store-types"; |
| 5 | + |
| 6 | +function createAvailableExtension(manifest: ExtensionManifest): AvailableExtension { |
| 7 | + return { |
| 8 | + manifest, |
| 9 | + isInstalled: false, |
| 10 | + isEnabled: false, |
| 11 | + isInstalling: false, |
| 12 | + runtimeIssues: [], |
| 13 | + }; |
| 14 | +} |
| 15 | + |
| 16 | +describe("extension-store bootstrap", () => { |
| 17 | + it("drops retired installed extensions before activation state is built", () => { |
| 18 | + const availableExtensions = new Map<string, AvailableExtension>([ |
| 19 | + [ |
| 20 | + "athas.theme.market", |
| 21 | + createAvailableExtension({ |
| 22 | + id: "athas.theme.market", |
| 23 | + name: "Athas Themes", |
| 24 | + displayName: "Athas Theme Pack", |
| 25 | + description: "Retired theme pack", |
| 26 | + version: "1.0.0", |
| 27 | + publisher: "Athas", |
| 28 | + categories: ["Theme"], |
| 29 | + themes: [ |
| 30 | + { |
| 31 | + id: "market-light", |
| 32 | + name: "Athas Light", |
| 33 | + appearance: "light", |
| 34 | + colors: {}, |
| 35 | + syntax: {}, |
| 36 | + }, |
| 37 | + ], |
| 38 | + }), |
| 39 | + ], |
| 40 | + [ |
| 41 | + "athas.theme.vercel", |
| 42 | + createAvailableExtension({ |
| 43 | + id: "athas.theme.vercel", |
| 44 | + name: "vercel", |
| 45 | + displayName: "Vercel Theme", |
| 46 | + description: "Vercel theme", |
| 47 | + version: "1.0.0", |
| 48 | + publisher: "Athas", |
| 49 | + categories: ["Theme"], |
| 50 | + installation: { type: "bundled" }, |
| 51 | + themes: [ |
| 52 | + { |
| 53 | + id: "vercel-light", |
| 54 | + name: "Vercel Light", |
| 55 | + appearance: "light", |
| 56 | + colors: {}, |
| 57 | + syntax: {}, |
| 58 | + }, |
| 59 | + ], |
| 60 | + }), |
| 61 | + ], |
| 62 | + ]); |
| 63 | + |
| 64 | + const installedExtensions = buildInstalledExtensionsMap({ |
| 65 | + backendInstalled: [ |
| 66 | + { |
| 67 | + id: "athas.theme.market", |
| 68 | + name: "Athas Theme Pack", |
| 69 | + version: "1.0.0", |
| 70 | + installed_at: "2026-07-08T00:00:00.000Z", |
| 71 | + enabled: true, |
| 72 | + }, |
| 73 | + ], |
| 74 | + indexedDBInstalled: [{ languageId: "athas.theme.market", version: "1.0.0" }], |
| 75 | + bundledContributionInstalled: ["athas.theme.market", "athas.theme.vercel"], |
| 76 | + availableExtensions, |
| 77 | + }); |
| 78 | + |
| 79 | + expect(installedExtensions.has("athas.theme.market")).toBe(false); |
| 80 | + expect(installedExtensions.has("athas.theme.vercel")).toBe(true); |
| 81 | + }); |
| 82 | +}); |
0 commit comments