Skip to content

test(external): add unit tests for create-from-template action#13942

Closed
dj4oC wants to merge 2 commits into
masterfrom
fix/web/11786-create-from-template-unit-tests
Closed

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

Conversation

@dj4oC

@dj4oC dj4oC commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description

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

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

isVisible cases covered:

  • more than one resource selected → false
  • no personal space present → false
  • resource not downloadable → false
  • no matching app-provider template mime type → false
  • single matching template resource → true

handler cases covered:

  • successful file creation and navigation to the editor route with the correct
    contextRouteName/contextRouteParams/contextRouteQuery params
  • duplicate-filename resolution via resolveFileNameDuplicate when a file of the
    same name already exists in the personal space root
  • error path where showErrorMessage is called when the webdav listFiles call
    or createFileHandler throws

Related Issue

Motivation and Context

The action was shipped without unit tests. These tests pin down the visibility
predicate and the create/navigate/error flow so future changes to the extension
are guarded.

How Has This Been Tested?

  • test environment: pnpm --filter external test:unit (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, 88.88% funcs
    (well above the 85% target; the single uncovered
    function is the label() getter, which is not part of the acceptance criteria)
  • eslint on the new file: clean
  • prettier --check: clean
  • full-repo vue-tsc --noEmit: no type errors

This is a test-only change — no product code is modified.

Documentation checklist

  • Changelog: added changelog/unreleased/change-add-create-from-template-tests.
  • REUSE/SPDX headers: not applicable — this repo uses a single root LICENSE
    and carries no per-file SPDX headers on any existing source or test file, so
    none were added, to stay consistent with the codebase.
  • Admin/end-user docs, WCAG note, OTEL metrics: not applicable (no behaviour or
    UI change).

Phase 4 pre-flight review (non-blocking findings): none — the change adds an
isolated spec with fully mocked dependencies (no network, deterministic).

Risk level: minimal (adds tests only).

Open tasks:

  • none

🤖 Automated by Claude Code

The "create from template" action extension added in PR #11775
(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, and the
positive case) and handler (successful creation and editor navigation
with context-route params, duplicate-filename resolution, and the error
path that surfaces showErrorMessage).

Closes: #11786

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: dj4oC <noreply@github.com>
@update-docs

update-docs Bot commented Jul 9, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@kw-security

kw-security commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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.

Closes: #11786

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: dj4oC <noreply@github.com>
@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

dj4oC commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by owncloud/ocis#12544.

The owncloud/web frontend has been consolidated into owncloud/ocis (under web/), so this test coverage has been moved there. Closing in favour of the ocis PR.

🤖 Automated by Claude Code


Generated by Claude Code

@dj4oC dj4oC closed this Jul 9, 2026
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

4 participants