test(web): add unit tests for create-from-template action#12544
Open
dj4oC wants to merge 2 commits into
Open
Conversation
The web "create from template" action extension (useActionExtensionCreateFromTemplate) had no unit test coverage. This adds a spec covering isVisible (selection count, missing personal space, non-downloadable resource, no matching template mime type, positive case) and handler (successful creation and editor navigation with context-route params, duplicate-filename resolution, and the error path that surfaces showErrorMessage). Moved from owncloud/web (now consolidated into owncloud/ocis). Closes: owncloud/web#11786 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: dj4oC <noreply@github.com>
Closes: owncloud/web#11786 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: dj4oC <noreply@github.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This was referenced Jul 9, 2026
dj4oC
marked this pull request as ready for review
July 9, 2026 21:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds unit test coverage for the web "create from template" action extension
(
useActionExtensionCreateFromTemplateinweb/packages/web-app-external/src/extensions/createFromTemplate.ts), which hadno tests.
New file:
web/packages/web-app-external/tests/unit/extensions/createFromTemplate.spec.ts.isVisiblecases: more than one resource selected → false; no personal space → false; resource not downloadable → false; no matching app-provider template mime type → false; single matching template → true.handlercases: successful file creation + navigation to the editor route with the correctcontextRouteName/contextRouteParams/contextRouteQueryparams; duplicate-filename resolution viaresolveFileNameDuplicate; error path whereshowErrorMessageis called whenlistFilesorcreateFileHandlerthrows.Related Issue
Motivation and Context
The action was shipped without unit tests. These pin down the visibility predicate and the create/navigate/error flow so future changes are guarded.
How Has This Been Tested?
pnpm --filter external test:unitinweb/(vitest 4.1.6, node 22)Test Files 1 passed,Tests 9 passed (9)src/extensions/createFromTemplate.ts: 97.56% lines, 100% branches (above the 85% target; the single uncovered function is thelabel()getter)eslintclean ·prettier --checkcleanThis is a test-only change — no product source is modified. A changelog entry was added at
changelog/unreleased/change-web-create-from-template-tests.md. Theweb/subtree carries no per-file SPDX headers on existing source/test files, so none were added (consistent with the codebase).Types of changes
Checklist:
🤖 Automated by Claude Code
Generated by Claude Code