Skip to content

test(FilesHooks): add tests for fileMove, fileMovePost, and generate*Activities#2574

Open
miaulalala wants to merge 1 commit intomasterfrom
refactor/fileshooks-move-tests
Open

test(FilesHooks): add tests for fileMove, fileMovePost, and generate*Activities#2574
miaulalala wants to merge 1 commit intomasterfrom
refactor/fileshooks-move-tests

Conversation

@miaulalala
Copy link
Copy Markdown
Collaborator

Summary

Adds 21 tests covering the previously-untested move/rename path in FilesHooks, which is a prerequisite for safely extracting it into a dedicated class.

  • fileMove: .part-file guard skips lookup; all four moveCase values set correctly (rename / moveUp / moveDown / moveCross); aborts and sets moveCase = false when parent file ID is 0
  • fileMovePost: early return when moveCase is false; dispatches to fileRenaming for rename; dispatches to fileMoving for all three move cases; always resets moveCase to false afterward
  • generateDeleteActivities / generateAddActivities: empty-users no-op; current user gets *_self subject; other user gets *_by subject
  • generateMoveActivities: same no-op / self / by coverage; plus the parentId-vs-fileId branch triggered when old and new filenames are identical

Private getFileChangeActivitySettings is exercised through its dependencies (UserSettings::filterUsersBySetting, TagManager::getUsersFavoritingObject) rather than being mocked directly.

Test plan

  • 73 FilesHooks tests pass (21 new)

🤖 AI-Assisted-By: Claude Sonnet 4.6 noreply@anthropic.com

…Activities

Covers all previously-untested move/rename paths:
- fileMove: .part-file guard, all four moveCase values (rename/moveUp/
  moveDown/moveCross), abort when parent fileId is 0
- fileMovePost: early-return when moveCase is false, dispatch to
  fileRenaming for rename, dispatch to fileMoving for all three
  move cases; moveCase reset to false after dispatch
- generateDeleteActivities / generateAddActivities: empty-users no-op,
  current-user gets *_self subject, other user gets *_by subject
- generateMoveActivities: same no-op/self/by coverage plus the
  parentId-vs-fileId branch when old and new filenames are equal

Signed-off-by: Anna Larch <anna@nextcloud.com>
AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@miaulalala miaulalala force-pushed the refactor/fileshooks-move-tests branch from cd8d5cc to 91d022a Compare May 6, 2026 23:08
@cypress
Copy link
Copy Markdown

cypress Bot commented May 6, 2026

Base automatically changed from refactor/early-returns-2 to master May 7, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant