pluginStoreListing.test.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. import { describe, expect, it } from "vitest";
  2. import type {
  3. ZCodeAvailablePluginSummary,
  4. ZCodeInstalledPluginSummary,
  5. ZCodePluginInfo,
  6. ZCodePluginMarketplaceSummary,
  7. } from "@zcode/shared";
  8. import {
  9. buildStoreItems,
  10. canUpdatePluginItem,
  11. formatCanonicalPluginName,
  12. groupItemsByCategory,
  13. resolveItemDisplayName,
  14. resolvePluginDisplayName,
  15. resolveUniquePluginListingByName,
  16. resolveLocalizedList,
  17. resolveLocalizedText,
  18. selectFeaturedItems,
  19. sortMarketplaceSources,
  20. sortInstalledStripItems,
  21. sortPersonalMarketplaceGroups,
  22. } from "../src/settings/pluginStoreListing.js";
  23. function makeSummary(
  24. overrides: Partial<ZCodeAvailablePluginSummary> & { id: string },
  25. ): ZCodeAvailablePluginSummary {
  26. const [name = "", marketplace = ""] = overrides.id.split("@");
  27. return {
  28. name,
  29. marketplace,
  30. installed: false,
  31. ...overrides,
  32. };
  33. }
  34. function makeInfo(overrides: Partial<ZCodePluginInfo> & { id: string }): ZCodePluginInfo {
  35. const [name = "", marketplace = ""] = overrides.id.split("@");
  36. return {
  37. name,
  38. marketplace,
  39. enabled: true,
  40. source: "cache",
  41. skillRootCount: 0,
  42. commandRootCount: 0,
  43. mcpServerNames: [],
  44. rootPath: `/cache/${name}`,
  45. ...overrides,
  46. };
  47. }
  48. function makeMarketplace(
  49. overrides: Partial<ZCodePluginMarketplaceSummary> & { id: string },
  50. ): ZCodePluginMarketplaceSummary {
  51. return {
  52. name: overrides.id,
  53. source: {},
  54. pluginCount: 0,
  55. ...overrides,
  56. };
  57. }
  58. describe("pluginStoreListing", () => {
  59. it("only falls back to a listing when the plugin name is unique", () => {
  60. const official = makeSummary({
  61. id: "computer-use@zcode-plugins-official",
  62. listing: { displayName: "Computer Use" },
  63. });
  64. const custom = makeSummary({
  65. id: "computer-use@custom-marketplace",
  66. listing: { displayName: "Custom CUA" },
  67. });
  68. expect(resolveUniquePluginListingByName([official], "computer-use")).toEqual(official.listing);
  69. expect(resolveUniquePluginListingByName([official, custom], "computer-use")).toBeUndefined();
  70. });
  71. it("prefers the official listing name over the internal plugin slug", () => {
  72. expect(
  73. resolvePluginDisplayName(
  74. {
  75. name: "computer-use",
  76. listing: {
  77. displayName: "Computer Use",
  78. displayNameI18n: { "zh-CN": "电脑控制" },
  79. },
  80. },
  81. "en-US",
  82. ),
  83. ).toBe("Computer Use");
  84. expect(
  85. resolvePluginDisplayName(
  86. {
  87. name: "computer-use",
  88. listing: {
  89. displayName: "Computer Use",
  90. displayNameI18n: { "zh-CN": "电脑控制" },
  91. },
  92. },
  93. "zh-CN",
  94. ),
  95. ).toBe("电脑控制");
  96. expect(resolvePluginDisplayName({ name: "third-party-tool" }, "en-US")).toBe(
  97. "Third Party Tool",
  98. );
  99. });
  100. it("resolves localized text with exact locale then language-prefix fallback", () => {
  101. expect(resolveLocalizedText("zh-CN", "base", { "zh-CN": "精确" })).toBe("精确");
  102. expect(resolveLocalizedText("zh-CN", "base", { zh: "前缀" })).toBe("前缀");
  103. expect(resolveLocalizedText("en-US", "base", { en: "english" })).toBe("english");
  104. expect(resolveLocalizedText("en-US", "base", { "zh-CN": "中文" })).toBe("base");
  105. expect(resolveLocalizedList("zh-CN", ["base"], { zh: ["列表"] })).toEqual(["列表"]);
  106. expect(resolveLocalizedList("en-US", undefined, undefined)).toBeUndefined();
  107. });
  108. it("joins catalog, runtime, and installed records into store items", () => {
  109. const items = buildStoreItems({
  110. marketplaces: [makeMarketplace({ id: "zcode-plugins-official" })],
  111. marketplaceAvailabilityKnown: true,
  112. availablePlugins: [
  113. makeSummary({ id: "a@zcode-plugins-official", installed: true }),
  114. makeSummary({ id: "b@zcode-plugins-official" }),
  115. ],
  116. installedPlugins: [
  117. {
  118. id: "a@zcode-plugins-official",
  119. name: "a",
  120. marketplace: "zcode-plugins-official",
  121. enabled: true,
  122. scope: "user",
  123. } as ZCodeInstalledPluginSummary,
  124. ],
  125. plugins: [
  126. makeInfo({ id: "a@zcode-plugins-official" }),
  127. // 运行时独有(inline)插件也要出现在条目集合里。
  128. makeInfo({ id: "c@inline", source: "inline" }),
  129. ],
  130. restorableBuiltins: [makeSummary({ id: "d@zcode-plugins-official" })],
  131. });
  132. const byId = new Map(items.map((item) => [item.id, item]));
  133. expect(byId.get("a@zcode-plugins-official")?.installed).toBe(true);
  134. expect(byId.get("a@zcode-plugins-official")?.info).toBeDefined();
  135. expect(byId.get("a@zcode-plugins-official")?.installedMeta).toBeDefined();
  136. expect(byId.get("b@zcode-plugins-official")?.installed).toBe(false);
  137. expect(byId.get("c@inline")?.installed).toBe(true);
  138. expect(byId.get("c@inline")?.orphaned).toBe(false);
  139. expect(byId.get("d@zcode-plugins-official")?.restorable).toBe(true);
  140. });
  141. it("merges a restorable built-in with its catalog entry instead of dropping detail metadata", () => {
  142. const [item] = buildStoreItems({
  143. marketplaces: [makeMarketplace({ id: "zcode-plugins-official" })],
  144. marketplaceAvailabilityKnown: true,
  145. availablePlugins: [
  146. makeSummary({
  147. id: "document-skills@zcode-plugins-official",
  148. listing: {
  149. category: "productivity",
  150. displayName: "Document Skills",
  151. descriptionI18n: { "en-US": "Work with documents" },
  152. },
  153. }),
  154. ],
  155. installedPlugins: [],
  156. plugins: [],
  157. restorableBuiltins: [makeSummary({ id: "document-skills@zcode-plugins-official" })],
  158. });
  159. expect(item).toMatchObject({
  160. id: "document-skills@zcode-plugins-official",
  161. installed: false,
  162. restorable: true,
  163. listing: {
  164. category: "productivity",
  165. displayName: "Document Skills",
  166. },
  167. });
  168. });
  169. it("does not treat a missing-package configuration projection as installed inventory", () => {
  170. const [item] = buildStoreItems({
  171. marketplaces: [makeMarketplace({ id: "personal-market" })],
  172. marketplaceAvailabilityKnown: true,
  173. availablePlugins: [
  174. makeSummary({
  175. id: "missing@personal-market",
  176. installed: true,
  177. marketplace: "personal-market",
  178. }),
  179. ],
  180. installedPlugins: [],
  181. plugins: [
  182. makeInfo({
  183. id: "missing@personal-market",
  184. packageStatus: "missing",
  185. rootPath: "",
  186. source: "missing",
  187. }),
  188. ],
  189. restorableBuiltins: [],
  190. });
  191. expect(item).toMatchObject({
  192. id: "missing@personal-market",
  193. installed: false,
  194. info: {
  195. packageStatus: "missing",
  196. },
  197. });
  198. });
  199. it("keeps marketplace ownership when a stale restorable marker overlaps an installed record", () => {
  200. const [item] = buildStoreItems({
  201. marketplaces: [makeMarketplace({ id: "zcode-plugins-official" })],
  202. marketplaceAvailabilityKnown: true,
  203. availablePlugins: [
  204. makeSummary({ id: "document-skills@zcode-plugins-official", installed: true }),
  205. ],
  206. installedPlugins: [
  207. {
  208. id: "document-skills@zcode-plugins-official",
  209. name: "document-skills",
  210. marketplace: "zcode-plugins-official",
  211. enabled: true,
  212. scope: "user",
  213. } as ZCodeInstalledPluginSummary,
  214. ],
  215. plugins: [makeInfo({ id: "document-skills@zcode-plugins-official", enabled: true })],
  216. restorableBuiltins: [makeSummary({ id: "document-skills@zcode-plugins-official" })],
  217. });
  218. expect(item).toMatchObject({
  219. id: "document-skills@zcode-plugins-official",
  220. installed: true,
  221. restorable: false,
  222. info: { enabled: true },
  223. installedMeta: { enabled: true },
  224. });
  225. });
  226. it("marks a cache install as orphaned when its known marketplace source is absent", () => {
  227. const [item] = buildStoreItems({
  228. marketplaces: [],
  229. marketplaceAvailabilityKnown: true,
  230. availablePlugins: [],
  231. installedPlugins: [
  232. {
  233. id: "orphan@personal-market",
  234. name: "orphan",
  235. marketplace: "personal-market",
  236. enabled: true,
  237. scope: "user",
  238. updateStatus: "update-available",
  239. } as ZCodeInstalledPluginSummary,
  240. ],
  241. plugins: [makeInfo({ id: "orphan@personal-market" })],
  242. restorableBuiltins: [],
  243. });
  244. expect(item).toMatchObject({
  245. id: "orphan@personal-market",
  246. installed: true,
  247. orphaned: true,
  248. });
  249. expect(canUpdatePluginItem(item)).toBe(false);
  250. });
  251. it("does not infer orphaned from a missing catalog listing when the source still exists", () => {
  252. const installedMeta: ZCodeInstalledPluginSummary = {
  253. id: "installed@personal-market",
  254. name: "installed",
  255. marketplace: "personal-market",
  256. enabled: true,
  257. scope: "user",
  258. updateStatus: "update-available",
  259. };
  260. const [item] = buildStoreItems({
  261. marketplaces: [makeMarketplace({ id: "personal-market" })],
  262. marketplaceAvailabilityKnown: true,
  263. availablePlugins: [],
  264. installedPlugins: [installedMeta],
  265. plugins: [makeInfo({ id: "installed@personal-market" })],
  266. restorableBuiltins: [],
  267. });
  268. expect(item?.orphaned).toBe(false);
  269. expect(canUpdatePluginItem(item)).toBe(true);
  270. });
  271. it("does not turn missing configuration into an installable item without a catalog source", () => {
  272. const missing = makeInfo({
  273. id: "document-skills@zcode-plugins-official",
  274. source: "missing",
  275. packageStatus: "missing",
  276. rootPath: "",
  277. });
  278. const input = {
  279. marketplaces: [makeMarketplace({ id: "zcode-plugins-official" })],
  280. marketplaceAvailabilityKnown: true,
  281. availablePlugins: [],
  282. installedPlugins: [],
  283. plugins: [missing],
  284. restorableBuiltins: [],
  285. };
  286. expect(buildStoreItems(input)).toEqual([]);
  287. // 配置诊断必须仍留给设置页,不能通过删源数据来掩盖商店误投影。
  288. expect(input.plugins).toEqual([missing]);
  289. expect(
  290. buildStoreItems({ ...input, availablePlugins: [makeSummary({ id: missing.id })] }),
  291. ).toEqual([
  292. expect.objectContaining({ id: missing.id, installed: false, summary: expect.any(Object) }),
  293. ]);
  294. });
  295. it("never marks official plugins as orphaned when the catalog listing is absent", () => {
  296. const [item] = buildStoreItems({
  297. marketplaces: [],
  298. marketplaceAvailabilityKnown: true,
  299. availablePlugins: [],
  300. installedPlugins: [],
  301. plugins: [
  302. makeInfo({
  303. id: "builtin@zcode-plugins-official",
  304. source: "official",
  305. }),
  306. ],
  307. restorableBuiltins: [],
  308. });
  309. expect(item?.orphaned).toBe(false);
  310. });
  311. it("allows updates only when the installed item still has a marketplace source", () => {
  312. const installedMeta: ZCodeInstalledPluginSummary = {
  313. id: "plugin@personal-market",
  314. name: "plugin",
  315. marketplace: "personal-market",
  316. enabled: true,
  317. scope: "user",
  318. updateStatus: "update-available",
  319. };
  320. expect(canUpdatePluginItem({ installedMeta, orphaned: false })).toBe(true);
  321. expect(canUpdatePluginItem({ installedMeta, orphaned: true })).toBe(false);
  322. expect(
  323. canUpdatePluginItem({
  324. installedMeta: { ...installedMeta, updateStatus: "none" },
  325. orphaned: false,
  326. }),
  327. ).toBe(false);
  328. });
  329. it("selects featured items from public marketplaces in catalog order", () => {
  330. const items = buildStoreItems({
  331. marketplaces: [
  332. makeMarketplace({ id: "zcode-plugins-official" }),
  333. makeMarketplace({ id: "claude-plugins-official" }),
  334. ],
  335. marketplaceAvailabilityKnown: true,
  336. availablePlugins: [
  337. makeSummary({ id: "alpha@zcode-plugins-official" }),
  338. makeSummary({ id: "beta@zcode-plugins-official" }),
  339. makeSummary({ id: "gamma@claude-plugins-official" }),
  340. ],
  341. installedPlugins: [],
  342. plugins: [],
  343. restorableBuiltins: [],
  344. });
  345. const publicItems = items.filter((item) => item.marketplace === "zcode-plugins-official");
  346. const featured = selectFeaturedItems(publicItems, [
  347. makeMarketplace({ id: "zcode-plugins-official", featured: ["beta", "missing", "alpha"] }),
  348. // 非公开市场的 featured 名单不参与。
  349. makeMarketplace({ id: "claude-plugins-official", featured: ["gamma"] }),
  350. ]);
  351. expect(featured.map((item) => item.name)).toEqual(["beta", "alpha"]);
  352. });
  353. it("orders category groups identically across locales with a fixed product order", () => {
  354. const items = buildStoreItems({
  355. marketplaces: [makeMarketplace({ id: "zcode-plugins-official" })],
  356. marketplaceAvailabilityKnown: true,
  357. availablePlugins: [
  358. makeSummary({ id: "a@zcode-plugins-official", listing: { category: "productivity" } }),
  359. makeSummary({ id: "b@zcode-plugins-official", listing: { category: "developer-tools" } }),
  360. makeSummary({ id: "c@zcode-plugins-official", listing: { category: "legal" } }),
  361. makeSummary({ id: "d@zcode-plugins-official", listing: { category: "template" } }),
  362. makeSummary({ id: "e@zcode-plugins-official", listing: { category: "utilities" } }),
  363. makeSummary({ id: "f@zcode-plugins-official", listing: { category: "zebra-unknown" } }),
  364. makeSummary({ id: "h@zcode-plugins-official", listing: { category: "finance" } }),
  365. makeSummary({ id: "g@zcode-plugins-official" }),
  366. ],
  367. installedPlugins: [],
  368. plugins: [],
  369. restorableBuiltins: [],
  370. });
  371. // 固定产品顺序:已知分类按 KNOWN_CATEGORY_ORDER,未知分类按 slug 排在其后,other 恒最后;
  372. // 与 UI locale 无关(旧实现按本地化标签排序,zh 拼音序与 en 字母序会得到不同分组顺序)。
  373. const expected = [
  374. "productivity",
  375. "developer-tools",
  376. "utilities",
  377. "finance",
  378. "legal",
  379. "template",
  380. "zebra-unknown",
  381. "other",
  382. ];
  383. for (const locale of ["zh-CN", "en-US"]) {
  384. expect(groupItemsByCategory(items, locale).map((group) => group.category)).toEqual(expected);
  385. }
  386. });
  387. it("prefers listing display name with locale resolution", () => {
  388. const [item] = buildStoreItems({
  389. marketplaces: [makeMarketplace({ id: "zcode-plugins-official" })],
  390. marketplaceAvailabilityKnown: true,
  391. availablePlugins: [
  392. makeSummary({
  393. id: "a@zcode-plugins-official",
  394. listing: { displayName: "Alpha", displayNameI18n: { "zh-CN": "阿尔法" } },
  395. }),
  396. ],
  397. installedPlugins: [],
  398. plugins: [],
  399. restorableBuiltins: [],
  400. });
  401. expect(item).toBeDefined();
  402. expect(resolveItemDisplayName(item!, "zh-CN")).toBe("阿尔法");
  403. expect(resolveItemDisplayName(item!, "en-US")).toBe("Alpha");
  404. });
  405. it("formats a canonical plugin name when no display name is configured", () => {
  406. const [item] = buildStoreItems({
  407. marketplaces: [makeMarketplace({ id: "zcode-plugins-official" })],
  408. marketplaceAvailabilityKnown: true,
  409. availablePlugins: [
  410. makeSummary({
  411. id: "cloudbase-skills@zcode-plugins-official",
  412. name: "cloudbase-skills",
  413. }),
  414. ],
  415. installedPlugins: [],
  416. plugins: [],
  417. restorableBuiltins: [],
  418. });
  419. expect(item).toBeDefined();
  420. expect(resolveItemDisplayName(item!, "en-US")).toBe("Cloudbase Skills");
  421. expect(formatCanonicalPluginName("zcode-guide", "en-US")).toBe("ZCode Guide");
  422. expect(formatCanonicalPluginName("aws-mcp-server", "en-US")).toBe("AWS MCP Server");
  423. expect(formatCanonicalPluginName("AWS_mCp_tools", "en-US")).toBe("AWS MCP Tools");
  424. });
  425. it("sorts built-in and inline plugins first, then marketplace plugins by installedAt desc", () => {
  426. const items = buildStoreItems({
  427. marketplaces: [
  428. makeMarketplace({ id: "m" }),
  429. makeMarketplace({ id: "zcode-plugins-official" }),
  430. ],
  431. marketplaceAvailabilityKnown: true,
  432. availablePlugins: [],
  433. installedPlugins: [
  434. {
  435. id: "old@m",
  436. name: "old",
  437. marketplace: "m",
  438. enabled: true,
  439. scope: "user",
  440. installedAt: "2026-01-01T00:00:00Z",
  441. } as ZCodeInstalledPluginSummary,
  442. {
  443. id: "new@m",
  444. name: "new",
  445. marketplace: "m",
  446. enabled: true,
  447. scope: "user",
  448. installedAt: "2026-07-01T00:00:00Z",
  449. } as ZCodeInstalledPluginSummary,
  450. {
  451. id: "builtin@zcode-plugins-official",
  452. name: "builtin",
  453. marketplace: "zcode-plugins-official",
  454. enabled: true,
  455. scope: "user",
  456. installedAt: "2025-01-01T00:00:00Z",
  457. } as ZCodeInstalledPluginSummary,
  458. ],
  459. plugins: [
  460. makeInfo({ id: "old@m" }),
  461. makeInfo({ id: "new@m" }),
  462. makeInfo({ id: "inline@inline", source: "inline" }),
  463. makeInfo({ id: "builtin@zcode-plugins-official", source: "official" }),
  464. ],
  465. restorableBuiltins: [],
  466. });
  467. const sorted = sortInstalledStripItems(items, "en-US");
  468. expect(sorted.map((item) => item.name)).toEqual(["builtin", "inline", "new", "old"]);
  469. });
  470. it("orders personal marketplace groups by lastUpdated descending, sinking unknown to the end", () => {
  471. const groups = [
  472. { marketplace: "claude-plugins-official", title: "Claude Code Plugins", items: [] },
  473. { marketplace: "zcode-plugins-test", title: "zcode-plugins-test", items: [] },
  474. { marketplace: "never-refreshed", title: "never-refreshed", items: [] },
  475. { marketplace: "paid-demo-market", title: "paid-demo-market", items: [] },
  476. ];
  477. const sorted = sortPersonalMarketplaceGroups(
  478. groups,
  479. [
  480. makeMarketplace({ id: "claude-plugins-official", lastUpdated: "2026-01-01T00:00:00Z" }),
  481. makeMarketplace({ id: "zcode-plugins-test", lastUpdated: "2026-08-20T12:00:00Z" }),
  482. makeMarketplace({ id: "paid-demo-market", lastUpdated: "2026-08-20T12:00:00Z" }),
  483. // never-refreshed 无记录:没有 lastUpdated,按缺失沉底。
  484. ],
  485. "en-US",
  486. );
  487. expect(sorted.map((group) => group.marketplace)).toEqual([
  488. // 最近刷新的在前;同刻(zcode-plugins-test / paid-demo-market)按显示名字母序。
  489. "paid-demo-market",
  490. "zcode-plugins-test",
  491. "claude-plugins-official",
  492. "never-refreshed",
  493. ]);
  494. });
  495. it("pins official sources and sorts custom sources by lastUpdated", () => {
  496. const sorted = sortMarketplaceSources(
  497. [
  498. makeMarketplace({
  499. id: "never-refreshed",
  500. name: "Never Refreshed",
  501. }),
  502. makeMarketplace({
  503. id: "zcode-plugins-test",
  504. name: "zcode-plugins-test",
  505. lastUpdated: "2026-08-20T12:00:00Z",
  506. }),
  507. makeMarketplace({
  508. id: "claude-plugins-official",
  509. name: "claude-plugins-official",
  510. lastUpdated: "2026-01-01T00:00:00Z",
  511. }),
  512. makeMarketplace({
  513. id: "zcode-plugins-official",
  514. name: "zcode-plugins-official",
  515. lastUpdated: "2026-08-20T23:00:00Z",
  516. }),
  517. makeMarketplace({
  518. id: "zcode-labs",
  519. name: "zcode-labs",
  520. lastUpdated: "2026-08-20T12:00:00Z",
  521. }),
  522. ],
  523. "en-US",
  524. );
  525. expect(sorted.map((marketplace) => marketplace.id)).toEqual([
  526. "zcode-plugins-official",
  527. "claude-plugins-official",
  528. "zcode-labs",
  529. "zcode-plugins-test",
  530. "never-refreshed",
  531. ]);
  532. });
  533. });
  534. describe("document plugin default order", () => {
  535. const names = ["pdf", "presentations", "spreadsheets", "documents"];
  536. const ids = names.map((name) => `${name}@zcode-plugins-official`);
  537. const items = buildStoreItems({
  538. marketplaces: [],
  539. installedPlugins: [],
  540. restorableBuiltins: [],
  541. availablePlugins: ["aaa", ...names.toReversed()].map((name) =>
  542. makeSummary({
  543. id: `${name}@zcode-plugins-official`,
  544. installed: true,
  545. listing: { category: "productivity" },
  546. }),
  547. ),
  548. plugins: ["aaa", ...names].map((name) =>
  549. makeInfo({
  550. id: `${name}@zcode-plugins-official`,
  551. source: "official",
  552. enabled: false,
  553. }),
  554. ),
  555. });
  556. it.each(["en-US", "zh-CN"])(
  557. "pins documents across installed and category views in %s",
  558. (locale) => {
  559. expect(
  560. sortInstalledStripItems(items, locale)
  561. .slice(0, 4)
  562. .map((item) => item.id),
  563. ).toEqual(ids);
  564. expect(
  565. groupItemsByCategory(items, locale)[0]
  566. ?.items.slice(0, 4)
  567. .map((item) => item.id),
  568. ).toEqual(ids);
  569. expect(items[0]?.name).toBe("aaa");
  570. },
  571. );
  572. it("retains explicit server priority and skips absent document plugins", () => {
  573. const groups = groupItemsByCategory(
  574. items.filter((item) => item.name !== "pdf"),
  575. "en-US",
  576. {
  577. pluginOrder: { productivity: ["aaa@zcode-plugins-official"] },
  578. },
  579. );
  580. expect(groups[0]?.items.map((item) => item.name)).toEqual([
  581. "aaa",
  582. "presentations",
  583. "spreadsheets",
  584. "documents",
  585. ]);
  586. });
  587. it("does not pin personal plugins with the same name", () => {
  588. const personal = items.map((item) => ({
  589. ...item,
  590. id: `${item.name}@personal`,
  591. marketplace: "personal",
  592. }));
  593. expect(sortInstalledStripItems(personal, "en-US")[0]?.name).toBe("aaa");
  594. });
  595. });