settingsEditFormDeleteAction.test.ts 1.1 KB

12345678910111213141516171819202122232425
  1. import { readFile } from "node:fs/promises";
  2. import { describe, expect, it } from "vitest";
  3. const editForms = ["CommandForm.tsx", "HookForm.tsx", "McpServerForm.tsx"] as const;
  4. const resourceLists = ["CommandCard.tsx", "HooksList.tsx", "McpServerList.tsx"] as const;
  5. describe("settings edit form delete action", () => {
  6. it("uses the Subagent delete action style in editable forms", async () => {
  7. for (const fileName of editForms) {
  8. const source = await readFile(new URL(`../src/settings/${fileName}`, import.meta.url), "utf8");
  9. expect(source, fileName).toContain("onDelete");
  10. expect(source, fileName).toContain('variant="link"');
  11. expect(source, fileName).toContain('size="lg"');
  12. expect(source, fileName).toContain("px-0 text-destructive hover:text-destructive");
  13. expect(source, fileName).toContain('<Trash2 className="size-3.5"');
  14. }
  15. });
  16. it("removes duplicate delete actions from list rows", async () => {
  17. for (const fileName of resourceLists) {
  18. const source = await readFile(new URL(`../src/settings/${fileName}`, import.meta.url), "utf8");
  19. expect(source, fileName).not.toContain("<Trash2");
  20. }
  21. });
  22. });