Skip to content

test(web): add unit tests for create-from-template action#12544

Open
dj4oC wants to merge 2 commits into
masterfrom
test/web-external-create-from-template-tests
Open

test(web): add unit tests for create-from-template action#12544
dj4oC wants to merge 2 commits into
masterfrom
test/web-external-create-from-template-tests

Conversation

@dj4oC

@dj4oC dj4oC commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description

Adds unit test coverage for the web "create from template" action extension
(useActionExtensionCreateFromTemplate in
web/packages/web-app-external/src/extensions/createFromTemplate.ts), which had
no tests.

New file: web/packages/web-app-external/tests/unit/extensions/createFromTemplate.spec.ts.

isVisible cases: 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.

handler cases: successful file creation + navigation to the editor route with the correct contextRouteName/contextRouteParams/contextRouteQuery params; duplicate-filename resolution via resolveFileNameDuplicate; error path where showErrorMessage is called when listFiles or createFileHandler throws.

Moved from the now-deprecated owncloud/web repo (frontend consolidated into owncloud/ocis under web/). Supersedes owncloud/web#13942.

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?

  • test environment: pnpm --filter external test:unit in web/ (vitest 4.1.6, node 22)
  • result: Test Files 1 passed, Tests 9 passed (9)
  • coverage on src/extensions/createFromTemplate.ts: 97.56% lines, 100% branches (above the 85% target; the single uncovered function is the label() getter)
  • eslint clean · prettier --check clean

This 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. The web/ subtree carries no per-file SPDX headers on existing source/test files, so none were added (consistent with the codebase).

Types of changes

  • Tests only (no source changes)

Checklist:

  • Unit tests added

🤖 Automated by Claude Code


Generated by Claude Code

claude added 2 commits July 9, 2026 19:12
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>
@kw-security

kw-security commented Jul 9, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unit test coverage for "create from template" feature

3 participants