taskListItemHoverActions.test.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. import { act, createElement, type ReactElement, type ReactNode } from "react";
  2. import { createRoot, type Root } from "react-dom/client";
  3. import { afterEach, describe, expect, it, vi } from "vitest";
  4. import type { ZCodeTaskMeta } from "@zcode/shared";
  5. type TestEvent = {
  6. bubbles?: boolean;
  7. currentTarget?: TestElement;
  8. relatedTarget?: unknown;
  9. target?: TestElement;
  10. type: string;
  11. };
  12. type TestEventHandler = (event: TestEvent) => void;
  13. type TestElement = Element & {
  14. __attrs: Map<string, string>;
  15. __listeners: Map<string, TestEventHandler[]>;
  16. childNodes: TestElement[];
  17. dispatchEvent: (event: TestEvent) => boolean;
  18. parentNode: TestElement | null;
  19. };
  20. const {
  21. contextMenuMounts,
  22. contextMenuOpenChangeHandlers,
  23. contextActionsCalls,
  24. leadingIndicatorState,
  25. formatRelativeTimeCalls,
  26. tooltipCalls,
  27. triggerChildren,
  28. stableIntl,
  29. } = vi.hoisted(() => ({
  30. contextMenuMounts: [] as Array<Record<string, unknown>>,
  31. contextMenuOpenChangeHandlers: [] as Array<(open: boolean) => void>,
  32. contextActionsCalls: [] as Array<Record<string, unknown>>,
  33. leadingIndicatorState: { value: "none" },
  34. formatRelativeTimeCalls: [] as number[],
  35. tooltipCalls: [] as Array<Record<string, unknown>>,
  36. triggerChildren: [] as ReactElement[],
  37. stableIntl: {
  38. formatMessage: ({ id }: { id: string }) => id,
  39. },
  40. }));
  41. vi.mock("lucide-react", () => {
  42. const createIcon = (name: string) => (props: Record<string, unknown>) =>
  43. createElement("svg", { "data-icon": name, ...props });
  44. return {
  45. Archive: createIcon("archive"),
  46. CloudUpload: createIcon("cloud-upload"),
  47. Clock: createIcon("clock"),
  48. LoaderIcon: createIcon("loader"),
  49. ListTree: createIcon("list-tree"),
  50. Pin: createIcon("pin"),
  51. Smartphone: createIcon("smartphone"),
  52. };
  53. });
  54. vi.mock("@/components/ui/badge.js", () => ({
  55. Badge: ({ children }: { children?: ReactNode }) => createElement("span", null, children),
  56. }));
  57. vi.mock("@/components/ui/button.js", () => ({
  58. Button: ({ children, ...props }: { children?: ReactNode }) =>
  59. createElement("button", props, children),
  60. }));
  61. vi.mock("@/components/ui/context-menu.js", () => ({
  62. ContextMenu: ({
  63. children,
  64. onOpenChange,
  65. }: {
  66. children?: ReactNode;
  67. onOpenChange?: (open: boolean) => void;
  68. }) => {
  69. if (onOpenChange) {
  70. contextMenuOpenChangeHandlers.push(onOpenChange);
  71. }
  72. return createElement("div", null, children);
  73. },
  74. ContextMenuTrigger: ({ children }: { children: ReactElement }) => {
  75. triggerChildren.push(children);
  76. return children;
  77. },
  78. }));
  79. vi.mock("@/lib/taskListItemPresentation.js", () => ({
  80. deriveTaskLeadingIndicator: () => leadingIndicatorState.value,
  81. formatTaskRelativeTime: (updatedAt: number) => {
  82. formatRelativeTimeCalls.push(updatedAt);
  83. return "now";
  84. },
  85. }));
  86. vi.mock("@/ControlHintTooltip.js", () => ({
  87. ControlHintTooltip: ({ children, ...props }: { children?: ReactNode }) => {
  88. tooltipCalls.push(props);
  89. return createElement("span", null, children);
  90. },
  91. }));
  92. vi.mock("@/TaskListItemContextMenu.js", () => ({
  93. TaskListItemContextMenu: (props: Record<string, unknown>) => {
  94. contextMenuMounts.push(props);
  95. return createElement("div", { "data-testid": "task-context-menu" });
  96. },
  97. }));
  98. vi.mock("@/useTaskListItemContextActions.js", () => ({
  99. useTaskListItemContextActions: (params: Record<string, unknown>) => {
  100. contextActionsCalls.push(params);
  101. return {
  102. fileManagerLabel: "Finder",
  103. handleCopyText: vi.fn(),
  104. handleOpenProviderConfig: vi.fn(),
  105. handleOpenTaskPathInFileManager: vi.fn(),
  106. providerConfigFile: { exists: false, loading: false, path: null },
  107. taskNativeSessionLogFile: { exists: false, loading: false, path: null },
  108. taskSessionFile: { exists: false, loading: false, path: null },
  109. };
  110. },
  111. }));
  112. vi.mock("@/hooks/usePlatform.js", () => ({
  113. useOptionalPlatform: () => null,
  114. }));
  115. vi.mock("@/feedback/feedbackStore.js", () => ({
  116. useFeedbackStore: (selector: (state: { openSubmit: () => void }) => unknown) =>
  117. selector({ openSubmit: vi.fn() }),
  118. }));
  119. vi.mock("@/store/modelTrajectoryStore.js", () => ({
  120. useModelTrajectoryStore: {
  121. getState: () => ({
  122. requestOpen: vi.fn(),
  123. }),
  124. },
  125. }));
  126. vi.mock("@/components/ui/toast.js", () => ({
  127. toast: () => {},
  128. }));
  129. vi.mock("@/store/zcodeSessionStore.js", async () => {
  130. const actual = await vi.importActual<typeof import("@/store/zcodeSessionStore.js")>(
  131. "@/store/zcodeSessionStore.js",
  132. );
  133. return {
  134. ...actual,
  135. getTaskRuntimeState: () => "idle",
  136. getTaskUnreadIndicator: () => false,
  137. hasTaskPendingHumanInterventionRequest: () => false,
  138. hasTaskPendingPermissionRequest: () => false,
  139. selectWorkspaceZCodeState: () => ({}),
  140. useZCodeSessionStore: (selector: (state: Record<string, unknown>) => unknown) => selector({}),
  141. };
  142. });
  143. function createTask(): ZCodeTaskMeta {
  144. return {
  145. createdAt: 1,
  146. mode: "default",
  147. provider: "codex",
  148. taskId: "task-1",
  149. title: "Task 1",
  150. traceId: "trace-1",
  151. updatedAt: 2,
  152. workspacePath: "/workspace",
  153. };
  154. }
  155. function createMinimalElement(ownerDocument: Document, tagName = "div") {
  156. const element = {
  157. __attrs: new Map<string, string>(),
  158. __listeners: new Map<string, TestEventHandler[]>(),
  159. addEventListener: (type: string, handler: TestEventHandler) => {
  160. const handlers = element.__listeners.get(type) ?? [];
  161. handlers.push(handler);
  162. element.__listeners.set(type, handlers);
  163. },
  164. appendChild: (child: TestElement) => {
  165. child.parentNode = element as unknown as TestElement;
  166. element.childNodes.push(child);
  167. return child;
  168. },
  169. childNodes: [] as TestElement[],
  170. dispatchEvent: (event: TestEvent) => {
  171. event.target ??= element as unknown as TestElement;
  172. let current: TestElement | null = element as unknown as TestElement;
  173. while (current) {
  174. event.currentTarget = current;
  175. for (const handler of current.__listeners.get(event.type) ?? []) {
  176. handler(event);
  177. }
  178. if (!event.bubbles) {
  179. break;
  180. }
  181. current = current.parentNode;
  182. }
  183. return true;
  184. },
  185. getAttribute: (name: string) => element.__attrs.get(name) ?? null,
  186. insertBefore: (child: TestElement, beforeChild?: TestElement | null) => {
  187. child.parentNode = element as unknown as TestElement;
  188. const beforeIndex = beforeChild ? element.childNodes.indexOf(beforeChild) : -1;
  189. if (beforeIndex >= 0) {
  190. element.childNodes.splice(beforeIndex, 0, child);
  191. } else {
  192. element.childNodes.push(child);
  193. }
  194. return child;
  195. },
  196. nodeName: tagName.toUpperCase(),
  197. nodeType: 1,
  198. ownerDocument,
  199. parentNode: null as TestElement | null,
  200. querySelector: (selector: string) => {
  201. const attributeMatch = /^\[([^=\]]+)(?:=[^\]]+)?\]$/u.exec(selector);
  202. if (!attributeMatch) {
  203. return null;
  204. }
  205. return findByAttribute(element as unknown as TestElement, attributeMatch[1]);
  206. },
  207. removeAttribute: (name: string) => {
  208. element.__attrs.delete(name);
  209. },
  210. removeChild: (child: TestElement) => {
  211. element.childNodes = element.childNodes.filter((item) => item !== child);
  212. child.parentNode = null;
  213. return child;
  214. },
  215. removeEventListener: (type: string, handler: TestEventHandler) => {
  216. element.__listeners.set(
  217. type,
  218. (element.__listeners.get(type) ?? []).filter((item) => item !== handler),
  219. );
  220. },
  221. setAttribute: (name: string, value: string) => {
  222. element.__attrs.set(name, String(value));
  223. },
  224. style: {},
  225. tagName: tagName.toUpperCase(),
  226. };
  227. return element as unknown as TestElement;
  228. }
  229. function findByAttribute(node: TestElement, attributeName: string) {
  230. if (node.__attrs?.has(attributeName)) {
  231. return node;
  232. }
  233. for (const child of node.childNodes ?? []) {
  234. const match = findByAttribute(child, attributeName);
  235. if (match) {
  236. return match;
  237. }
  238. }
  239. return null;
  240. }
  241. function findByAttributeValue(node: TestElement, attributeName: string, attributeValue: string) {
  242. if (node.__attrs?.get(attributeName) === attributeValue) {
  243. return node;
  244. }
  245. for (const child of node.childNodes ?? []) {
  246. const match = findByAttributeValue(child, attributeName, attributeValue);
  247. if (match) {
  248. return match;
  249. }
  250. }
  251. return null;
  252. }
  253. function installMinimalDom(hoverNone = false) {
  254. const documentMock = {
  255. addEventListener: () => {},
  256. createElement: (tagName: string) =>
  257. createMinimalElement(documentMock as unknown as Document, tagName),
  258. createElementNS: (_namespace: string, tagName: string) =>
  259. createMinimalElement(documentMock as unknown as Document, tagName),
  260. createTextNode: (nodeValue: string) => ({
  261. nodeType: 3,
  262. nodeValue,
  263. ownerDocument: documentMock,
  264. parentNode: null,
  265. }),
  266. nodeType: 9,
  267. removeEventListener: () => {},
  268. } as unknown as Document;
  269. const windowMock = {
  270. addEventListener: () => {},
  271. document: documentMock,
  272. HTMLIFrameElement: function HTMLIFrameElement() {},
  273. HTMLElement: function HTMLElement() {},
  274. matchMedia: () => ({ matches: hoverNone }),
  275. Node: function Node() {},
  276. removeEventListener: () => {},
  277. };
  278. Object.defineProperty(globalThis, "document", {
  279. configurable: true,
  280. value: documentMock,
  281. });
  282. Object.defineProperty(globalThis, "window", {
  283. configurable: true,
  284. value: windowMock,
  285. });
  286. Object.defineProperty(globalThis, "IS_REACT_ACT_ENVIRONMENT", {
  287. configurable: true,
  288. value: true,
  289. });
  290. return createMinimalElement(documentMock);
  291. }
  292. describe("TaskListItem hover action rendering", () => {
  293. afterEach(() => {
  294. contextMenuMounts.length = 0;
  295. contextMenuOpenChangeHandlers.length = 0;
  296. contextActionsCalls.length = 0;
  297. leadingIndicatorState.value = "none";
  298. formatRelativeTimeCalls.length = 0;
  299. tooltipCalls.length = 0;
  300. triggerChildren.length = 0;
  301. delete (globalThis as { document?: unknown }).document;
  302. delete (globalThis as { window?: unknown }).window;
  303. delete (globalThis as { IS_REACT_ACT_ENVIRONMENT?: unknown }).IS_REACT_ACT_ENVIRONMENT;
  304. });
  305. it("opens pinned files on touch without selecting the task", async () => {
  306. const { MemoTaskItem } = await import("@/TaskListItem.js");
  307. const container = installMinimalDom(true);
  308. const root = createRoot(container);
  309. const onOpenFileTree = vi.fn(async () => {});
  310. const onSelectTask = vi.fn();
  311. act(() =>
  312. root.render(
  313. createElement(MemoTaskItem, {
  314. intl: stableIntl,
  315. isActive: false,
  316. isArchiveConfirming: false,
  317. isPinned: true,
  318. onArchiveTask: vi.fn(),
  319. onArchiveTaskInline: vi.fn(),
  320. onCancelArchiveConfirm: vi.fn(),
  321. onMarkTaskAsUnread: vi.fn(),
  322. onSelectTask,
  323. onStartRenameTask: vi.fn(),
  324. onTogglePinTask: vi.fn(),
  325. onOpenFileTree,
  326. task: createTask(),
  327. workspacePath: "/workspace",
  328. }),
  329. ),
  330. );
  331. const button = findByAttributeValue(container, "data-testid", "task-files-task-1");
  332. expect(button).not.toBeNull();
  333. const stopPropagation = vi.fn();
  334. await act(async () => {
  335. button?.dispatchEvent({
  336. type: "click",
  337. bubbles: true,
  338. preventDefault: vi.fn(),
  339. stopPropagation,
  340. } as TestEvent);
  341. });
  342. expect(onOpenFileTree).toHaveBeenCalledOnce();
  343. expect(stopPropagation).toHaveBeenCalled();
  344. expect(onSelectTask).not.toHaveBeenCalled();
  345. act(() => root.unmount());
  346. });
  347. it.each([false, true])(
  348. "hoverEnabled=%s controls synthetic mouse and focus presentation",
  349. async (hoverEnabled) => {
  350. const { MemoTaskItem } = await import("@/TaskListItem.js");
  351. const container = installMinimalDom(true);
  352. const root = createRoot(container);
  353. const onSelectTask = vi.fn();
  354. act(() =>
  355. root.render(
  356. createElement(MemoTaskItem, {
  357. intl: stableIntl,
  358. isActive: false,
  359. isArchiveConfirming: false,
  360. isPinned: false,
  361. hoverEnabled,
  362. onArchiveTask: vi.fn(),
  363. onArchiveTaskInline: vi.fn(),
  364. onCancelArchiveConfirm: vi.fn(),
  365. onMarkTaskAsUnread: vi.fn(),
  366. onSelectTask,
  367. onStartRenameTask: vi.fn(),
  368. onTogglePinTask: vi.fn(),
  369. task: createTask(),
  370. workspacePath: "/workspace",
  371. }),
  372. ),
  373. );
  374. const row = findByAttribute(container, "data-task-item-key")!;
  375. act(() => {
  376. row.dispatchEvent({ type: "mouseover", bubbles: true, relatedTarget: null });
  377. row.dispatchEvent({ type: "focusin", bubbles: true });
  378. });
  379. expect(
  380. findByAttribute(container, "data-task-row-metadata")
  381. ?.getAttribute("class")
  382. ?.includes("hidden"),
  383. ).toBe(hoverEnabled);
  384. expect(row.getAttribute("class")?.includes("hover:bg-surface-hover")).toBe(hoverEnabled);
  385. act(() => row.dispatchEvent({ type: "click", bubbles: true }));
  386. expect(onSelectTask).toHaveBeenCalledOnce();
  387. act(() => root.unmount());
  388. },
  389. );
  390. it("keeps idle rows free of per-row context menu and hover-only archive tooltip", async () => {
  391. const { MemoTaskItem } = await import("@/TaskListItem.js");
  392. const root: Root = createRoot(installMinimalDom());
  393. act(() => {
  394. root.render(
  395. createElement(MemoTaskItem, {
  396. intl: stableIntl,
  397. isActive: false,
  398. isArchiveConfirming: false,
  399. isPinned: false,
  400. onArchiveTask: vi.fn(),
  401. onArchiveTaskInline: vi.fn(),
  402. onCancelArchiveConfirm: vi.fn(),
  403. onMarkTaskAsUnread: vi.fn(),
  404. onSelectTask: vi.fn(),
  405. onStartRenameTask: vi.fn(),
  406. onTogglePinTask: vi.fn(),
  407. task: createTask(),
  408. workspacePath: "/workspace",
  409. }),
  410. );
  411. });
  412. expect(contextMenuOpenChangeHandlers).toHaveLength(0);
  413. expect(contextMenuMounts).toHaveLength(0);
  414. expect(contextActionsCalls).toHaveLength(0);
  415. expect(tooltipCalls).toHaveLength(0);
  416. act(() => {
  417. root.unmount();
  418. });
  419. });
  420. it("触屏常驻 actions 时仍保留 task 元信息", async () => {
  421. const { MemoTaskItem } = await import("@/TaskListItem.js");
  422. const container = installMinimalDom(true);
  423. const root: Root = createRoot(container);
  424. leadingIndicatorState.value = "unread";
  425. act(() => {
  426. root.render(
  427. createElement(MemoTaskItem, {
  428. intl: stableIntl,
  429. isActive: false,
  430. isArchiveConfirming: false,
  431. isPinned: false,
  432. onArchiveTask: vi.fn(),
  433. onArchiveTaskInline: vi.fn(),
  434. onCancelArchiveConfirm: vi.fn(),
  435. onMarkTaskAsUnread: vi.fn(),
  436. onSelectTask: vi.fn(),
  437. onStartRenameTask: vi.fn(),
  438. onTogglePinTask: vi.fn(),
  439. task: createTask(),
  440. workspacePath: "/workspace",
  441. }),
  442. );
  443. });
  444. expect(findByAttribute(container, "data-task-row-actions")).not.toBeNull();
  445. const metadata = findByAttribute(container, "data-task-row-metadata");
  446. expect(metadata).not.toBeNull();
  447. expect(metadata?.__attrs.get("class")).not.toContain("hidden");
  448. const unreadIndicator = findByAttribute(container, "data-unread-indicator");
  449. expect(unreadIndicator).not.toBeNull();
  450. expect(unreadIndicator?.parentNode?.__attrs.get("class")).not.toContain("hidden");
  451. act(() => {
  452. root.unmount();
  453. });
  454. });
  455. it("does not re-render when task meta is replaced with equivalent display fields", async () => {
  456. const { MemoTaskItem } = await import("@/TaskListItem.js");
  457. const root: Root = createRoot(installMinimalDom());
  458. const task = createTask();
  459. const props = {
  460. intl: stableIntl,
  461. isActive: false,
  462. isArchiveConfirming: false,
  463. isPinned: false,
  464. onArchiveTask: vi.fn(),
  465. onArchiveTaskInline: vi.fn(),
  466. onCancelArchiveConfirm: vi.fn(),
  467. onMarkTaskAsUnread: vi.fn(),
  468. onSelectTask: vi.fn(),
  469. onStartRenameTask: vi.fn(),
  470. onTogglePinTask: vi.fn(),
  471. task,
  472. workspacePath: "/workspace",
  473. };
  474. act(() => {
  475. root.render(createElement(MemoTaskItem, props));
  476. });
  477. expect(formatRelativeTimeCalls).toHaveLength(1);
  478. act(() => {
  479. root.render(
  480. createElement(MemoTaskItem, {
  481. ...props,
  482. task: { ...task },
  483. }),
  484. );
  485. });
  486. expect(formatRelativeTimeCalls).toHaveLength(1);
  487. act(() => {
  488. root.unmount();
  489. });
  490. });
  491. it("re-renders when a task receives automation identity", async () => {
  492. const { MemoTaskItem } = await import("@/TaskListItem.js");
  493. const container = installMinimalDom();
  494. const root: Root = createRoot(container);
  495. const task = createTask();
  496. const props = {
  497. intl: stableIntl,
  498. isActive: false,
  499. isArchiveConfirming: false,
  500. isPinned: false,
  501. onArchiveTask: vi.fn(),
  502. onArchiveTaskInline: vi.fn(),
  503. onCancelArchiveConfirm: vi.fn(),
  504. onMarkTaskAsUnread: vi.fn(),
  505. onSelectTask: vi.fn(),
  506. onStartRenameTask: vi.fn(),
  507. onTogglePinTask: vi.fn(),
  508. task,
  509. workspacePath: "/workspace",
  510. };
  511. act(() => {
  512. root.render(createElement(MemoTaskItem, props));
  513. });
  514. expect(container.querySelector("[data-cron-task-icon]")).toBeNull();
  515. act(() => {
  516. root.render(
  517. createElement(MemoTaskItem, {
  518. ...props,
  519. task: {
  520. ...task,
  521. automationId: "automation-1",
  522. } as ZCodeTaskMeta & { automationId: string },
  523. }),
  524. );
  525. });
  526. expect(container.querySelector("[data-cron-task-icon]")).not.toBeNull();
  527. act(() => {
  528. root.unmount();
  529. });
  530. });
  531. it("renders cron icon in the timeline time metadata", async () => {
  532. const { MemoTaskItem } = await import("@/TaskListItem.js");
  533. const container = installMinimalDom();
  534. const root: Root = createRoot(container);
  535. act(() => {
  536. root.render(
  537. createElement(MemoTaskItem, {
  538. intl: stableIntl,
  539. isActive: false,
  540. isArchiveConfirming: false,
  541. isPinned: false,
  542. onArchiveTask: vi.fn(),
  543. onArchiveTaskInline: vi.fn(),
  544. onCancelArchiveConfirm: vi.fn(),
  545. onMarkTaskAsUnread: vi.fn(),
  546. onSelectTask: vi.fn(),
  547. onStartRenameTask: vi.fn(),
  548. onTogglePinTask: vi.fn(),
  549. task: {
  550. ...createTask(),
  551. cronAutomationId: "automation-1",
  552. },
  553. variant: "timeline",
  554. workspacePath: "/workspace",
  555. }),
  556. );
  557. });
  558. expect(container.querySelector("[data-cron-task-icon]")).not.toBeNull();
  559. act(() => {
  560. root.unmount();
  561. });
  562. });
  563. it("keeps archive confirmation active after the pointer leaves the row", async () => {
  564. const { MemoTaskItem } = await import("@/TaskListItem.js");
  565. const container = installMinimalDom();
  566. const root: Root = createRoot(container);
  567. const onCancelArchiveConfirm = vi.fn();
  568. act(() => {
  569. root.render(
  570. createElement(MemoTaskItem, {
  571. intl: stableIntl,
  572. isActive: false,
  573. isArchiveConfirming: true,
  574. isPinned: false,
  575. onArchiveTask: vi.fn(),
  576. onArchiveTaskInline: vi.fn(),
  577. onCancelArchiveConfirm,
  578. onMarkTaskAsUnread: vi.fn(),
  579. onSelectTask: vi.fn(),
  580. onStartRenameTask: vi.fn(),
  581. onTogglePinTask: vi.fn(),
  582. task: createTask(),
  583. workspacePath: "/workspace",
  584. }),
  585. );
  586. });
  587. const row = container.querySelector("[data-task-item-key]") as TestElement | null;
  588. expect(row).not.toBeNull();
  589. act(() => {
  590. row?.dispatchEvent({
  591. bubbles: true,
  592. relatedTarget: null,
  593. type: "mouseout",
  594. });
  595. });
  596. expect(onCancelArchiveConfirm).not.toHaveBeenCalled();
  597. const confirmButton = findByAttributeValue(container, "aria-label", "common.confirm");
  598. expect(confirmButton?.__attrs.get("class")).toContain("flex");
  599. expect(confirmButton?.__attrs.get("class")).not.toContain("hidden");
  600. act(() => {
  601. root.unmount();
  602. });
  603. });
  604. });