Repository navigation
Migrate to nextcloud-viewer v2 #2854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d48fe4d
chore: install @nextcloud/viewer library
mejo- 2daf4d9
chore(viewer): migrate to @nextcloud/viewer v2
mejo- d85d8bb
fix(viewer): allow to open page sidebar from viewer in attachments view
mejo- 50ccf38
test(playwright): adjust link bubble tests to new Text behaviour
mejo- 402152b
test(cypress): fix Text route interceptions with Nextcloud 35+
mejo- dbe0dd5
chore: add AGENTS.md with instructions for AI agents
mejo- 1e98760
test(playwright): test opening page sidebar from viewer
mejo- 2f9dbf2
test: migrate page attachments tests from Cypress to Playwright
mejo- 26ac085
fix(attachments): open attachments in viewer on public shares
mejo- a333fcd
test: adjust selectors for new toast messages
mejo- 71fc66e
fix(viewer): bring back support for viewer on stable35 and below
mejo- 8836545
test(playwright): accept self-signed certificates of local instances
mejo- 3f3b15e
test(e2e): don't pin and build particular Text Git references
mejo- 60211c0
test(playwright): fix failing tests with latest Text version
mejo- a44397f
test(playwright): fix files app URL in FilesAppSection
mejo- 5b8769b
test(playwright): fix image locator in `hasImage()`
mejo- File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| AGENTS.md | ||
| build/ | ||
| node_modules/ | ||
| /vendor/ | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| <!-- | ||
| - SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| - SPDX-License-Identifier: AGPL-3.0-or-later | ||
| --> | ||
| # AGENTS.md | ||
|
|
||
| Nextcloud Collectives. PHP backend (`lib/`) + Vue.js frontend (`src/`). | ||
|
|
||
| --- | ||
|
|
||
| ## Generic notes | ||
|
|
||
| In frontend, always generate Typescript files when creating new files. Existing `.js` specs are not a template for new code. | ||
|
|
||
| For new e2e tests, always generate Playwright tests. Where appropriate, suggest to migrate Cypress tests to Playwright. The goal is to migrate completely from Cypress to Playwright in the future. | ||
|
|
||
| ## Contributions | ||
|
|
||
| - Conventional Commits with a scope (e.g. `fix(versions): ...`). | ||
| - AI-assisted commits get an `Assisted-by: <Tool>:<model>` trailer. | ||
| - Changed or added code needs unit tests: Vitest in `src/tests/`, PHPUnit in `tests/Unit/`. | ||
| - New files need SPDX headers (REUSE CI enforces this). | ||
| - Comments describe the code, not the change that produced it. | ||
| - Keep PRs to one concern. Disclose AI use in the PR description (the template has a section for it). | ||
|
|
||
| ## Commands | ||
|
|
||
| ### Install | ||
|
|
||
| ```bash | ||
| npm ci # JS deps | ||
| composer install # PHP deps (uses platform php=8.2 regardless of local PHP) | ||
| ``` | ||
|
|
||
| ### Build | ||
|
|
||
| ```bash | ||
| npm run build # Production (Vite, NODE_ENV=production) | ||
| npm run dev # Dev build | ||
| ``` | ||
|
|
||
| ### Frontend tests (Vitest, jsdom, no server needed) | ||
|
|
||
| ```bash | ||
| npm run test # Run all unit tests once | ||
| npx vitest run src/tests/util/sortOrders..spec.js # Single file | ||
| npx vitest run -t "pattern" # Filter by name | ||
| ``` | ||
|
|
||
| Unit specs live in `src/tests/**/*.spec.{js,ts}`; E2E specs live in `playwright/e2e/`. | ||
|
|
||
| ### PHP unit tests (requires full Nextcloud server install β see below) | ||
|
|
||
| ```bash | ||
| composer run test:unit # phpunit -c tests/phpunit.xml | ||
| vendor/bin/phpunit --filter testMethodName tests/Unit/Service/EmojiHelperTest.php | ||
| ``` | ||
|
|
||
| PHPUnit should only be run with the user's consent (see Testing gotchas). | ||
|
|
||
| ### Lint / typecheck / format | ||
|
|
||
| ```bash | ||
| npm run lint # tsc typecheck + ESLint | ||
| npm run lint:fix # ESLint auto-fix | ||
| npm run stylelint # Stylelint for CSS/SCSS/Vue styles | ||
| composer run lint # PHP syntax check (php -l) | ||
| composer run cs:check # PHP code style check (php-cs-fixer --dry-run) | ||
| composer run cs:fix # php-cs-fixer auto-fix | ||
| composer run psalm # Psalm static analysis (level 4, baseline: tests/psalm-baseline.xml) | ||
| composer run rector # Rector refactoring (followed by cs:fix) | ||
| ``` | ||
|
|
||
| ### E2E β Playwright (newer suite) | ||
|
|
||
| ```bash | ||
| npx playwright install chromium --only-shell # One-time browser install | ||
| npx playwright test | ||
| npx playwright test playwright/e2e/settings.spec.ts | ||
| npx playwright test --grep "pattern" | ||
| ``` | ||
|
|
||
| - Default URL: `http://localhost:8089/index.php/`. Unless a server already runs there, `playwright.config.ts` starts Nextcloud in Docker (`playwright/start-nextcloud-server.js`). | ||
| - CI runs 4 shards. | ||
| - Setting the `baseURL` env var skips the Docker `webServer`, but most tests still need the container: the fixtures `random-user.ts` and `Collective.ts` create test users with `createRandomUser()` from `@nextcloud/e2e-test-server/playwright`, which runs `occ` inside it. | ||
|
|
||
| #### Optional: running against an existing local Nextcloud instance | ||
|
|
||
| 1. Build first (`npm run dev`) if not already done, since the instance serves `js/` and `css/` from this checkout. | ||
| 2. Run the tests from a scratch copy whose `random-user.ts` and `Collective.ts` create users via OCS (`POST /ocs/v2.php/cloud/users` with `OCS-APIRequest: true` and admin credentials) instead of `createRandomUser()`. | ||
| 3. Set `baseURL`. If Node doesn't trust the instance's certificate, also set `NODE_TLS_REJECT_UNAUTHORIZED=0`: | ||
| ```bash | ||
| baseURL=https://nextcloud.local/index.php/ \ | ||
| npx playwright test playwright/e2e/page-attachments.spec.ts --project=chromium | ||
| ``` | ||
|
|
||
| Tests that run `occ` directly still fail without the container: `page-content.spec.s` (whiteboard), `page-share.spec.ts`, `unified-search.spec.ts`, `version-comparison.spec.ts`, and collectives created with `markdownImportPath`. | ||
|
|
||
| ### E2E β Cypress (deprecated, requires Nextcloud server) | ||
|
|
||
| ```bash | ||
| npx cypress open # Interactive Cypress UI (run from repo root) | ||
| npx cypress run --spec "cypress/e2e/files.spec.js" # Single spec | ||
| ``` | ||
|
|
||
| - Default server URL: `http://localhost:8081/index.php`. Override with `CYPRESS_baseUrl`. | ||
| - CI uses 4 parallel runners via `cypress-split`. | ||
|
|
||
| ## Testing gotchas | ||
|
|
||
| **Behat integration tests** require a live Nextcloud reachable at `https://nextcloud.local` | ||
| (the default Behat profile). | ||
|
|
||
| **PHPUnit** should not be run without manual consent as it might brick the development instance. | ||
|
|
||
| --- | ||
|
|
||
| ## Architecture notes | ||
|
|
||
| - **Multiple frontend entry points** (`vite.config.ts`): `icons`, `init`, `main`, `reference`, `settings-admin`; the PWA service worker is also compiled from `src/`. | ||
| - **Built assets are not committed.** `js/` and `css/` contain compiled output but it's not tracked in Git. | ||
| - **Version lives only in `appinfo/info.xml`** β not in `package.json` or `composer.json`. | ||
| - **vendor-bin isolation.** PHP dev tools (phpunit, psalm, php-cs-fixer, behat, openapi-extractor) each have their own scoped Composer install under `vendor-bin/`. They are accessible via `./vendor/bin/` symlinks. | ||
|
|
||
| ## OpenAPI | ||
|
|
||
| Run `composer run openapi` after any OCS API change. The `openapi.yml` CI workflow fails if | ||
| `openapi.json` has uncommitted changes. | ||
|
|
||
| ## Psalm | ||
|
|
||
| - Error level 4, PHP 8.2 target; baseline at `tests/psalm-baseline.xml` | ||
| - Run `composer run psalm:update-baseline` to update the baseline (requires review β don't use | ||
| it to silently suppress new issues) | ||
|
|
||
| ## License compliance (REUSE) | ||
|
|
||
| Every new file needs SPDX headers (as PHP/JS/HTML comment): | ||
|
|
||
| ``` | ||
| SPDX-FileCopyrightText: <year> Nextcloud GmbH and Nextcloud contributors | ||
| SPDX-License-Identifier: AGPL-3.0-or-later | ||
| ``` | ||
|
|
||
| Bulk entries for files that can't carry inline headers go in `REUSE.toml`. The `reuse.yml` | ||
| CI workflow enforces compliance on every PR. |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of this seems useful for humans as well. I wonder if we could have all the generic useful stuff in our development docs and then point there from
AGENTS.mdto avoid duplication.(As a follow up / separate from this PR)