Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

feat(control-ui): folder drag moves with path guards and one confirmation

Mb617587276a3
diff --git a/control-ui/app/globals.css b/control-ui/app/globals.css
index c0f62a48f..2ce73579c 100644
--- a/control-ui/app/globals.css
+++ b/control-ui/app/globals.css
@@ -14710,3 +14710,38 @@ button.cu-gfs-tree__button:focus-visible,
}
}
}
+
+/* ── GfsMoveConfirmDialog (rev-2 drag-and-drop D2) ─────────────────────────
+ One confirmation for folder drag moves: impact + naming policy. Reuses the
+ established move-dialog action/token vocabulary. */
+.cu-gfs-move-confirm {
+ max-width: 30rem;
+}
+
+.cu-gfs-move-confirm__header h3 {
+ margin: 0;
+}
+
+.cu-gfs-move-confirm__body {
+ display: grid;
+ gap: var(--cu-space-3);
+ padding: var(--cu-space-3) 0;
+}
+
+.cu-gfs-move-confirm__impact {
+ margin: 0;
+ color: var(--cu-text-muted, var(--cu-text-dim));
+}
+
+.cu-gfs-move-confirm__rename-toggle {
+ display: flex;
+ align-items: center;
+ gap: var(--cu-space-1);
+ cursor: pointer;
+}
+
+.cu-gfs-move-confirm__actions {
+ display: flex;
+ justify-content: flex-end;
+ gap: var(--cu-space-1);
+}
diff --git a/control-ui/components/GfsBrowser.tsx b/control-ui/components/GfsBrowser.tsx
index d2b70d599..8ba96e071 100644
--- a/control-ui/components/GfsBrowser.tsx
+++ b/control-ui/components/GfsBrowser.tsx
@@ -5,7 +5,9 @@ import { SingleValueEditDialog } from '@clerum/frontend-components'
import {
GFS_UPLOAD_NAME_EXHAUSTED_MESSAGE,
GFS_UPLOAD_NAME_RETRY_LIMIT,
+ GFS_MOVE_MAX_NETWORK_ATTEMPTS,
createGfsUploadNameReservationBook,
+ decideDragPathStructure,
gfsUploadNameRetryDecision,
isGfsNameConflict,
nextAvailableGfsResourceName,
@@ -14,6 +16,7 @@ import {
import { FileUploadModal } from '@components/FileUploadModal'
import { GfsImagePreview } from '@components/GfsImagePreview'
import { GfsMarkdownPreview } from '@components/GfsMarkdownPreview'
+import { GfsMoveConfirmDialog } from '@components/GfsMoveConfirmDialog'
import { GfsMoveDialog } from '@components/GfsMoveDialog'
import { GfsOpenLinkModal } from '@components/GfsOpenLinkModal'
import { GfsVideoPreview } from '@components/GfsVideoPreview'
@@ -212,8 +215,6 @@ type TrailReconstructionOutcome = 'applied' | 'failed' | 'superseded'
const DRIVE = 'main'
const PENDING_GFS_UPLOAD_KEY = 'evenfire:gfs-upload-v2:pending'
const GFS_RESOURCE_DRAG_TYPE = 'application/x-evenfire-gfs-resource'
-const GFS_MOVE_NAME_EXHAUSTED_MESSAGE =
- 'Could not move this resource because all numbered names are already in use.'
interface PendingGfsUpload {
uploadId?: string
@@ -402,6 +403,13 @@ export function GfsBrowser(): React.JSX.Element {
const [dragOverFolderId, setDragOverFolderId] = useState<string | null>(null)
const [movingResourceId, setMovingResourceId] = useState<string | null>(null)
const [moveTarget, setMoveTarget] = useState<GfsChild | null>(null)
+ // rev-2 §1: a folder DROP stops at ONE confirmation (impact + naming
+ // policy); files move directly; the Move dialog is its own confirmation.
+ const [confirmMoveTarget, setConfirmMoveTarget] = useState<{
+ source: GfsChild
+ destination: GfsChild
+ suggestedName?: string
+ } | null>(null)
const moveTargetRef = useRef(moveTarget)
moveTargetRef.current = moveTarget
// R5-M1 recovery: the Move PATCH succeeded but the breadcrumb trail could
@@ -1294,7 +1302,8 @@ export function GfsBrowser(): React.JSX.Element {
}
function handleResourceDragStart(event: React.DragEvent<HTMLLIElement>, child: GfsChild): void {
- if (child.kind === 'directory' || movingResourceRef.current) {
+ // Files AND folders drag (rev-2 D2); an in-flight move freezes sources.
+ if (movingResourceRef.current) {
event.preventDefault()
return
}
@@ -1337,8 +1346,9 @@ export function GfsBrowser(): React.JSX.Element {
async function moveResource(
source: GfsChild,
destination: Pick<GfsChild, 'resourceId' | 'name' | 'kind'>,
- bubbleError = false
+ options: { bubbleError?: boolean; allowNumberedRename?: boolean } = {}
): Promise<void> {
+ const { bubbleError = false, allowNumberedRename = true } = options
if (
destination.kind !== 'directory' ||
source.resourceId === destination.resourceId ||
@@ -1354,7 +1364,10 @@ export function GfsBrowser(): React.JSX.Element {
let moveName = source.name
let moved = false
let moveResult: unknown
- for (let attempt = 0; attempt < GFS_UPLOAD_NAME_RETRY_LIMIT; attempt += 1) {
+ // rev-2 §5: at most three network attempts per gesture under an
+ // approved numbered-name policy; a single attempt otherwise.
+ const maxAttempts = allowNumberedRename ? GFS_MOVE_MAX_NETWORK_ATTEMPTS : 1
+ for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
try {
moveResult = await apiSend(
'PATCH',
@@ -1371,14 +1384,20 @@ export function GfsBrowser(): React.JSX.Element {
break
} catch (error) {
if (!isGfsNameConflict(error)) throw error
- occupiedNames.add(moveName)
- if (attempt + 1 >= GFS_UPLOAD_NAME_RETRY_LIMIT) {
- throw new Error(GFS_MOVE_NAME_EXHAUSTED_MESSAGE)
+ if (!allowNumberedRename) {
+ throw new Error(
+ 'An item with this name already exists. Choose another folder, or use Move to change its name.'
+ )
}
+ occupiedNames.add(moveName)
+ if (attempt + 1 >= maxAttempts) break
moveName = nextAvailableGfsResourceName(source.name, occupiedNames)
}
}
- if (!moved) throw new Error(GFS_MOVE_NAME_EXHAUSTED_MESSAGE)
+ if (!moved) {
+ // A concurrent naming storm, not "all numbered names used".
+ throw new Error('The destination changed. Refresh it or choose another folder.')
+ }
const movedResource = (
moveResult as { data?: { resourceId?: string; version?: number } } | undefined
)?.data
@@ -1396,6 +1415,12 @@ export function GfsBrowser(): React.JSX.Element {
: `Moved "${source.name}" to "${destination.name}" as "${moveName}".`,
{ tone: 'success' }
)
+ if (source.kind === 'directory') {
+ showToast(
+ 'Moving a folder changes who can access its contents — access now follows the new location.',
+ { tone: 'info' }
+ )
+ }
// A move changes the moved folder's ANCESTRY. When the moved resource
// is part of the open breadcrumb trail, patching only its own crumb
// would leave every crumb above it describing the OLD location (R5-M1):
@@ -1538,6 +1563,36 @@ export function GfsBrowser(): React.JSX.Element {
await rebuildTrailFromNewLocation(recovery.resourceId, recovery.gfsUri)
}
+ /** Resolve a resource's canonical path from a current authorized view
+ * (rev-2 §3.2): the operator resolve contract returns `path`; a null or
+ * absent path NEVER certifies structure — callers fall back to the atomic
+ * server check. */
+ async function canonicalPathOf(child: Pick<GfsChild, 'gfsUri' | 'path'>): Promise<string | null> {
+ if (typeof child.path === 'string' && child.path.length > 0) return child.path
+ try {
+ const view = (await apiGet('/api/v1/gfs/resolve', { uri: child.gfsUri })) as {
+ path?: string | null
+ }
+ return typeof view.path === 'string' && view.path.length > 0 ? view.path : null
+ } catch {
+ return null
+ }
+ }
+
+ function structureDenialMessage(reason: 'self' | 'descendant' | 'same-parent' | 'root-source' | 'cross-drive'): string {
+ switch (reason) {
+ case 'same-parent':
+ return 'This item is already in this folder.'
+ case 'descendant':
+ case 'self':
+ return 'A folder cannot be moved into itself or one of its subfolders.'
+ case 'root-source':
+ return 'The top-level folder cannot be moved.'
+ default:
+ return 'Items can’t be moved between drives.'
+ }
+ }
+
async function handleFolderDrop(
event: React.DragEvent<HTMLLIElement>,
folder: GfsChild
@@ -1548,7 +1603,34 @@ export function GfsBrowser(): React.JSX.Element {
setDragOverFolderId(null)
const source = draggingResourceRef.current
if (!source) return
- await moveResource(source, folder)
+ if (source.kind === 'file') {
+ // Files cannot be ancestors: no structural risk; move directly.
+ await moveResource(source, folder)
+ return
+ }
+ // Folder drops stop at ONE confirmation (rev-2 §1) after the fresh-path
+ // structural guard — the impact dialog also records the naming policy.
+ const [sourcePath, targetPath] = await Promise.all([
+ canonicalPathOf(source),
+ canonicalPathOf(folder),
+ ])
+ const structure = decideDragPathStructure({ sourcePath, targetPath })
+ if (structure.kind === 'deny') {
+ showToast(structureDenialMessage(structure.reason), { tone: 'error' })
+ return
+ }
+ const occupiedNames = new Set<string>(
+ (childCacheRef.current.get(folder.resourceId)?.items ?? []).map(item => item.name)
+ )
+ const suggested =
+ occupiedNames.size > 0 && occupiedNames.has(source.name)
+ ? nextAvailableGfsResourceName(source.name, occupiedNames)
+ : undefined
+ setConfirmMoveTarget({
+ source,
+ destination: folder,
+ ...(suggested !== undefined ? { suggestedName: suggested } : {}),
+ })
}
async function uploadWithCompatibility(
@@ -2256,7 +2338,7 @@ export function GfsBrowser(): React.JSX.Element {
const rowOpenable = child.kind === 'directory' || isGfsPreviewFile(child.name)
const isDragging = draggingResourceId === child.resourceId
const isDropTarget = dragOverFolderId === child.resourceId
- const canDragResource = child.kind !== 'directory' && movingResourceId === null
+ const canDragResource = movingResourceId === null
const openRow = () => {
if (child.kind === 'directory') openDirectory(child)
else openFilePreview(child)
@@ -2611,7 +2693,7 @@ export function GfsBrowser(): React.JSX.Element {
await moveResource(
moveTarget,
{ resourceId: destinationId, name: destinationName, kind: 'directory' },
- true
+ { bubbleError: true }
)
setMoveTarget(null)
}}
@@ -2619,6 +2701,28 @@ export function GfsBrowser(): React.JSX.Element {
/>
) : null}
+ {confirmMoveTarget ? (
+ <GfsMoveConfirmDialog
+ busy={movingResourceId === confirmMoveTarget.source.resourceId}
+ onCancel={() => setConfirmMoveTarget(null)}
+ onConfirm={({ allowNumberedRename }) => {
+ const pending = confirmMoveTarget
+ setConfirmMoveTarget(null)
+ if (pending) {
+ void moveResource(pending.source, pending.destination, { allowNumberedRename })
+ }
+ }}
+ request={{
+ sourceName: confirmMoveTarget.source.name,
+ destinationName: confirmMoveTarget.destination.name,
+ canRename: true,
+ ...(confirmMoveTarget.suggestedName !== undefined
+ ? { suggestedName: confirmMoveTarget.suggestedName }
+ : {}),
+ }}
+ />
+ ) : null}
+
{uploadOpen ? (
<FileUploadModal
busy={uploading}
diff --git a/control-ui/components/GfsMoveConfirmDialog/index.tsx b/control-ui/components/GfsMoveConfirmDialog/index.tsx
new file mode 100644
index 000000000..e0d85a3f2
--- /dev/null
+++ b/control-ui/components/GfsMoveConfirmDialog/index.tsx
@@ -0,0 +1,102 @@
+'use client'
+
+import { useEffect, useState } from 'react'
+import { Button } from '@components/ui'
+
+export interface GfsMoveConfirmRequest {
+ sourceName: string
+ destinationName: string
+ /** Suggested numbered-name candidate, when destination names are known. */
+ suggestedName?: string
+ /** Numbered renaming is allowed (operator plane: intrinsic write). */
+ canRename: boolean
+}
+
+export interface GfsMoveConfirmDialogProps {
+ request: GfsMoveConfirmRequest
+ busy?: boolean
+ onConfirm: (options: { allowNumberedRename: boolean }) => void
+ onCancel: () => void
+}
+
+/**
+ * The ONE confirmation for folder drag moves (rev-2 §1): explains the
+ * inherited-access impact and records the conflict naming policy in the same
+ * dialog, so no second automatic prompt follows the drop. Cancel ends the
+ * admission before dispatch; once the PATCH is dispatched it cannot be
+ * recalled. Files move without confirmation; the Move dialog is its own
+ * explicit confirmation surface.
+ */
+export function GfsMoveConfirmDialog({
+ request,
+ busy = false,
+ onConfirm,
+ onCancel,
+}: GfsMoveConfirmDialogProps): React.JSX.Element {
+ const [allowNumberedRename, setAllowNumberedRename] = useState(false)
+
+ useEffect(() => {
+ if (busy) return
+ function handleKeyDown(event: KeyboardEvent): void {
+ if (event.key === 'Escape') onCancel()
+ }
+ window.addEventListener('keydown', handleKeyDown)
+ return () => window.removeEventListener('keydown', handleKeyDown)
+ }, [busy, onCancel])
+
+ return (
+ <div
+ className="cu-modal-backdrop"
+ role="presentation"
+ onMouseDown={event => {
+ if (!busy && event.target === event.currentTarget) onCancel()
+ }}
+ >
+ <section
+ aria-label={`Move folder ${request.sourceName} to ${request.destinationName}`}
+ aria-modal="true"
+ className="cu-modal-panel cu-gfs-move-confirm"
+ role="dialog"
+ >
+ <header className="cu-gfs-move-confirm__header">
+ <h3>
+ Move “{request.sourceName}” to “{request.destinationName}”?
+ </h3>
+ </header>
+ <div className="cu-gfs-move-confirm__body">
+ <p className="cu-gfs-move-confirm__impact">
+ Inherited access to this folder and its contents follows the new location. Direct
+ sharing entries stay with their items, and grantees may lose access.
+ </p>
+ {request.canRename ? (
+ <label className="cu-gfs-move-confirm__rename-toggle">
+ <input
+ checked={allowNumberedRename}
+ disabled={busy}
+ onChange={event => setAllowNumberedRename(event.target.checked)}
+ type="checkbox"
+ />
+ <span>
+ {request.suggestedName
+ ? `Use a numbered name if needed (e.g. “${request.suggestedName}”)`
+ : 'Use a numbered name if needed'}
+ </span>
+ </label>
+ ) : null}
+ </div>
+ <footer className="cu-gfs-move-confirm__actions">
+ <Button autoFocus disabled={busy} onClick={onCancel} variant="ghost">
+ Cancel
+ </Button>
+ <Button
+ disabled={busy}
+ onClick={() => onConfirm({ allowNumberedRename })}
+ variant="primary"
+ >
+ {busy ? 'Moving…' : 'Move'}
+ </Button>
+ </footer>
+ </section>
+ </div>
+ )
+}
diff --git a/control-ui/components/__tests__/GfsBrowser.test.tsx b/control-ui/components/__tests__/GfsBrowser.test.tsx
index 840948a02..102d6442e 100644
--- a/control-ui/components/__tests__/GfsBrowser.test.tsx
+++ b/control-ui/components/__tests__/GfsBrowser.test.tsx
@@ -1844,7 +1844,8 @@ describe('GfsBrowser', () => {
expect(fileRow).not.toBeNull()
expect(folderRow).not.toBeNull()
expect(fileRow).toHaveAttribute('draggable', 'true')
- expect(folderRow).toHaveAttribute('draggable', 'false')
+ // rev-2 D2: folders drag too (moves via the drop-target rows).
+ expect(folderRow).toHaveAttribute('draggable', 'true')
const dataTransfer = {
dropEffect: 'none',
@@ -3831,3 +3832,217 @@ describe('GfsBrowser', () => {
expect(screen.getByRole('button', { name: 'Load more' })).toBeTruthy()
})
})
+
+// ── folder drag moves (rev-2 D2) ─────────────────────────────────────────────
+
+describe('GfsBrowser — folder drag-and-drop', () => {
+ // The file's shared mock reset lives inside the sibling describe('GfsBrowser')
+ // block; this block resets the same API mocks for itself.
+ beforeEach(() => {
+ mockApiGet.mockReset()
+ mockApiSend.mockReset()
+ })
+
+ function folderPage() {
+ const archive = child('archive', 'directory', 1)
+ const projects = child('projects', 'directory', 2)
+ mockApiGet.mockImplementation(async (path: string) => {
+ if (path === '/api/v1/gfs/tree' || path === '/api/v1/gfs/resources/11111111-1111-1111-1111-111111111111/children') {
+ return {
+ rootResourceId: '11111111-1111-1111-1111-111111111111',
+ items: [archive, projects],
+ nextCursor: null,
+ }
+ }
+ return { items: [], nextCursor: null }
+ })
+ return { archive, projects }
+ }
+
+ function dragAndDrop(sourceRow: HTMLElement, destinationRow: HTMLElement) {
+ const dataTransfer = {
+ dropEffect: 'none',
+ effectAllowed: 'uninitialized',
+ files: [],
+ types: ['application/x-evenfire-gfs-resource'],
+ setData: vi.fn(),
+ getData: vi.fn(),
+ }
+ fireEvent.dragStart(sourceRow, { dataTransfer })
+ fireEvent.dragEnter(destinationRow, { dataTransfer })
+ fireEvent.dragOver(destinationRow, { dataTransfer })
+ fireEvent.drop(destinationRow, { dataTransfer })
+ fireEvent.dragEnd(sourceRow, { dataTransfer })
+ }
+
+ it('stops a folder drop at the one confirmation and commits on Move', async () => {
+ const { archive, projects } = folderPage()
+ mockApiSend.mockResolvedValueOnce({ ok: true, data: { resourceId: 'id-2', version: 1 } })
+ renderBrowser()
+
+ await waitFor(() =>
+ expect(screen.queryByRole('status', { name: 'Loading files' })).toBeNull()
+ )
+ const projectsRow = within(screen.getByRole('list', { name: 'Current folder resources' }))
+ .getByText('projects')
+ .closest('li')!
+ const archiveRow = within(screen.getByRole('list', { name: 'Current folder resources' }))
+ .getByText('archive')
+ .closest('li')!
+
+ dragAndDrop(projectsRow, archiveRow)
+
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move folder projects to archive',
+ })
+ expect(
+ within(dialog).getByText(/Inherited access to this folder and its contents follows the new location/)
+ ).toBeTruthy()
+ // The structure guard passed on fresh canonical paths (both rows carry
+ // paths; sibling folders are structurally safe) — no request yet.
+ expect(mockApiSend).not.toHaveBeenCalled()
+
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenCalledWith(
+ 'PATCH',
+ '/api/v1/gfs/resources/id-2',
+ { drive: 'main', newParentId: 'id-1', ifMatch: 0 },
+ { drive: 'main' }
+ )
+ )
+ expect(await screen.findByText('Moved "projects" to "archive".')).toBeTruthy()
+ expect(await screen.findByText(/access now follows the new location/)).toBeTruthy()
+ expect(screen.queryByRole('dialog')).toBeNull()
+ void projects
+ })
+
+ it('cancelling the folder confirmation sends no PATCH and claims no move', async () => {
+ folderPage()
+ renderBrowser()
+
+ await waitFor(() =>
+ expect(screen.queryByRole('status', { name: 'Loading files' })).toBeNull()
+ )
+ const list = screen.getByRole('list', { name: 'Current folder resources' })
+ const projectsRow = within(list).getByText('projects').closest('li')!
+ const archiveRow = within(list).getByText('archive').closest('li')!
+
+ dragAndDrop(projectsRow, archiveRow)
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move folder projects to archive',
+ })
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Cancel' }))
+
+ expect(mockApiSend).not.toHaveBeenCalled()
+ expect(screen.queryByText(/Moved/)).toBeNull()
+ expect(screen.queryByRole('dialog')).toBeNull()
+ })
+
+ it('refuses a folder drop into its own descendant using canonical paths', async () => {
+ // projects lives at /projects; archive lives at /projects/archive — a
+ // child of the source. The listing rows carry those paths.
+ const projects = child('projects', 'directory', 2)
+ const nestedArchive = child('archive', 'directory', 1)
+ nestedArchive.path = '/projects/archive'
+ mockApiGet.mockImplementation(async (path: string) => {
+ if (path === '/api/v1/gfs/tree' || path === '/api/v1/gfs/resources/11111111-1111-1111-1111-111111111111/children') {
+ return {
+ rootResourceId: '11111111-1111-1111-1111-111111111111',
+ items: [projects, nestedArchive],
+ nextCursor: null,
+ }
+ }
+ return { items: [], nextCursor: null }
+ })
+ renderBrowser()
+
+ await waitFor(() =>
+ expect(screen.queryByRole('status', { name: 'Loading files' })).toBeNull()
+ )
+ const list = screen.getByRole('list', { name: 'Current folder resources' })
+ const projectsRow = within(list).getByText('projects').closest('li')!
+ const archiveRow = within(list).getByText('archive').closest('li')!
+
+ dragAndDrop(projectsRow, archiveRow)
+
+ expect(
+ await screen.findByText('A folder cannot be moved into itself or one of its subfolders.')
+ ).toBeTruthy()
+ expect(mockApiSend).not.toHaveBeenCalled()
+ expect(screen.queryByRole('dialog')).toBeNull()
+ })
+
+ it('a folder conflict without the numbered-name opt-in stops after one attempt', async () => {
+ folderPage()
+ const actualApi = await vi.importActual<typeof import('@lib/api')>('@lib/api')
+ const conflict = () => {
+ const text = JSON.stringify({
+ error: { code: 'already_exists', message: 'a resource with this name already exists' },
+ })
+ return actualApi.formatApiError(new Response(text, { status: 409, statusText: 'Conflict' }), text)
+ }
+ mockApiSend.mockRejectedValueOnce(conflict())
+ renderBrowser()
+
+ await waitFor(() =>
+ expect(screen.queryByRole('status', { name: 'Loading files' })).toBeNull()
+ )
+ const list = screen.getByRole('list', { name: 'Current folder resources' })
+ const projectsRow = within(list).getByText('projects').closest('li')!
+ const archiveRow = within(list).getByText('archive').closest('li')!
+
+ dragAndDrop(projectsRow, archiveRow)
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move folder projects to archive',
+ })
+ // The numbered-name policy is an explicit opt-in (unchecked by default).
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ expect(
+ await screen.findByText(/An item with this name already exists/)
+ ).toBeTruthy()
+ expect(mockApiSend).toHaveBeenCalledTimes(1)
+ })
+
+ it('a folder conflict with the numbered-name opt-in renames the whole folder within 3 attempts', async () => {
+ folderPage()
+ const actualApi = await vi.importActual<typeof import('@lib/api')>('@lib/api')
+ const conflict = () => {
+ const text = JSON.stringify({
+ error: { code: 'already_exists', message: 'a resource with this name already exists' },
+ })
+ return actualApi.formatApiError(new Response(text, { status: 409, statusText: 'Conflict' }), text)
+ }
+ mockApiSend
+ .mockRejectedValueOnce(conflict())
+ .mockRejectedValueOnce(conflict())
+ .mockResolvedValueOnce({ ok: true, data: { resourceId: 'id-2', version: 1 } })
+ renderBrowser()
+
+ await waitFor(() =>
+ expect(screen.queryByRole('status', { name: 'Loading files' })).toBeNull()
+ )
+ const list = screen.getByRole('list', { name: 'Current folder resources' })
+ const projectsRow = within(list).getByText('projects').closest('li')!
+ const archiveRow = within(list).getByText('archive').closest('li')!
+
+ dragAndDrop(projectsRow, archiveRow)
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move folder projects to archive',
+ })
+ fireEvent.click(within(dialog).getByRole('checkbox'))
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ await waitFor(() => expect(mockApiSend).toHaveBeenCalledTimes(3))
+ expect(mockApiSend).toHaveBeenNthCalledWith(
+ 3,
+ 'PATCH',
+ '/api/v1/gfs/resources/id-2',
+ { drive: 'main', newParentId: 'id-1', ifMatch: 0, newName: 'projects (2)' },
+ { drive: 'main' }
+ )
+ expect(await screen.findByText('Moved "projects" to "archive" as "projects (2)".')).toBeTruthy()
+ })
+})