|
1 | 1 | import { EnvironmentId, OrchestrationV2ArchivedShellSnapshot } from "@t3tools/contracts"; |
| 2 | +import * as Cause from "effect/Cause"; |
2 | 3 | import * as DateTime from "effect/DateTime"; |
3 | 4 | import * as Schema from "effect/Schema"; |
4 | 5 | import { AsyncResult } from "effect/reactivity"; |
@@ -107,9 +108,6 @@ const snapshot = Schema.decodeUnknownSync(OrchestrationV2ArchivedShellSnapshot)( |
107 | 108 | itemCount: 0, |
108 | 109 | visibleItemCount: 0, |
109 | 110 | archivedAt: DateTime.makeUnsafe(now), |
110 | | - settledOverride: null, |
111 | | - settledAt: null, |
112 | | - deletedAt: null, |
113 | 111 | })), |
114 | 112 | }); |
115 | 113 |
|
@@ -242,3 +240,38 @@ it("releases the lock and reports a failed bulk action", async () => { |
242 | 240 | await act(async () => openContextMenu()); |
243 | 241 | expect(state.unarchiveThread).toHaveBeenCalledOnce(); |
244 | 242 | }); |
| 243 | + |
| 244 | +it.each([ |
| 245 | + ["Unarchive Thread 1", "unarchiveThread"], |
| 246 | + ["Delete Thread 1", "confirmAndDeleteThread"], |
| 247 | +] as const)("keeps %s locked independently and recovers after failure", async (label, method) => { |
| 248 | + const pending = deferred<ReturnType<typeof AsyncResult.failure>>(); |
| 249 | + state[method].mockReturnValueOnce(pending.promise); |
| 250 | + const button = container.querySelector<HTMLButtonElement>(`button[aria-label="${label}"]`)!; |
| 251 | + |
| 252 | + await act(async () => button.click()); |
| 253 | + await act(async () => { |
| 254 | + button.click(); |
| 255 | + button |
| 256 | + .closest('[data-slot="settings-row"]')! |
| 257 | + .dispatchEvent(new MouseEvent("contextmenu", { bubbles: true })); |
| 258 | + container |
| 259 | + .querySelector<HTMLButtonElement>('button[aria-label="Archived thread actions for Project"]')! |
| 260 | + .click(); |
| 261 | + }); |
| 262 | + expect(state[method]).toHaveBeenCalledOnce(); |
| 263 | + expect(state.showContextMenu).not.toHaveBeenCalled(); |
| 264 | + expect(document.querySelector('[role="menu"]')).toBeNull(); |
| 265 | + |
| 266 | + await act(async () => openContextMenu()); |
| 267 | + expect(state.showContextMenu).toHaveBeenCalledOnce(); |
| 268 | + const calls = state[method].mock.calls.length; |
| 269 | + await act(async () => |
| 270 | + pending.resolve(AsyncResult.failure(Cause.fail(new Error("Disconnected")))), |
| 271 | + ); |
| 272 | + expect(state.toast).toHaveBeenCalledWith( |
| 273 | + expect.objectContaining({ description: "Disconnected" }), |
| 274 | + ); |
| 275 | + await act(async () => button.click()); |
| 276 | + expect(state[method]).toHaveBeenCalledTimes(calls + 1); |
| 277 | +}); |
0 commit comments