diff --git a/.github/workflows/cypress-e2e.yml b/.github/workflows/cypress-e2e.yml deleted file mode 100644 index effce70a12e..00000000000 --- a/.github/workflows/cypress-e2e.yml +++ /dev/null @@ -1,221 +0,0 @@ -# SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-License-Identifier: AGPL-3.0-or-later - -name: Cypress - -on: pull_request - -permissions: - contents: read - -concurrency: - group: cypress-${{ github.head_ref || github.run_id }} - cancel-in-progress: ${{ !github.head_ref }} - -env: - # Adjust APP_NAME if your repository name is different - APP_NAME: ${{ github.event.repository.name }} - CYPRESS_baseUrl: http://localhost:8081/index.php - CYPRESS_CACHE_FOLDER: ${{ github.workspace }}/Cypress - -jobs: - init: - runs-on: ubuntu-latest - outputs: - nodeVersion: ${{ steps.versions.outputs.nodeVersion }} - npmVersion: ${{ steps.versions.outputs.npmVersion }} - strategy: - matrix: - server-versions: ['master'] - - steps: - - name: Checkout server - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 - with: - persist-credentials: false - repository: nextcloud/server - ref: ${{ matrix.server-versions }} - submodules: true - - - name: Checkout viewer - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 - with: - persist-credentials: false - repository: nextcloud/viewer - ref: ${{ matrix.server-versions }} - path: apps/viewer - - - name: Checkout assistant - if: matrix.server-versions == 'main' - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 - with: - persist-credentials: false - repository: nextcloud/assistant - ref: main - path: apps/assistant - - - name: Checkout app - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 - with: - persist-credentials: false - path: apps/${{ env.APP_NAME }} - - - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 - id: versions - with: - fallbackNode: "^20" - fallbackNpm: "^10" - path: apps/${{ env.APP_NAME }} - - - name: Set up node ${{ steps.versions.outputs.nodeVersion }} - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 - with: - cache: 'npm' - node-version: ${{ steps.versions.outputs.nodeVersion }} - - - name: Set up npm ${{ steps.versions.outputs.npmVersion }} - run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' - - - name: Install node dependencies & build app - working-directory: apps/${{ env.APP_NAME }} - run: | - npm ci - TESTING=true npm run build --if-present - - - name: Install node dependencies & build assistant app - if: matrix.server-versions == 'main' - working-directory: apps/assistant - run: | - composer install --no-dev - npm ci - npm run build - - - name: Save context - uses: buildjet/cache/save@3e70d19e31d6a8030aeddf6ed8dbe601f94d09f4 # v4.0.2 - with: - key: cypress-context-${{ github.run_id }} - path: | - ./ - - cypress: - runs-on: ubuntu-latest - timeout-minutes: 30 - needs: init - - strategy: - fail-fast: false - matrix: - containers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] - php-versions: ['8.3'] - - name: runner ${{ matrix.containers }} - - services: - postgres: - image: ghcr.io/nextcloud/continuous-integration-postgres-16:latest # zizmor: ignore[unpinned-images] - ports: - - 4444:5432/tcp - env: - POSTGRES_USER: root - POSTGRES_PASSWORD: rootpassword - POSTGRES_DB: nextcloud - options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5 - - steps: - - name: Restore context - uses: buildjet/cache/restore@3e70d19e31d6a8030aeddf6ed8dbe601f94d09f4 # v4.0.2 - with: - fail-on-cache-miss: true - key: cypress-context-${{ github.run_id }} - path: | - ./ - - - name: Set up node ${{ needs.init.outputs.nodeVersion }} - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 - with: - cache: 'npm' - node-version: ${{ needs.init.outputs.nodeVersion }} - - - name: Set up npm ${{ needs.init.outputs.npmVersion }} - run: npm i -g 'npm@${{ needs.init.outputs.npmVersion }}' - - - name: Set up php ${{ matrix.php-versions }} - uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0 - with: - php-version: ${{ matrix.php-versions }} - extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, pgsql, pdo_pgsql - ini-values: - apc.enable_cli=on - coverage: none - - - name: Set up Nextcloud - env: - DB_PORT: 4444 - PHP_CLI_SERVER_WORKERS: 10 - run: | - mkdir data - echo '"\OC\Memcache\APCu","hashing_default_password"=>true];' > config/config.php - php occ maintenance:install --verbose --database=pgsql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin - php -f index.php - php -S 0.0.0.0:8081 & - export OC_PASS=1234561 - php occ user:add --password-from-env user1 - php occ user:add --password-from-env user2 - php occ app:enable viewer - php occ app:enable text - php occ app:enable assistant --force - php occ app:enable testing - php occ app:enable whiteboard --force - php occ app:list - php occ background:cron - php occ config:system:set session_keepalive --value=false --type=boolean - # Set offline_readonly_delay to 5 seconds to speed up tests that rely on it, like recover tests in sync.spec.js - php occ config:app:set --type integer --value 5 text offline_readonly_delay - curl -v http://localhost:8081/index.php/login - cat data/nextcloud.log - - - name: Run E2E cypress tests - run: | - cd 'apps/${{ env.APP_NAME }}' - npx wait-on $CYPRESS_baseUrl - npx cypress run --record false --config defaultCommandTimeout=10000,video=false - env: - # https://github.com/cypress-io/github-action/issues/124 - COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} - COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }} - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - npm_package_name: ${{ env.APP_NAME }} - SPLIT: ${{ strategy.job-total }} - SPLIT_INDEX: ${{ strategy.job-index }} - - - - name: Upload snapshots - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 - if: failure() - with: - name: snapshots_${{ matrix.containers }} - path: | - apps/${{ env.APP_NAME }}/cypress/screenshots/ - apps/${{ env.APP_NAME }}/cypress/snapshots/ - retention-days: 5 - - - name: Upload NC logs - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 - if: failure() - with: - name: nc_logs_${{ matrix.containers }}.log - path: data/nextcloud.log - retention-days: 5 - - summary: - runs-on: ubuntu-latest-low - needs: [init, cypress] - - if: always() - - name: cypress-summary - - steps: - - name: Summary status - run: if ${{ needs.init.result != 'success' || ( needs.cypress.result != 'success' && needs.cypress.result != 'skipped' ) }}; then exit 1; fi diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 1de225766f6..36a75f73d12 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -17,8 +17,8 @@ jobs: strategy: fail-fast: false matrix: - shardIndex: [1, 2, 3] - shardTotal: [3] + shardIndex: [1] + shardTotal: [1] steps: - name: Checkout app uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -52,7 +52,6 @@ jobs: CYPRESS_INSTALL_BINARY: 0 run: | npm ci - npm run build --if-present - name: Install Playwright Browsers run: npx playwright install chromium --only-shell diff --git a/appinfo/info.xml b/appinfo/info.xml index 6dc7cdd8b44..321e42da8b4 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -31,7 +31,7 @@ https://raw.githubusercontent.com/nextcloud/text/main/img/screenshots/screenshot2.png https://raw.githubusercontent.com/nextcloud/text/main/img/screenshots/screenshot3.gif - + OCA\Text\Cron\Cleanup diff --git a/cypress/e2e/propfind.spec.js b/cypress/e2e/propfind.spec.js deleted file mode 100644 index 9ef8a470cf4..00000000000 --- a/cypress/e2e/propfind.spec.js +++ /dev/null @@ -1,114 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { randUser } from '../utils/index.js' - -const user = randUser() - -// Retries fail because folders / files already exist. -describe('Text PROPFIND extension ', { retries: 0 }, function() { - const PROPERTY_WORKSPACE = 'nc:rich-workspace' - const PROPERTY_WORKSPACE_FILE = 'nc:rich-workspace-file' - const PROPERTY_WORKSPACE_FLAT = 'nc:rich-workspace-flat' - const PROPERTY_WORKSPACE_FILE_FLAT = 'nc:rich-workspace-file-flat' - - before(function() { - cy.createUser(user) - }) - - beforeEach(function() { - cy.login(user) - cy.deleteFile('/Readme.md') - cy.deleteFile('/workspace-flat') - cy.deleteFile('/workspace') - }) - - describe('with workspaces enabled', function() { - beforeEach(function() { - cy.configureText('workspace_enabled', 1) - }) - - it('always adds rich workspace property', function() { - const properties = [ - PROPERTY_WORKSPACE_FLAT, - PROPERTY_WORKSPACE_FILE_FLAT, - ] - cy.uploadFile('empty.md', 'text/markdown', '/Readme.md') - cy.visit('/apps/dashboard') - cy.propfindFolder('/', 0, properties).should( - 'have.property', - PROPERTY_WORKSPACE_FLAT, - '', - ) - cy.uploadFile('test.md', 'text/markdown', '/Readme.md') - cy.propfindFolder('/', 0, properties).should( - 'have.property', - PROPERTY_WORKSPACE_FLAT, - '## Hello world\n', - ) - cy.deleteFile('/Readme.md') - cy.propfindFolder('/', 0, properties).should( - 'have.property', - PROPERTY_WORKSPACE_FLAT, - '', - ) - }) - - it('never adds rich workspace property to nested folders for flat properties', function() { - const properties = [ - PROPERTY_WORKSPACE_FLAT, - PROPERTY_WORKSPACE_FILE_FLAT, - ] - cy.visit('/apps/dashboard') - cy.createFolder('/workspace-flat') - cy.propfindFolder('/', 1, properties) - .then((results) => results.pop()) - .should('have.property', PROPERTY_WORKSPACE_FLAT, '') - cy.uploadFile('test.md', 'text/markdown', '/workspace-flat/Readme.md') - cy.propfindFolder('/', 1, properties) - .then((results) => results.pop()) - .should('have.property', PROPERTY_WORKSPACE_FLAT, '') - }) - - // Android app relies on this to detect rich workspace availability in subfolders properly - it('adds rich workspace property to nested folders for the default properties', function() { - const properties = [PROPERTY_WORKSPACE, PROPERTY_WORKSPACE_FILE] - cy.createFolder('/workspace') - cy.visit('/apps/dashboard') - cy.propfindFolder('/', 1, properties) - .then((results) => results.pop()) - .should('have.property', PROPERTY_WORKSPACE, '') - cy.uploadFile('test.md', 'text/markdown', '/workspace/Readme.md') - cy.propfindFolder('/', 1, properties) - .then((results) => results.pop()) - .should('have.property', PROPERTY_WORKSPACE, '## Hello world\n') - }) - }) - - describe('with workspaces disabled', function() { - beforeEach(function() { - cy.configureText('workspace_enabled', 0) - }) - - it('does not return a rich workspace property', function() { - // FIXME: Ideally we do not need a page context for those tests at all - // For now the dashboard avoids that we have failing requests due to conflicts when updating the file - cy.visit('/apps/dashboard') - cy.propfindFolder('/', 1, [ - PROPERTY_WORKSPACE_FLAT, - PROPERTY_WORKSPACE_FILE_FLAT, - ]).should('not.have.property', PROPERTY_WORKSPACE_FLAT) - cy.uploadFile('test.md', 'text/markdown', '/Readme.md') - cy.propfindFolder('/', 1, [ - PROPERTY_WORKSPACE_FLAT, - PROPERTY_WORKSPACE_FILE_FLAT, - ]).should('not.have.property', PROPERTY_WORKSPACE_FLAT) - cy.createFolder('/without-workspace') - cy.propfindFolder('/', 1) - .then((results) => results.pop()) - .should('not.have.property', PROPERTY_WORKSPACE_FLAT) - }) - }) -}) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index b384730920b..69f4e67477c 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -237,74 +237,6 @@ Cypress.Commands.add('getFileContent', (path) => { .then((response) => response.data) }) -Cypress.Commands.add('propfindFolder', (path, depth = 0, properties = null) => { - const defaultProperties = ` - - ` - - const propsXml = properties - ? properties.map((p) => `<${p} />`).join('\n') - : defaultProperties - - const rootPath = `${url}/remote.php/webdav/` - const requestPath = path === '/' ? rootPath : `${rootPath}${path}` - - return axios - .request({ - method: 'PROPFIND', - url: requestPath, - headers: { - Depth: depth, - 'Content-Type': 'application/xml', - }, - data: ` - - - ${propsXml} - -`, - }) - .then((response) => { - const parser = new DOMParser() - const xmlDoc = parser.parseFromString(response.data, 'text/xml') - const responses = xmlDoc.querySelectorAll('d\\:response, response') - const results = Array.from(responses).map((resp) => { - const props = {} - const propStats = resp.querySelectorAll('d\\:propstat, propstat') - propStats.forEach((propStat) => { - const status - = propStat.querySelector('d\\:status, status')?.textContent - - // Skip properties with 404 status ( not found) - if (status?.includes('404')) { - return - } - - const propElements = resp.querySelectorAll('d\\:prop > *, prop > * ') - - propElements.forEach((prop) => { - const tagName = prop.localName - const namespace = prop.namespaceURI - - let key = tagName - if (namespace === 'http://nextcloud.org/ns') { - key = `nc:${tagName}` - } else if (namespace === 'http://owncloud.org/ns') { - key = `oc:${tagName}` - } - - props[key] = prop.textContent || '' - }) - }) - return props - }) - - return depth > 0 ? results : results[0] || {} - }) -}) - Cypress.Commands.add('reloadFileList', () => { cy.get('[title="Reload current directory"] button').click() return cy.get('button').contains('Reload content').click() diff --git a/package-lock.json b/package-lock.json index 09fff19199c..6def3c778e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -96,6 +96,7 @@ "@nextcloud/eslint-config": "^9.0.1", "@nextcloud/vite-config": "^2.5.4", "@playwright/test": "^1.62.1", + "@types/jsdom": "^30.0.0", "@types/markdown-it": "^14.1.2", "@types/markdown-it-footnote": "^3.0.4", "@vitejs/plugin-vue": "^6.0.8", @@ -5909,6 +5910,26 @@ "@types/sizzle": "*" } }, + "node_modules/@types/jsdom": { + "version": "30.0.0", + "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-30.0.0.tgz", + "integrity": "sha512-uAHGxujGE0cDaKGdK28zgDotFtNA7MKq5DXl8LrfdxdCI8VHcg15oJz+amHTChPNI5JpgEPQWc2xFdrw3em/nQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "@types/tough-cookie": "*", + "parse5": "^8.0.0", + "undici-types": "^8.9.0" + } + }, + "node_modules/@types/jsdom/node_modules/undici-types": { + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.10.0.tgz", + "integrity": "sha512-ibvdovq3nCFs8Msrd95BW+zUOq+aOVbT+wpHUoPWhztbHEoPc6oof51iFDB6Es8lTKvNvVW9jNSAB8dwrKTMGg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/jsesc": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/@types/jsesc/-/jsesc-2.5.1.tgz", @@ -6011,6 +6032,13 @@ "integrity": "sha512-zfZHU4tKffPCnZRe7pjv/eFKzTVHozKewFCKaCjZ4gFinKgJRz/t0bkZiMCXJxPhv/ZoeDGNOeRD09R0kQZ/nw==", "license": "MIT" }, + "node_modules/@types/tough-cookie": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz", + "integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/trusted-types": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", diff --git a/package.json b/package.json index a80b3af8e04..ea7cdaedfb3 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,7 @@ "@nextcloud/eslint-config": "^9.0.1", "@nextcloud/vite-config": "^2.5.4", "@playwright/test": "^1.62.1", + "@types/jsdom": "^30.0.0", "@types/markdown-it": "^14.1.2", "@types/markdown-it-footnote": "^3.0.4", "@vitejs/plugin-vue": "^6.0.8", diff --git a/playwright/e2e/autosave.spec.ts b/playwright/e2e/autosave.spec.ts deleted file mode 100644 index 46ed77deebf..00000000000 --- a/playwright/e2e/autosave.spec.ts +++ /dev/null @@ -1,88 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as offlineTest } from '../support/fixtures/offline.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, offlineTest, uploadFileTest) - -// As we switch on and off the network -// we cannot run tests in parallel. -test.describe.configure({ mode: 'serial' }) - -// Files were created 10 seconds ago so there's no throttling to begin with. -test.use({ mtime: Date.now() / 1000 - 10 }) - -test.beforeEach(async ({ open }) => { - await open() -}) - -test('saves after 1 second', async ({ editor }) => { - await expect(editor.el).toBeVisible() - await editor.typeHeading('Hello world') - await expect(editor.saveIndicator).toHaveAccessibleName(/Unsaved changes/) - await expect(editor.saveIndicator).not.toHaveAccessibleName(/Unsaved changes/) - // TODO: Why does this not work? await expect(await file.getContent()).toBe('## Hello world') -}) - -/* - * 1 second autosave debounce - * 10 seconds waiting for server to be ready again - * 1 second for the save request - */ -test('saves again within 12 seconds', async ({ editor }) => { - test.slow() - await expect(editor.el).toBeVisible() - await editor.typeHeading('Hello') - await expect(editor.saveIndicator).toHaveAccessibleName(/Unsaved changes/) - await expect(editor.saveIndicator).not.toHaveAccessibleName(/Unsaved changes/) - await editor.type(' again') - await expect(editor.saveIndicator).toHaveAccessibleName(/Unsaved changes/) - await expect(editor.saveIndicator).not.toHaveAccessibleName(/Unsaved changes/, { timeout: 12_000 }) -}) - -test('saves after being disconnected for 5 sec.', async ({ - editor, - setOffline, - setOnline, -}) => { - await expect(editor.el).toBeVisible() - await editor.typeHeading('Hello') - await expect(editor.saveIndicator).not.toHaveAccessibleName(/Unsaved changes/) - await editor.type(' again') - await expect(editor.saveIndicator).toHaveAccessibleName(/Unsaved changes/) - await setOffline() - await new Promise((resolve) => setTimeout(resolve, 5_000)) - await setOnline() - await expect(editor.saveIndicator).toHaveAccessibleName(/Unsaved changes/) - await expect(editor.saveIndicator).not.toHaveAccessibleName(/Unsaved changes/, { timeout: 10_000 }) -}) - -test('saves after being disconnected for 2 minutes.', async ({ - editor, - page, - setOffline, - setOnline, -}) => { - await page.clock.install() - await expect(editor.el).toBeVisible() - await editor.typeHeading('Hello') - await expect(editor.saveIndicator).toHaveAccessibleName(/Unsaved changes/) - await expect(editor.saveIndicator).not.toHaveAccessibleName(/Unsaved changes/) - await editor.type(' again') - await expect(editor.saveIndicator).toHaveAccessibleName(/Unsaved changes/) - await setOffline() - // Wait long enough for the server throttling to be over. - await new Promise((resolve) => setTimeout(resolve, 10_000)) - await page.clock.fastForward(110_000) - await setOnline() - await expect(editor.offlineState).not.toBeVisible() - await expect(editor.saveIndicator).toHaveAccessibleName(/Unsaved changes/) - // Be sure to trigger at least one autosave - await page.clock.fastForward(15_000) - await expect(editor.saveIndicator).not.toHaveAccessibleName(/Unsaved changes/) -}) diff --git a/playwright/e2e/change-mime-type.spec.ts b/playwright/e2e/change-mime-type.spec.ts deleted file mode 100644 index 23694282711..00000000000 --- a/playwright/e2e/change-mime-type.spec.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, uploadFileTest) - -test.beforeEach(async ({ open }) => { - await open() -}) - -test.describe('Changing mimetype from markdown to plaintext', () => { - test('resets the document session and indexed db', async ({ - editor, - file, - viewer, - }) => { - test.slow() - await editor.typeHeading('Hello world') - await viewer.close() - const plaintext = await file.move('test.txt') - await plaintext.open() - await expect(editor.content).toHaveText('## Hello world') - await expect(editor.getHeading()).not.toBeVisible() - }) -}) - -test.describe('Changing mimetype from plain to markdown', () => { - test.use({ fileName: 'empty.txt' }) - - test('resets the document session and indexed db', async ({ - editor, - file, - viewer, - }) => { - test.slow() - await editor.type('## Hello world') - await expect(editor.content).toHaveText('## Hello world') - await viewer.close() - const markdown = await file.move('test.md') - await markdown.open() - await expect(editor.getHeading({ name: 'Hello world' })).toBeVisible() - }) -}) diff --git a/playwright/e2e/comments.spec.ts b/playwright/e2e/comments.spec.ts deleted file mode 100644 index 74b37ca25f0..00000000000 --- a/playwright/e2e/comments.spec.ts +++ /dev/null @@ -1,152 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, uploadFileTest) - -test.describe('renders comments from Markdown', () => { - test.use({ - fileContent: 'The quick[^comment-1] brown fox.\n\n' - + '[^comment-1]:\n' - + ' - @[jane](mention://user/jane) *(2026-07-16T13:12Z)*\n' - + ' Comment by Jane\n', - }) - - test('shows reference from Markdown', async ({ editor, open }) => { - await open() - await expect(editor.getCommentReference('comment-1')).toBeVisible() - }) - - test('opens bubble with thread content on click', async ({ editor, open }) => { - await open() - await editor.getCommentReference('comment-1').click() - await expect(editor.commentBubble).toBeVisible() - await expect(editor.commentBubble).toContainText('Comment by Jane') - }) - - test('closes bubble when close button is clicked', async ({ editor, open }) => { - await open() - await editor.getCommentReference('comment-1').click() - await expect(editor.commentBubble).toBeVisible() - await editor.commentBubble.getByRole('button', { name: 'Close' }).click({ force: true }) - await expect(editor.commentBubble).not.toBeVisible() - }) -}) - -test('inserts comment via keyboard shortcut', async ({ editor, open }) => { - await open() - await editor.type('Some text') - await editor.press('ControlOrMeta+Alt+m') - await expect(editor.commentReferences.first()).toBeVisible() - await expect(editor.commentBubble).toBeVisible() -}) - -test('inserts comment via [?] input rule', async ({ editor, open }) => { - await open() - await editor.type('hello[?]') - await expect(editor.commentReferences.first()).toBeVisible() - await expect(editor.commentBubble).toBeVisible() -}) - -test('adds a reply to a comment', async ({ editor, open }) => { - await open() - await editor.type('Test[?]') - await expect(editor.commentBubble).toBeVisible() - - const composerInput = editor.commentBubble - .locator('.comment-bubble__composer-input [contenteditable]') - await composerInput.fill('My first reply') - await editor.commentBubble.getByRole('button', { name: 'Comment' }).click() - await expect(editor.commentBubble).toContainText('My first reply') -}) - -test('edits an existing comment', async ({ editor, open }) => { - await open() - await editor.type('Test[?]') - await expect(editor.commentBubble).toBeVisible() - - // Submit initial reply - const composerInput = editor.commentBubble - .locator('.comment-bubble__composer-input [contenteditable]') - await composerInput.fill('Original text') - await editor.commentBubble.getByRole('button', { name: 'Comment' }).click() - await expect(editor.commentBubble).toContainText('Original text') - - // Edit the reply - await editor.commentBubble.getByLabel('Actions', { exact: true }).click() - await editor.commentBubble.getByRole('menuitem', { name: 'Edit' }).click() - const editInput = editor.commentBubble - .locator('.comment-bubble__body-edit [contenteditable]') - await editInput.clear() - await editInput.fill('Updated text') - await editor.commentBubble.getByRole('button', { name: 'Save' }).click() - await expect(editor.commentBubble).toContainText('Updated text') - await expect(editor.commentBubble).not.toContainText('Original text') -}) - -test.describe('deletes a comment reply', () => { - test.use({ - fileContent: 'Test[^comment-1]\n\n' - + '[^comment-1]:\n' - + ' - @[jane](mention://user/jane) *(2026-07-16T13:12Z)*\n' - + ' First reply\n' - + ' - @[bob](mention://user/bob) *(2026-07-17T11:11Z)*\n' - + ' Second reply\n', - }) - - test('deletes one reply from a multi-reply thread', async ({ editor, open }) => { - await open() - await editor.getCommentReference('comment-1').click() - await expect(editor.commentBubble).toContainText('First reply') - await expect(editor.commentBubble).toContainText('Second reply') - - // Delete the first reply - await editor.commentBubble.getByLabel('Actions', { exact: true }).first().click() - await editor.commentBubble.getByRole('menuitem', { name: 'Delete' }).click() - - await expect(editor.commentBubble).not.toContainText('First reply') - await expect(editor.commentBubble).toContainText('Second reply') - - // Reference still in the editor (thread still has one reply) - await expect(editor.getCommentReference('comment-1')).toBeVisible() - }) -}) - -test.describe('deletes last comment reply', () => { - test.use({ - fileContent: 'Test[^comment-1]\n\n' - + '[^comment-1]:\n' - + ' - @[jane](mention://user/jane) *(2026-07-16T13:12Z)*\n' - + ' Only reply\n', - }) - - test('removes reference when last reply is deleted', async ({ editor, open }) => { - await open() - await editor.getCommentReference('comment-1').click() - await expect(editor.commentBubble).toContainText('Only reply') - - await editor.commentBubble.getByLabel('Actions', { exact: true }).click() - await editor.commentBubble.getByRole('menuitem', { name: 'Delete' }).click() - - // Bubble should close and reference should be gone - await expect(editor.commentBubble).not.toBeVisible() - await expect(editor.commentReferences.first()).not.toBeVisible() - }) -}) - -test('hides and shows comment references via annotations toggle', async ({ editor, open }) => { - await open() - await editor.type('Test[?]') - await expect(editor.commentReferences.first()).toBeVisible() - - await editor.clickMenu('Annotations', 'Hide annotations') - await expect(editor.commentReferences.first()).toBeHidden() - - await editor.clickMenu('Annotations', 'Show annotations') - await expect(editor.commentReferences.first()).toBeVisible() -}) diff --git a/playwright/e2e/conflict.spec.ts b/playwright/e2e/conflict.spec.ts deleted file mode 100644 index ac234c11fcc..00000000000 --- a/playwright/e2e/conflict.spec.ts +++ /dev/null @@ -1,359 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as offlineTest } from '../support/fixtures/offline.ts' -import { test as randomUserTest } from '../support/fixtures/random-user.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, offlineTest, randomUserTest, uploadFileTest) - -// As we switch on and off the network -// we cannot run tests in parallel. -test.describe.configure({ mode: 'serial' }) - -test.beforeEach(async ({ open }) => { - await open() -}) - -const resolutionVariants = [ - { - source: 'local', - buttonName: /Keep my local changes and overwrite the remote version/, - headingName: 'Hello world', - }, - { - source: 'server', - buttonName: /Discard my local changes and use the remote version/, - headingName: 'Good bye', - }, -] - -resolutionVariants.forEach(({ source, buttonName, headingName }) => { - test(`[conflict] manual resolution after typing while offline - resolve with ${source} version`, async ({ - container, - editor, - file, - reader, - setOffline, - setOnline, - user, - }) => { - await expect(editor.el).toBeVisible() - await setOffline() - await editor.typeHeading('Hello world') - await setOnline() - await user.uploadFile({ name: file.name, content: '## Good bye' }) - - // Verify both verisons are shown - await expect(editor.getHeading({ name: 'Good bye' })).toBeVisible({ - timeout: 10_000, - }) - await expect(reader.getHeading({ name: 'Hello world' })).toBeVisible() - - // Resolve conflict - await container.getButton({ name: buttonName }).click() - await expect(reader.el).not.toBeVisible() - await expect(editor.getHeading({ name: headingName })).toBeVisible() - }) -}) - -resolutionVariants.forEach(({ source, buttonName, headingName }) => { - test(`[conflict] manual resolution after typing while offline and reopening editor - resolve with ${source} version`, async ({ - close, - container, - editor, - file, - reader, - setOffline, - setOnline, - user, - }) => { - await expect(editor.el).toBeVisible() - await setOffline() - await editor.typeHeading('Hello world') - await close() - await setOnline() - await user.uploadFile({ name: file.name, content: '## Good bye' }) - await file.open() - - // Verify both verisons are shown - await expect(editor.getHeading({ name: 'Good bye' })).toBeVisible({ - timeout: 10_000, - }) - await expect(reader.getHeading({ name: 'Hello world' })).toBeVisible() - - // Resolve conflict - await container.getButton({ name: buttonName }).click() - await expect(reader.el).not.toBeVisible() - await expect(editor.getHeading({ name: headingName })).toBeVisible() - }) -}) - -resolutionVariants.forEach(({ source, buttonName, headingName }) => { - test(`[conflict] manual resolution after typing while online - resolve with ${source} version`, async ({ - container, - editor, - file, - page, - reader, - user, - }) => { - await expect(editor.el).toBeVisible() - const pushPromise = page.waitForRequest(/push/) - await editor.typeHeading('Hello world') - await pushPromise - await user.uploadFile({ name: file.name, content: '## Good bye' }) - - // Verify both verisons are shown - await expect(editor.getHeading({ name: 'Good bye' })).toBeVisible({ - timeout: 10_000, - }) - await expect(reader.getHeading({ name: 'Hello world' })).toBeVisible() - - // Resolve conflict - await container.getButton({ name: buttonName }).click() - await expect(reader.el).not.toBeVisible() - await expect(editor.getHeading({ name: headingName })).toBeVisible() - }) -}) - -test.describe('Plaintext conflict resolution', () => { - test.use({ fileName: 'empty.txt' }) - const plaintextResolutionVariants = [ - { - source: 'local', - buttonName: /Keep my local changes and overwrite the remote version/, - content: 'Hello world', - }, - { - source: 'server', - buttonName: /Discard my local changes and use the remote version/, - content: 'Good bye', - }, - ] - - plaintextResolutionVariants.forEach(({ source, buttonName, content }) => { - test(`[conflict, plaintext] manual resolution after typing while online - resolve with ${source} version`, async ({ - container, - editor, - file, - reader, - user, - }) => { - await expect(editor.el).toBeVisible() - await editor.type('Hello world') - await user.uploadFile({ name: file.name, content: 'Good bye' }) - - // Verify both verisons are shown - await expect(editor.content).toHaveText('Good bye', { timeout: 10_000 }) - await expect(reader.content).toHaveText('Hello world') - - // Resolve conflict - await container.getButton({ name: buttonName }).click() - await expect(reader.el).not.toBeVisible() - await expect(editor.content).toHaveText(content) - }) - }) -}) - -test('[conflict] automatic resolution if no unsaved changes', async ({ - container, - editor, - file, - page, - reader, - user, -}) => { - await expect(editor.el).toBeVisible() - await editor.typeHeading('Hello world') - const requestPromise = page.waitForRequest(/save/) - await editor.saveIndicator.click() - await requestPromise - await page.waitForTimeout(500) // More robust against 423 Locked - - await user.uploadFile({ name: file.name, content: '## Good bye' }) - - // Should show latest content, no conflict dialog - await expect(editor.getHeading({ name: 'Good bye' })).toBeVisible({ - timeout: 10_000, - }) - await expect(reader.content).not.toBeVisible() - await expect(container.getButton({ - name: /Keep my local changes and overwrite the remote version/, - })).not.toBeVisible() -}) - -test('readonly session hides conflict dialog', async ({ - container, - close, - editor, - file, - page, - setOffline, - setOnline, - user, -}) => { - await expect(editor.el).toBeVisible() - await setOffline() - const pushPromise = page.waitForRequest(/push/) - await editor.typeHeading('Hello world') - await pushPromise - await close() - - await setOnline() - await user.uploadFile({ name: file.name, content: '## Good bye' }) - - // Share file and open as guest (read-only) - const { token } = await file.shareLink() - await page.goto(`/s/${token}`) - - // Should show latest content, no conflict dialog - await expect(editor.getHeading({ name: 'Good bye' })).toBeVisible({ - timeout: 10_000, - }) - await expect(container.getButton({ - name: /Keep my local changes and overwrite the remote version/, - })).not.toBeVisible() -}) - -test('no conflict when uploading identical content with unsaved changes', async ({ - container, - editor, - file, - reader, - page, - user, -}) => { - await expect(editor.el).toBeVisible() - const pushPromise = page.waitForRequest(/push/) - await editor.typeHeading('Hello world') - await pushPromise - const requestPromise = page.waitForRequest(/save/) - await editor.saveIndicator.click() - await requestPromise - await editor.type('\nUnsaved change') - - await user.uploadFile({ name: file.name, content: '## Hello world' }) - - await expect(editor.getHeading({ name: 'Hello world' })).toBeVisible({ - timeout: 10_000, - }) - await expect(reader.content).not.toBeVisible() - await expect(container.getButton({ name: /Overwrite/ })).not.toBeVisible() - await expect(editor.getHeading({ name: 'Hello world' })).toBeVisible() -}) - -test('no conflict when uploading identical content with local unsaved changes', async ({ - container, - editor, - file, - reader, - page, - setOffline, - setOnline, - user, -}) => { - await expect(editor.el).toBeVisible() - const pushPromise = page.waitForRequest(/push/) - await editor.typeHeading('Hello world') - await pushPromise - const requestPromise = page.waitForRequest(/save/) - await editor.saveIndicator.click() - await requestPromise - await setOffline() - await editor.type('\nLocal change') - - await setOnline() - await user.uploadFile({ name: file.name, content: '## Hello world' }) - - await expect(editor.getHeading({ name: 'Hello world' })).toBeVisible({ - timeout: 10_000, - }) - await expect(reader.content).not.toBeVisible() - await expect(container.getButton({ name: /Overwrite/ })).not.toBeVisible() - await expect(editor.getHeading({ name: 'Hello world' })).toBeVisible() -}) - -test('no conflict when uploading identical content with local unsaved changes after reopening the editor', async ({ - close, - container, - editor, - file, - reader, - page, - setOffline, - setOnline, - user, -}) => { - await expect(editor.el).toBeVisible() - const pushPromise = page.waitForRequest(/push/) - await editor.typeHeading('Hello world') - await pushPromise - const requestPromise = page.waitForRequest(/save/) - await editor.saveIndicator.click() - await requestPromise - await setOffline() - await editor.type('\nLocal change') - await close() - - await setOnline() - await user.uploadFile({ name: file.name, content: '## Hello world' }) - await file.open() - - await expect(editor.getHeading({ name: 'Hello world' })).toBeVisible({ - timeout: 10_000, - }) - await expect(reader.content).not.toBeVisible() - await expect(container.getButton({ - name: /Keep my local changes and overwrite the remote version/, - })).not.toBeVisible() - await expect(editor.getHeading({ name: 'Hello world' })).toBeVisible() -}) - -test('conflict dialog is sticky when scrolling', async ({ - close, - container, - file, - editor, - page, - reader, - setOffline, - setOnline, - user, -}) => { - await expect(editor.el).toBeVisible() - const pushPromise = page.waitForRequest(/push/) - await editor.typeHeading('Long content\n') - await pushPromise - - for (let i = 1; i < 8; i++) { - await editor.typeHeading(`Section ${i}`) - await editor.type('\n\nLorem ipsum dolor sit amet.\n\n') - } - - await setOffline() - await editor.type('unsaved changes') - await close() - - await setOnline() - await user.uploadFile({ name: file.name, content: '## Different content' }) - await file.open() - - // Verify both verisons are shown - await expect(editor.getHeading({ name: 'Different content' })).toBeVisible({ - timeout: 10_000, - }) - await expect(reader.getHeading({ name: 'Long content' })).toBeVisible() - - // Scroll down - await reader.getHeading({ name: 'Section 7' }).scrollIntoViewIfNeeded() - - await expect(container.getButton({ - name: /Keep my local changes and overwrite the remote version/, - })).toBeVisible() - await expect(page.locator('.document-status')).toBeVisible() -}) diff --git a/playwright/e2e/design.spec.ts b/playwright/e2e/design.spec.ts deleted file mode 100644 index c0a06b7b620..00000000000 --- a/playwright/e2e/design.spec.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, uploadFileTest) - -test.beforeEach(async ({ open }) => { - await open() -}) - -test('Editor container grows vertically', async ({ editor }) => { - await expect(editor.menubar).toBeVisible() - await expect(editor.content).toBeVisible() - - const editorBox = (await editor.el.boundingBox())! - const menubarBox = (await editor.menubar.boundingBox())! - const contentBox = (await editor.content.boundingBox())! - const suggestionsContainerBox - = (await editor.suggestionsContainer.boundingBox())! - - const expectedContentHeight - = editorBox.height - menubarBox.height - suggestionsContainerBox.height - - // Allow up to 2px tolerance for borders etc. - expect(Math.abs(expectedContentHeight - contentBox.height)).toBeLessThan(2) -}) diff --git a/playwright/e2e/details.spec.ts b/playwright/e2e/details.spec.ts deleted file mode 100644 index 175eb50b678..00000000000 --- a/playwright/e2e/details.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, uploadFileTest) - -test('inserts and removes details', async ({ editor, open }) => { - await open() - await editor.type('content') - await editor.content.press('ControlOrMeta+a') - - await editor.clickMenu('Blocks', 'Details') - await expect(editor.details).toBeVisible() - - await editor.type('summary') - await expect(editor.details.locator('summary')).toContainText('summary') - await expect(editor.details.locator('.details-content')).toContainText('content') - - await editor.clickMenu('Blocks', 'Details') - await expect(editor.details).not.toBeVisible() - await expect(editor.content).toContainText('content') -}) diff --git a/playwright/e2e/editor-api-create-table.spec.ts b/playwright/e2e/editor-api-create-table.spec.ts deleted file mode 100644 index 4b063f4cb70..00000000000 --- a/playwright/e2e/editor-api-create-table.spec.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect } from '@playwright/test' -import { test } from '../support/fixtures/editor-api.ts' - -test.describe('createTable API', () => { - test.beforeEach(async ({ page }) => { - // Open the files app so we're somewhere with `window.OCA.Text` available - await page.goto('/apps/files') - - // Load the editor API bundle - const textRoot = await page.evaluate(() => (window as any).OC.appswebroots.text) - await page.addScriptTag({ - // @nextcloud/e2e-test-server mounts the app to `/apps-writable` - url: `${textRoot}/js/text-editor.mjs`, - type: 'module', - }) - }) - - test('renders table editor', async ({ page, createEditor, containerId }) => { - await createEditor({ - type: 'table', - content: '| A | B |\n|---|---|\n| 1 | 2 |', - readOnly: false, - }) - - await expect(page.locator(`#${containerId} table`)).toBeVisible() - await expect(page.locator(`#${containerId} th`).first()).toContainText('A') - await expect(page.locator(`#${containerId} td`).first()).toContainText('1') - }) - - test('allows editing when not readonly', async ({ - page, - createEditor, - containerId, - }) => { - await createEditor({ - type: 'table', - content: '| A |\n|---|\n| x |', - readOnly: false, - }) - - const cell = page.locator(`#${containerId} .ProseMirror td`).first() - await cell.click({ force: true }) - await page.waitForTimeout(100) - await cell.selectText() - await page.keyboard.type('edited') - - await expect(cell).toContainText('edited') - }) - test('prevents editing when readonly', async ({ - page, - createEditor, - containerId, - }) => { - await createEditor({ - type: 'table', - content: '| A |\n|---|---|\n| 1 |', - readOnly: true, - }) - - const editable = page.locator(`#${containerId} [contenteditable]`).first() - await expect(editable).toHaveAttribute('contenteditable', 'false') - }) -}) diff --git a/playwright/e2e/editor-api.spec.ts b/playwright/e2e/editor-api.spec.ts deleted file mode 100644 index 703c2a97aff..00000000000 --- a/playwright/e2e/editor-api.spec.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test } from '../support/fixtures/editor-api.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const fileTest = mergeTests(uploadFileTest, test) - -test.describe('editor API at window.OCA.Text - MarkdownContentEditor.vue without collaboration session', () => { - test.beforeEach(async ({ page }) => { - // Open the files app so we're somewhere with `window.OCA.Text` available - await page.goto('/apps/files') - - // Load the editor API bundle - const textRoot = await page.evaluate(() => (window as any).OC.appswebroots.text) - await page.addScriptTag({ - // @nextcloud/e2e-test-server mounts the app to `/apps-writable` - url: `${textRoot}/js/text-editor.mjs`, - type: 'module', - }) - }) - - test('opens editor in write mode with predefined content', async ({ - page, - createEditor, - containerId, - }) => { - await createEditor({ - type: 'editor', - content: '# heading\n', - }) - - await expect(page.locator(`#${containerId} h1`)).toHaveText('#heading') - - const content = page.locator(`#${containerId} .ProseMirror`) - await content.click() - await page.keyboard.type('More text.') - await expect(content).toContainText('#headingMore text.') - }) - - test('opens editor readonly with predefined content', async ({ - page, - createEditor, - containerId, - }) => { - await createEditor({ - type: 'editor', - content: '# heading\n', - readOnly: true, - }) - - await expect(page.locator(`#${containerId} h1`)).toHaveText('#heading') - const content = page.locator(`#${containerId} .ProseMirror`) - await expect(content).toHaveAttribute('contenteditable', 'false') - }) -}) - -fileTest.describe( - 'editor API at window.OCA.Text - CollaborativeEditor.vue with collaboration session', - () => { - fileTest.use({ fileContent: 'some content\n' }) - - fileTest.beforeEach(async ({ page }) => { - // Open the files app so we're somewhere with `window.OCA.Text` available - await page.goto('/apps/files') - - // Load the editor API bundle - const textRoot = await page.evaluate(() => (window as any).OC.appswebroots.text) - await page.addScriptTag({ - url: `${textRoot}/js/text-editor.mjs`, - type: 'module', - }) - }) - - fileTest( - 'opens editor with session for existing file', - async ({ file, page, createEditor, containerId }) => { - await createEditor({ - type: 'editor', - fileId: file.id, - readOnly: true, - }) - - await expect(page.locator(`#${containerId}`)).toContainText('some content') - - const content = page.locator(`#${containerId} .ProseMirror`) - await content.click() - await page.keyboard.type('More text.') - await expect(content).toContainText('More text.') - }, - ) - }, -) diff --git a/playwright/e2e/folder-description/create.spec.ts b/playwright/e2e/folder-description/create.spec.ts deleted file mode 100644 index bb88e057a87..00000000000 --- a/playwright/e2e/folder-description/create.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../../support/fixtures/editor.ts' -import { test as randomUserTest } from '../../support/fixtures/random-user.ts' - -const test = mergeTests(editorTest, randomUserTest) - -test('from new menu', async ({ page, editor }) => { - await page.goto('/apps/files') - await page.getByRole('button', { name: 'New' }).click() - await page.getByRole('menuitem', { name: 'Add folder description' }).click() - await editor.content.click() - await editor.typeHeading('Hello world') - await expect(editor.getHeading({ name: 'Hello world' })).toBeVisible() - await expect(page.locator('#rich-workspace .text-editor .text-editor__wrapper')).toBeVisible() - await expect(page - .locator('[data-cy-files-list-row-name="Readme.md"]') - .getByLabel('Actions')).toBeVisible() -}) diff --git a/playwright/e2e/folder-description/navigate.spec.ts b/playwright/e2e/folder-description/navigate.spec.ts deleted file mode 100644 index fde87aca36b..00000000000 --- a/playwright/e2e/folder-description/navigate.spec.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../../support/fixtures/editor.ts' -import { test as folderDescriptionTest } from '../../support/fixtures/folder-description.ts' -import { createFolder } from '../../support/fixtures/Node.ts' - -const test = mergeTests(editorTest, folderDescriptionTest) - -test.use({ - fileContent: '# Folder description', -}) - -test('Shows Readme.md', async ({ open, editor }) => { - await open() - await expect(editor.getHeading({ name: 'Folder description' })).toBeVisible() -}) - -test.describe('Scroll reset on blur', () => { - test.use({ - fileContent: - '# Title\n\n' + Array(30).fill('A paragraph of text.').join('\n\n'), - }) - - test('Scrolls back to top when focus is lost', async ({ - open, - page, - editor, - }) => { - await open() - await editor.el.click() - const heading = editor.getHeading({ name: 'Title' }) - await expect(page.locator('#rich-workspace')).toHaveClass(/focus/) - await expect(heading).toBeInViewport() - - // Scroll down withhin the content wrapper - await page - .locator('#rich-workspace .editor__content-wrapper') - .evaluate((el) => { - el.scrollTop = 400 - }) - await expect(heading).not.toBeInViewport() - - // Blur by clicking outside the workspace - await page - .getByRole('navigation', { name: 'Current directory path' }) - .click() - await expect(page.locator('#rich-workspace')).not.toHaveClass(/focus/) - await expect(heading).toBeInViewport() - }) -}) - -test('Hides in a different folder', async ({ editor, open, page, user }) => { - await createFolder({ name: 'Other folder', owner: user }) - await open() - await page.getByRole('button', { name: 'Other folder' }).click() - await expect(editor.getHeading({ name: 'Folder description' })).not.toBeVisible() -}) - -test('Hides in a different view', async ({ editor, open, page }) => { - await open() - await page.getByRole('link', { name: 'Recent' }).click() - await expect(editor.getHeading({ name: 'Folder description' })).not.toBeVisible() -}) diff --git a/playwright/e2e/footnotes.spec.ts b/playwright/e2e/footnotes.spec.ts deleted file mode 100644 index cfbe9d07113..00000000000 --- a/playwright/e2e/footnotes.spec.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, uploadFileTest) - -test.describe('renders footnotes', () => { - test.use({ - fileContent: 'Foo[^bar] baz\n\n[^bar]: footnote\n', - }) - - test('shows reference and footnote from Markdown', async ({ editor, open }) => { - await open() - await expect(editor.getFootnoteReference('bar')).toBeVisible() - await expect(editor.getFootnoteReference('bar').locator('a')).toHaveText('1') - await expect(editor.getFootnote('bar')).toContainText('footnote') - }) -}) - -test('inserts footnote via keyboard shortcut', async ({ editor, open }) => { - await open() - await editor.type('Some text') - await editor.press('ControlOrMeta+Shift+F') - await expect(editor.getFootnoteReference('1')).toBeVisible() - await expect(editor.getFootnote('1')).toBeVisible() - - await editor.type('footnote') - await expect(editor.getFootnote('1')).toContainText('footnote') -}) - -test('inserts footnote via [^] input rule', async ({ editor, open }) => { - await open() - await editor.type('hello[^]') - await expect(editor.getFootnoteReference('1')).toBeVisible() - await expect(editor.getFootnote('1')).toBeVisible() -}) diff --git a/playwright/e2e/format-text.spec.ts b/playwright/e2e/format-text.spec.ts deleted file mode 100644 index 5997c3275cb..00000000000 --- a/playwright/e2e/format-text.spec.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as folderDescriptionTest } from '../support/fixtures/folder-description.ts' -import { test as sharedFileTest } from '../support/fixtures/shared-file.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const fileTest = mergeTests(editorTest, uploadFileTest) -const shareTest = mergeTests(editorTest, sharedFileTest) -const descriptionTest = mergeTests(editorTest, folderDescriptionTest) - -new Map([ - ['Own file', fileTest], - ['Shared file', shareTest], - ['Folder description', descriptionTest], -]).forEach((test, name) => { - test.describe(name, () => { - test('formats text', async ({ editor, open }) => { - await open() - const buttons = { - Bold: 'strong', - Italic: 'em', - Underline: 'u', - Strikethrough: 's', - Highlight: 'mark', - } - await editor.type('Format me') - for (const [button] of Object.entries(buttons)) { - await expect(editor.getMenu(button)).not.toHaveClass('active') - } - await editor.content.press('Control+a') - for (const [button, tag] of Object.entries(buttons)) { - await editor.getMenu(button).click() - await expect(editor.el.locator(tag)).toContainText('Format me') - await editor.getMenu(button).click() - await expect(editor.el.locator(tag)).not.toBeVisible() - } - }) - }) -}) diff --git a/playwright/e2e/history.spec.ts b/playwright/e2e/history.spec.ts deleted file mode 100644 index d53dec35948..00000000000 --- a/playwright/e2e/history.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, uploadFileTest) - -test.beforeEach(async ({ open }) => { - await open() -}) - -test.describe('Undo manager', () => { - test('Can undo first action in empty document', async ({ editor }) => { - await editor.type('a') - await expect(editor.content).toContainText('a') - - const undoButton = editor.getMenu('Undo') - await expect(undoButton).not.toBeDisabled() - await undoButton.click() - - await expect(editor.content).not.toContainText('a') - }) -}) diff --git a/playwright/e2e/ime-input.spec.ts b/playwright/e2e/ime-input.spec.ts deleted file mode 100644 index f8b0f2c2976..00000000000 --- a/playwright/e2e/ime-input.spec.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -// Ideas taken from https://github.com/microsoft/playwright/issues/5777 and https://github.com/slab/quill/commit/0ea789f95fc4956287b3995f9495aafa367d4190 - -import type { Locator } from '@playwright/test' - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, uploadFileTest) - -test.beforeEach(async ({ open }) => { - await open() -}) - -let composingData = '' -async function withKeyboardEvents( - el: Locator, - key: string, - callback: () => Promise, -) { - composingData += key - await el.dispatchEvent('keydown', { key }) - await callback() - await el.dispatchEvent('keyup', { key }) -} - -test('Input Chinese character via IME at beginning of paragraph works', async ({ - browserName, - editor, - page, -}) => { - test.skip( - browserName !== 'chromium', - 'IME testing is currently only implemented in Chromium API', - ) - - // Get developer tools API - const client = await page.context().newCDPSession(page) - - await editor.content.focus() - - await withKeyboardEvents(editor.content, 'w', async () => { - client.send('Input.imeSetComposition', { - selectionStart: composingData.length, - selectionEnd: composingData.length, - text: 'w', - }) - }) - await withKeyboardEvents(editor.content, 'o', async () => { - client.send('Input.imeSetComposition', { - selectionStart: composingData.length, - selectionEnd: composingData.length, - text: 'o', - }) - }) - await withKeyboardEvents(editor.content, 'Space', async () => { - client.send('Input.insertText', { - text: '我', - }) - }) - - await expect(editor.content).toHaveText('我') -}) diff --git a/playwright/e2e/indexed-db.spec.ts b/playwright/e2e/indexed-db.spec.ts deleted file mode 100644 index 51e8ea07807..00000000000 --- a/playwright/e2e/indexed-db.spec.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as offlineTest } from '../support/fixtures/offline.ts' -import { test as randomUserTest } from '../support/fixtures/random-user.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, offlineTest, randomUserTest, uploadFileTest) - -// As we switch on and off the network -// we cannot run tests in parallel. -test.describe.configure({ mode: 'serial' }) - -test.beforeEach(async ({ open }) => { - await open() -}) - -test('recovering from indexed db', async ({ - close, - editor, - file, - page, - setOffline, - setOnline, -}) => { - await expect(editor.el).toBeVisible() - await setOffline() - await editor.typeHeading('Hello world') - await close() - await setOnline() - const pushWithSteps = page.waitForRequest( - (request) => { - if (!request.url().includes('push')) { - return false - } - const data = request.postDataJSON() - return data.steps.length > 0 - }, - { timeout: 10_000 }, - ) - await file.open() - await expect(editor.getHeading({ name: 'Hello world' })).toBeVisible() - await expect(editor.offlineState).not.toBeVisible() - await pushWithSteps - await expect(editor.saveIndicator).not.toHaveAttribute( - 'title', - /Unsaved changes/, - ) - await expect - .poll(() => file.getContent(), { timeout: 10_000 }) - .toBe('## Hello world') -}) diff --git a/playwright/e2e/input-rules.spec.ts b/playwright/e2e/input-rules.spec.ts deleted file mode 100644 index 682fb39559c..00000000000 --- a/playwright/e2e/input-rules.spec.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, uploadFileTest) - -test('applies code mark input rule with preceding character (#5483)', async ({ - editor, - open, -}) => { - await open() - await editor.type('hello inline (`code`)') - await expect(editor.el.locator('code')).toHaveText('code') - await expect(editor.el.locator('p').first()).toHaveText('hello inline (code)') -}) - -test('applies link mark input rule with dot in text (#7872)', async ({ - editor, - open, -}) => { - await open() - await editor.type('[example.org](https://example.org)') - await expect(editor.el.locator('a').first()).toHaveText('example.org') - await expect(editor.el.locator('a').first()).toHaveAttribute( - 'href', - 'https://example.org', - ) -}) - -test('code bloc', async ({ - editor, - open, -}) => { - await open() - await editor.type('```') - await editor.press('Enter') - await editor.type('code') - await expect(editor.el.locator('code')).toHaveText('code') -}) diff --git a/playwright/e2e/mobile.spec.ts b/playwright/e2e/mobile.spec.ts deleted file mode 100644 index c64d4114bb1..00000000000 --- a/playwright/e2e/mobile.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { devices, expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, uploadFileTest) - -test.use({ - ...devices['Moto G4'], -}) - -test.beforeEach(async ({ open }) => { - await open() -}) - -test('Formatting help', async ({ editor }) => { - await editor.clickMenu('Remain', 'Formatting help') - await expect(editor.formattingHelp).toBeVisible() - await editor.formattingHelp.getByLabel('Close').click() - await expect(editor.formattingHelp).not.toBeVisible() -}) diff --git a/playwright/e2e/offline.spec.ts b/playwright/e2e/offline.spec.ts deleted file mode 100644 index c8ccbe33981..00000000000 --- a/playwright/e2e/offline.spec.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as offlineTest } from '../support/fixtures/offline.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, offlineTest, uploadFileTest) - -// As we switch on and off the network -// we cannot run tests in parallel. -test.describe.configure({ mode: 'serial' }) - -test.beforeEach(async ({ open }) => { - await open() -}) - -test('Offline state indicator', async ({ editor, setOffline }) => { - await expect(editor.sessionList).toBeVisible() - await expect(editor.offlineState).not.toBeVisible() - - await setOffline() - - await expect(editor.sessionList).not.toBeVisible() - await expect(editor.offlineState).toBeVisible() -}) - -test('Disabled upload and link file when offline', async ({ - editor, - setOffline, -}) => { - const linkToFile = editor.getMenuItem('Link to file or folder') - await editor.withOpenMenu('Insert link', () => expect(linkToFile).toBeEnabled()) - await expect(editor.getMenu('Insert attachment')).toBeEnabled() - - await setOffline() - - await editor.withOpenMenu('Insert link', () => expect(linkToFile).toBeDisabled()) - await expect(editor.getMenu('Insert attachment')).toBeDisabled() -}) - -test('typing offline and coming back online', async ({ - editor, - setOffline, - setOnline, -}) => { - await expect(editor.el).toBeVisible() - await setOffline() - await editor.typeHeading('Hello world') - await setOnline() - await expect(editor.offlineState).not.toBeVisible() - await expect(editor.saveIndicator).toHaveAccessibleName(/Unsaved changes/) -}) diff --git a/playwright/e2e/print.spec.ts b/playwright/e2e/print.spec.ts deleted file mode 100644 index 061a3852d0a..00000000000 --- a/playwright/e2e/print.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { hostname } from 'os' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { loadFixture } from '../support/fixtures/loadFixture.ts' -import { test as sharedFileTest } from '../support/fixtures/shared-file.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const fileTest = mergeTests(editorTest, uploadFileTest) -const shareTest = mergeTests(editorTest, sharedFileTest) -const host = process.env.CI ? 'ci' : hostname() - -new Map([ - [`Own file on ${host}`, fileTest], - [`Shared file on ${host}`, shareTest], -]).forEach((test, name) => { - test.use({ fileContent: loadFixture('print.md') }) - test(name, async ({ open, page }) => { - await open() - await page.emulateMedia({ media: 'print' }) - await expect(page).toHaveScreenshot({ fullPage: true }) - }) -}) diff --git a/playwright/e2e/propfind-a.spec.ts b/playwright/e2e/propfind-a.spec.ts new file mode 100644 index 00000000000..da27d49ba20 --- /dev/null +++ b/playwright/e2e/propfind-a.spec.ts @@ -0,0 +1,107 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { expect } from '@playwright/test' +import { createFolder, uploadFile } from '../support/fixtures/Node.ts' +import { test } from '../support/fixtures/random-user.ts' +import { setTextSetting } from '../support/fixtures/settings.ts' +import { + deleteWebDAVResource, + PROPERTY_WORKSPACE, + PROPERTY_WORKSPACE_FILE, + PROPERTY_WORKSPACE_FILE_FLAT, + PROPERTY_WORKSPACE_FLAT, + propfindFolder, +} from '../support/fixtures/webdav.ts' + +test.describe('Text PROPFIND extension', () => { + test.describe('with workspaces enabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 1) + }) + + test('always adds rich workspace property', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await user.uploadFile({ name: 'Readme.md', content: '' }) + + const [root1] = await propfindFolder(user, '/', 0, properties) + expect(root1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + for (const n of [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]) { + const content = `## Hello world ${n}\n` + // await deleteWebDAVResource(user, '/Readme.md') + await user.uploadFile({ name: 'Readme.md', content }) + await new Promise((resolve) => setTimeout(resolve, 100)) + const [first] = await propfindFolder(user, '/', 0, properties) + expect(first).toHaveProperty(PROPERTY_WORKSPACE_FLAT, content) + } + + await deleteWebDAVResource(user, '/Readme.md') + const [root3] = await propfindFolder(user, '/', 0, properties) + expect(root3).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + test('never adds rich workspace property to nested folders for flat properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace-flat', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + await uploadFile({ name: 'workspace-flat/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + // Android app relies on this to detect rich workspace availability in subfolders properly + test('adds rich workspace property to nested folders for the default properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE, PROPERTY_WORKSPACE_FILE] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE, '') + + await uploadFile({ name: 'workspace/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE, '## Hello world\n') + }) + }) + + test.describe('with workspaces disabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 0) + }) + + test('does not return a rich workspace property', async ({ page, user }) => { + await page.goto('/apps/dashboard') + + const results1 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results1) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await user.uploadFile({ name: 'Readme.md', content: '## Hello world\n' }) + const results2 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results2) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await createFolder({ name: 'without-workspace', owner: user }) + const results3 = await propfindFolder(user, '/', 1) + const folder = results3.find((r) => r['d:href']?.endsWith('/without-workspace/')) + expect(folder).not.toHaveProperty(PROPERTY_WORKSPACE) + }) + }) +}) diff --git a/playwright/e2e/propfind-b.spec.ts b/playwright/e2e/propfind-b.spec.ts new file mode 100644 index 00000000000..da27d49ba20 --- /dev/null +++ b/playwright/e2e/propfind-b.spec.ts @@ -0,0 +1,107 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { expect } from '@playwright/test' +import { createFolder, uploadFile } from '../support/fixtures/Node.ts' +import { test } from '../support/fixtures/random-user.ts' +import { setTextSetting } from '../support/fixtures/settings.ts' +import { + deleteWebDAVResource, + PROPERTY_WORKSPACE, + PROPERTY_WORKSPACE_FILE, + PROPERTY_WORKSPACE_FILE_FLAT, + PROPERTY_WORKSPACE_FLAT, + propfindFolder, +} from '../support/fixtures/webdav.ts' + +test.describe('Text PROPFIND extension', () => { + test.describe('with workspaces enabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 1) + }) + + test('always adds rich workspace property', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await user.uploadFile({ name: 'Readme.md', content: '' }) + + const [root1] = await propfindFolder(user, '/', 0, properties) + expect(root1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + for (const n of [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]) { + const content = `## Hello world ${n}\n` + // await deleteWebDAVResource(user, '/Readme.md') + await user.uploadFile({ name: 'Readme.md', content }) + await new Promise((resolve) => setTimeout(resolve, 100)) + const [first] = await propfindFolder(user, '/', 0, properties) + expect(first).toHaveProperty(PROPERTY_WORKSPACE_FLAT, content) + } + + await deleteWebDAVResource(user, '/Readme.md') + const [root3] = await propfindFolder(user, '/', 0, properties) + expect(root3).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + test('never adds rich workspace property to nested folders for flat properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace-flat', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + await uploadFile({ name: 'workspace-flat/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + // Android app relies on this to detect rich workspace availability in subfolders properly + test('adds rich workspace property to nested folders for the default properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE, PROPERTY_WORKSPACE_FILE] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE, '') + + await uploadFile({ name: 'workspace/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE, '## Hello world\n') + }) + }) + + test.describe('with workspaces disabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 0) + }) + + test('does not return a rich workspace property', async ({ page, user }) => { + await page.goto('/apps/dashboard') + + const results1 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results1) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await user.uploadFile({ name: 'Readme.md', content: '## Hello world\n' }) + const results2 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results2) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await createFolder({ name: 'without-workspace', owner: user }) + const results3 = await propfindFolder(user, '/', 1) + const folder = results3.find((r) => r['d:href']?.endsWith('/without-workspace/')) + expect(folder).not.toHaveProperty(PROPERTY_WORKSPACE) + }) + }) +}) diff --git a/playwright/e2e/propfind-c.spec.ts b/playwright/e2e/propfind-c.spec.ts new file mode 100644 index 00000000000..da27d49ba20 --- /dev/null +++ b/playwright/e2e/propfind-c.spec.ts @@ -0,0 +1,107 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { expect } from '@playwright/test' +import { createFolder, uploadFile } from '../support/fixtures/Node.ts' +import { test } from '../support/fixtures/random-user.ts' +import { setTextSetting } from '../support/fixtures/settings.ts' +import { + deleteWebDAVResource, + PROPERTY_WORKSPACE, + PROPERTY_WORKSPACE_FILE, + PROPERTY_WORKSPACE_FILE_FLAT, + PROPERTY_WORKSPACE_FLAT, + propfindFolder, +} from '../support/fixtures/webdav.ts' + +test.describe('Text PROPFIND extension', () => { + test.describe('with workspaces enabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 1) + }) + + test('always adds rich workspace property', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await user.uploadFile({ name: 'Readme.md', content: '' }) + + const [root1] = await propfindFolder(user, '/', 0, properties) + expect(root1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + for (const n of [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]) { + const content = `## Hello world ${n}\n` + // await deleteWebDAVResource(user, '/Readme.md') + await user.uploadFile({ name: 'Readme.md', content }) + await new Promise((resolve) => setTimeout(resolve, 100)) + const [first] = await propfindFolder(user, '/', 0, properties) + expect(first).toHaveProperty(PROPERTY_WORKSPACE_FLAT, content) + } + + await deleteWebDAVResource(user, '/Readme.md') + const [root3] = await propfindFolder(user, '/', 0, properties) + expect(root3).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + test('never adds rich workspace property to nested folders for flat properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace-flat', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + await uploadFile({ name: 'workspace-flat/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + // Android app relies on this to detect rich workspace availability in subfolders properly + test('adds rich workspace property to nested folders for the default properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE, PROPERTY_WORKSPACE_FILE] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE, '') + + await uploadFile({ name: 'workspace/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE, '## Hello world\n') + }) + }) + + test.describe('with workspaces disabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 0) + }) + + test('does not return a rich workspace property', async ({ page, user }) => { + await page.goto('/apps/dashboard') + + const results1 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results1) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await user.uploadFile({ name: 'Readme.md', content: '## Hello world\n' }) + const results2 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results2) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await createFolder({ name: 'without-workspace', owner: user }) + const results3 = await propfindFolder(user, '/', 1) + const folder = results3.find((r) => r['d:href']?.endsWith('/without-workspace/')) + expect(folder).not.toHaveProperty(PROPERTY_WORKSPACE) + }) + }) +}) diff --git a/playwright/e2e/propfind-d.spec.ts b/playwright/e2e/propfind-d.spec.ts new file mode 100644 index 00000000000..d98b09eec76 --- /dev/null +++ b/playwright/e2e/propfind-d.spec.ts @@ -0,0 +1,106 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { expect } from '@playwright/test' +import { createFolder, uploadFile } from '../support/fixtures/Node.ts' +import { test } from '../support/fixtures/random-user.ts' +import { setTextSetting } from '../support/fixtures/settings.ts' +import { + deleteWebDAVResource, + PROPERTY_WORKSPACE, + PROPERTY_WORKSPACE_FILE, + PROPERTY_WORKSPACE_FILE_FLAT, + PROPERTY_WORKSPACE_FLAT, + propfindFolder, +} from '../support/fixtures/webdav.ts' + +test.describe('Text PROPFIND extension', () => { + test.describe('with workspaces enabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 1) + }) + + test('always adds rich workspace property', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await user.uploadFile({ name: 'Readme.md', content: '' }) + + const [root1] = await propfindFolder(user, '/', 0, properties) + expect(root1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + for (const n of [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]) { + const content = `## Hello world ${n}\n` + // await deleteWebDAVResource(user, '/Readme.md') + await user.uploadFile({ name: 'Readme.md', content }) + const [first] = await propfindFolder(user, '/', 0, properties) + expect(first).toHaveProperty(PROPERTY_WORKSPACE_FLAT, content) + } + + await deleteWebDAVResource(user, '/Readme.md') + const [root3] = await propfindFolder(user, '/', 0, properties) + expect(root3).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + test('never adds rich workspace property to nested folders for flat properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace-flat', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + await uploadFile({ name: 'workspace-flat/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + // Android app relies on this to detect rich workspace availability in subfolders properly + test('adds rich workspace property to nested folders for the default properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE, PROPERTY_WORKSPACE_FILE] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE, '') + + await uploadFile({ name: 'workspace/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE, '## Hello world\n') + }) + }) + + test.describe('with workspaces disabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 0) + }) + + test('does not return a rich workspace property', async ({ page, user }) => { + await page.goto('/apps/dashboard') + + const results1 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results1) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await user.uploadFile({ name: 'Readme.md', content: '## Hello world\n' }) + const results2 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results2) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await createFolder({ name: 'without-workspace', owner: user }) + const results3 = await propfindFolder(user, '/', 1) + const folder = results3.find((r) => r['d:href']?.endsWith('/without-workspace/')) + expect(folder).not.toHaveProperty(PROPERTY_WORKSPACE) + }) + }) +}) diff --git a/playwright/e2e/propfind-e.spec.ts b/playwright/e2e/propfind-e.spec.ts new file mode 100644 index 00000000000..d98b09eec76 --- /dev/null +++ b/playwright/e2e/propfind-e.spec.ts @@ -0,0 +1,106 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { expect } from '@playwright/test' +import { createFolder, uploadFile } from '../support/fixtures/Node.ts' +import { test } from '../support/fixtures/random-user.ts' +import { setTextSetting } from '../support/fixtures/settings.ts' +import { + deleteWebDAVResource, + PROPERTY_WORKSPACE, + PROPERTY_WORKSPACE_FILE, + PROPERTY_WORKSPACE_FILE_FLAT, + PROPERTY_WORKSPACE_FLAT, + propfindFolder, +} from '../support/fixtures/webdav.ts' + +test.describe('Text PROPFIND extension', () => { + test.describe('with workspaces enabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 1) + }) + + test('always adds rich workspace property', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await user.uploadFile({ name: 'Readme.md', content: '' }) + + const [root1] = await propfindFolder(user, '/', 0, properties) + expect(root1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + for (const n of [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]) { + const content = `## Hello world ${n}\n` + // await deleteWebDAVResource(user, '/Readme.md') + await user.uploadFile({ name: 'Readme.md', content }) + const [first] = await propfindFolder(user, '/', 0, properties) + expect(first).toHaveProperty(PROPERTY_WORKSPACE_FLAT, content) + } + + await deleteWebDAVResource(user, '/Readme.md') + const [root3] = await propfindFolder(user, '/', 0, properties) + expect(root3).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + test('never adds rich workspace property to nested folders for flat properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace-flat', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + await uploadFile({ name: 'workspace-flat/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + // Android app relies on this to detect rich workspace availability in subfolders properly + test('adds rich workspace property to nested folders for the default properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE, PROPERTY_WORKSPACE_FILE] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE, '') + + await uploadFile({ name: 'workspace/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE, '## Hello world\n') + }) + }) + + test.describe('with workspaces disabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 0) + }) + + test('does not return a rich workspace property', async ({ page, user }) => { + await page.goto('/apps/dashboard') + + const results1 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results1) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await user.uploadFile({ name: 'Readme.md', content: '## Hello world\n' }) + const results2 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results2) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await createFolder({ name: 'without-workspace', owner: user }) + const results3 = await propfindFolder(user, '/', 1) + const folder = results3.find((r) => r['d:href']?.endsWith('/without-workspace/')) + expect(folder).not.toHaveProperty(PROPERTY_WORKSPACE) + }) + }) +}) diff --git a/playwright/e2e/propfind-f.spec.ts b/playwright/e2e/propfind-f.spec.ts new file mode 100644 index 00000000000..d98b09eec76 --- /dev/null +++ b/playwright/e2e/propfind-f.spec.ts @@ -0,0 +1,106 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { expect } from '@playwright/test' +import { createFolder, uploadFile } from '../support/fixtures/Node.ts' +import { test } from '../support/fixtures/random-user.ts' +import { setTextSetting } from '../support/fixtures/settings.ts' +import { + deleteWebDAVResource, + PROPERTY_WORKSPACE, + PROPERTY_WORKSPACE_FILE, + PROPERTY_WORKSPACE_FILE_FLAT, + PROPERTY_WORKSPACE_FLAT, + propfindFolder, +} from '../support/fixtures/webdav.ts' + +test.describe('Text PROPFIND extension', () => { + test.describe('with workspaces enabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 1) + }) + + test('always adds rich workspace property', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await user.uploadFile({ name: 'Readme.md', content: '' }) + + const [root1] = await propfindFolder(user, '/', 0, properties) + expect(root1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + for (const n of [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]) { + const content = `## Hello world ${n}\n` + // await deleteWebDAVResource(user, '/Readme.md') + await user.uploadFile({ name: 'Readme.md', content }) + const [first] = await propfindFolder(user, '/', 0, properties) + expect(first).toHaveProperty(PROPERTY_WORKSPACE_FLAT, content) + } + + await deleteWebDAVResource(user, '/Readme.md') + const [root3] = await propfindFolder(user, '/', 0, properties) + expect(root3).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + test('never adds rich workspace property to nested folders for flat properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace-flat', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + await uploadFile({ name: 'workspace-flat/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + // Android app relies on this to detect rich workspace availability in subfolders properly + test('adds rich workspace property to nested folders for the default properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE, PROPERTY_WORKSPACE_FILE] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE, '') + + await uploadFile({ name: 'workspace/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE, '## Hello world\n') + }) + }) + + test.describe('with workspaces disabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 0) + }) + + test('does not return a rich workspace property', async ({ page, user }) => { + await page.goto('/apps/dashboard') + + const results1 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results1) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await user.uploadFile({ name: 'Readme.md', content: '## Hello world\n' }) + const results2 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results2) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await createFolder({ name: 'without-workspace', owner: user }) + const results3 = await propfindFolder(user, '/', 1) + const folder = results3.find((r) => r['d:href']?.endsWith('/without-workspace/')) + expect(folder).not.toHaveProperty(PROPERTY_WORKSPACE) + }) + }) +}) diff --git a/playwright/e2e/propfind-g.spec.ts b/playwright/e2e/propfind-g.spec.ts new file mode 100644 index 00000000000..d98b09eec76 --- /dev/null +++ b/playwright/e2e/propfind-g.spec.ts @@ -0,0 +1,106 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { expect } from '@playwright/test' +import { createFolder, uploadFile } from '../support/fixtures/Node.ts' +import { test } from '../support/fixtures/random-user.ts' +import { setTextSetting } from '../support/fixtures/settings.ts' +import { + deleteWebDAVResource, + PROPERTY_WORKSPACE, + PROPERTY_WORKSPACE_FILE, + PROPERTY_WORKSPACE_FILE_FLAT, + PROPERTY_WORKSPACE_FLAT, + propfindFolder, +} from '../support/fixtures/webdav.ts' + +test.describe('Text PROPFIND extension', () => { + test.describe('with workspaces enabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 1) + }) + + test('always adds rich workspace property', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await user.uploadFile({ name: 'Readme.md', content: '' }) + + const [root1] = await propfindFolder(user, '/', 0, properties) + expect(root1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + for (const n of [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]) { + const content = `## Hello world ${n}\n` + // await deleteWebDAVResource(user, '/Readme.md') + await user.uploadFile({ name: 'Readme.md', content }) + const [first] = await propfindFolder(user, '/', 0, properties) + expect(first).toHaveProperty(PROPERTY_WORKSPACE_FLAT, content) + } + + await deleteWebDAVResource(user, '/Readme.md') + const [root3] = await propfindFolder(user, '/', 0, properties) + expect(root3).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + test('never adds rich workspace property to nested folders for flat properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace-flat', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + await uploadFile({ name: 'workspace-flat/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + // Android app relies on this to detect rich workspace availability in subfolders properly + test('adds rich workspace property to nested folders for the default properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE, PROPERTY_WORKSPACE_FILE] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE, '') + + await uploadFile({ name: 'workspace/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE, '## Hello world\n') + }) + }) + + test.describe('with workspaces disabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 0) + }) + + test('does not return a rich workspace property', async ({ page, user }) => { + await page.goto('/apps/dashboard') + + const results1 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results1) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await user.uploadFile({ name: 'Readme.md', content: '## Hello world\n' }) + const results2 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results2) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await createFolder({ name: 'without-workspace', owner: user }) + const results3 = await propfindFolder(user, '/', 1) + const folder = results3.find((r) => r['d:href']?.endsWith('/without-workspace/')) + expect(folder).not.toHaveProperty(PROPERTY_WORKSPACE) + }) + }) +}) diff --git a/playwright/e2e/propfind.spec.ts b/playwright/e2e/propfind.spec.ts new file mode 100644 index 00000000000..da27d49ba20 --- /dev/null +++ b/playwright/e2e/propfind.spec.ts @@ -0,0 +1,107 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { expect } from '@playwright/test' +import { createFolder, uploadFile } from '../support/fixtures/Node.ts' +import { test } from '../support/fixtures/random-user.ts' +import { setTextSetting } from '../support/fixtures/settings.ts' +import { + deleteWebDAVResource, + PROPERTY_WORKSPACE, + PROPERTY_WORKSPACE_FILE, + PROPERTY_WORKSPACE_FILE_FLAT, + PROPERTY_WORKSPACE_FLAT, + propfindFolder, +} from '../support/fixtures/webdav.ts' + +test.describe('Text PROPFIND extension', () => { + test.describe('with workspaces enabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 1) + }) + + test('always adds rich workspace property', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await user.uploadFile({ name: 'Readme.md', content: '' }) + + const [root1] = await propfindFolder(user, '/', 0, properties) + expect(root1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + for (const n of [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]) { + const content = `## Hello world ${n}\n` + // await deleteWebDAVResource(user, '/Readme.md') + await user.uploadFile({ name: 'Readme.md', content }) + await new Promise((resolve) => setTimeout(resolve, 100)) + const [first] = await propfindFolder(user, '/', 0, properties) + expect(first).toHaveProperty(PROPERTY_WORKSPACE_FLAT, content) + } + + await deleteWebDAVResource(user, '/Readme.md') + const [root3] = await propfindFolder(user, '/', 0, properties) + expect(root3).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + test('never adds rich workspace property to nested folders for flat properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace-flat', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + + await uploadFile({ name: 'workspace-flat/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace-flat/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE_FLAT, '') + }) + + // Android app relies on this to detect rich workspace availability in subfolders properly + test('adds rich workspace property to nested folders for the default properties', async ({ page, user }) => { + const properties = [PROPERTY_WORKSPACE, PROPERTY_WORKSPACE_FILE] + + await page.goto('/apps/dashboard') + await createFolder({ name: 'workspace', owner: user }) + + const results1 = await propfindFolder(user, '/', 1, properties) + const folder1 = results1.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder1).toHaveProperty(PROPERTY_WORKSPACE, '') + + await uploadFile({ name: 'workspace/Readme.md', content: '## Hello world\n', owner: user }) + const results2 = await propfindFolder(user, '/', 1, properties) + const folder2 = results2.find((r) => r['d:href']?.endsWith('/workspace/')) + expect(folder2).toHaveProperty(PROPERTY_WORKSPACE, '## Hello world\n') + }) + }) + + test.describe('with workspaces disabled', () => { + test.beforeEach(async ({ user }) => { + await setTextSetting(user, 'workspace_enabled', 0) + }) + + test('does not return a rich workspace property', async ({ page, user }) => { + await page.goto('/apps/dashboard') + + const results1 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results1) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await user.uploadFile({ name: 'Readme.md', content: '## Hello world\n' }) + const results2 = await propfindFolder(user, '/', 1, [PROPERTY_WORKSPACE_FLAT, PROPERTY_WORKSPACE_FILE_FLAT]) + for (const result of results2) { + expect(result).not.toHaveProperty(PROPERTY_WORKSPACE_FLAT) + } + + await createFolder({ name: 'without-workspace', owner: user }) + const results3 = await propfindFolder(user, '/', 1) + const folder = results3.find((r) => r['d:href']?.endsWith('/without-workspace/')) + expect(folder).not.toHaveProperty(PROPERTY_WORKSPACE) + }) + }) +}) diff --git a/playwright/e2e/reconnect.spec.ts b/playwright/e2e/reconnect.spec.ts deleted file mode 100644 index 39458e85594..00000000000 --- a/playwright/e2e/reconnect.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as offlineTest } from '../support/fixtures/offline.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, offlineTest, uploadFileTest) - -// As we switch on and off the network -// we cannot run tests in parallel. -test.describe.configure({ mode: 'serial' }) - -test.beforeEach(async ({ open }) => { - await open() -}) - -test('opening a file with unsaved changes', async ({ - editor, - file, - open, - close, - setOffline, - setOnline, -}) => { - await expect(editor.el).toBeVisible() - await setOffline() - await editor.typeHeading('Hello world') - await expect(editor.saveIndicator).toHaveAccessibleName(/Unsaved changes/) - await close() - await setOnline() - await expect(await file.getContent()).toBe('') - await open() - await expect(editor.getHeading({ name: 'Hello world' })).toBeVisible() - await expect(editor.saveIndicator).not.toHaveAccessibleName(/Unsaved changes/) - await expect(await file.getContent()).toBe('## Hello world') -}) diff --git a/playwright/e2e/smart-picker.spec.ts b/playwright/e2e/smart-picker.spec.ts deleted file mode 100644 index e5ce2d7c6c3..00000000000 --- a/playwright/e2e/smart-picker.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, uploadFileTest) - -test.beforeEach(async ({ open }) => { - await open() -}) - -test('See top options', async ({ editor }) => { - await editor.type('/') - await expect(editor.getSuggestion('To-Do list')).toBeVisible() -}) - -test('Create heading', async ({ editor }) => { - await editor.type('/Heading') - await editor.content.press('Enter') - await editor.type('Hello world') - await editor.content.press('Enter') - await expect(editor.getHeading({ name: 'Hello world' })).toBeVisible() -}) - -test('Insert Link', async ({ editor }) => { - await editor.type('/Any') - await editor.getSuggestion('Any link').click() - await editor.referencePicker.fill('https://github.com') - await expect(editor.referenceWidget).toContainText('GitHub') - await editor.referencePicker.press('Enter') - await expect(editor.content.getByRole('link')).toContainText('github.com') -}) - -test('Files provider is renamed to "Link a file"', async ({ editor }) => { - await editor.type('/') - await expect(editor.getSuggestion('Link a file')).toBeVisible() -}) - -test('Important items appear before remaining items', async ({ editor }) => { - await editor.type('/') - await expect(editor.getSuggestion('To-Do list')).toBeVisible() - const allTexts = await editor.suggestions - .locator('.suggestion-list__item') - .allTextContents() - - const todoIdx = allTexts.findIndex((t) => t.includes('To-Do list')) - const tableIdx = allTexts.findIndex((t) => t.includes('Table')) - const filesIdx = allTexts.findIndex((t) => t.includes('Link a file')) - const heading1Idx = allTexts.findIndex((t) => t.includes('Heading 1')) - - expect(todoIdx).toBeLessThan(filesIdx) - expect(todoIdx).toBeLessThan(heading1Idx) - expect(tableIdx).toBeLessThan(filesIdx) - expect(tableIdx).toBeLessThan(heading1Idx) - expect(filesIdx).toBeLessThan(heading1Idx) -}) diff --git a/playwright/e2e/table-tab-navigation.spec.ts b/playwright/e2e/table-tab-navigation.spec.ts deleted file mode 100644 index 629f226d97c..00000000000 --- a/playwright/e2e/table-tab-navigation.spec.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, uploadFileTest) - -test.describe('Tab navigation inside table cell', () => { - test('indents list item inside table cell', async ({ editor, open }) => { - await open() - await editor.getMenu('Table').click() - - const firstCell = editor.content.locator('table td').first() - await firstCell.click() - await editor.type('- one') - await editor.content.press('Enter') - await editor.type('two') - - await editor.content.press('Tab') - - const nested = firstCell.locator('ul > li').first().locator('ul > li') - await expect(nested).toHaveText('two') - - await editor.content.press('Shift+Tab') - await expect(firstCell.locator('> ul > li')).toHaveCount(2) - await expect(firstCell.locator('> ul > li > ul')).toHaveCount(0) - }) - - test('navigates cells when caret is not inside a list', async ({ - editor, - open, - }) => { - await open() - await editor.getMenu('Table').click() - - const header = editor.content.locator('table th').first() - await header.click() - await editor.type('h1') - await editor.content.press('Tab') - await editor.type('h2') - - const headers = editor.content.locator('table th') - await expect(headers.nth(0)).toContainText('h1') - await expect(headers.nth(0)).toContainText('h1') - }) -}) diff --git a/playwright/e2e/versions.spec.ts b/playwright/e2e/versions.spec.ts deleted file mode 100644 index 8538b2e4324..00000000000 --- a/playwright/e2e/versions.spec.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import type { Locator } from '@playwright/test' -import type { EditorSection } from '../support/sections/EditorSection.ts' - -import { expect, mergeTests } from '@playwright/test' -import { test as editorTest } from '../support/fixtures/editor.ts' -import { test as randomUserTest } from '../support/fixtures/random-user.ts' -import { test as uploadFileTest } from '../support/fixtures/upload-file.ts' - -const test = mergeTests(editorTest, randomUserTest, uploadFileTest) - -test.use({ - fileName: 'versions.md', - fileContent: '# V3', -}) - -test.describe('Versions with close timestamps', () => { - test.use({ - oldVersions: [ - [ - { content: '# V1', mtime: 1691420501 }, - { content: '# V2', mtime: 1691420521 }, - ], - { scope: 'test' }, - ], - }) - - test('Show up separately', async ({ editor, open, viewer }) => { - await open() - const versions = await viewer.openSidebarTab('Versions') - await checkVersions(versions, editor) - }) -}) - -test.describe('Versions with distant timestamps', () => { - test.use({ - oldVersions: [ - [ - { content: '# V1', mtime: 1691420501 }, - { content: '# V2', mtime: 1691424242 }, - ], - { scope: 'test' }, - ], - }) - - test('Show up', async ({ editor, open, viewer }) => { - await open() - const versions = await viewer.openSidebarTab('Versions') - await checkVersions(versions, editor) - }) - - test('Compare', async ({ open, page, viewer }) => { - await open() - const versions = await viewer.openSidebarTab('Versions') - await versions.getByRole('button').nth(2).click() - await page - .getByRole('menuitem', { name: 'Compare to current version' }) - .click() - const oldVersion = page.getByRole('textbox') - const current = page.locator('.ProseMirror[contenteditable="true"]') - await expect(oldVersion.getByRole('heading', { name: 'V1' })).toBeVisible() - await expect(current.getByRole('heading', { name: 'V3' })).toBeVisible() - - // Test that version contents are vertically aligned - const oldBox = await oldVersion.getByRole('heading', { name: 'V1' }).boundingBox() - const currentBox = await oldVersion.getByRole('heading', { name: 'V3' }).boundingBox() - expect(Math.abs(oldBox!.y - currentBox!.y)).toBeLessThan(5) - }) -}) - -/** - * Go through the different versions and check them in the editor - * - * Assumes 3 versions with content `# V1`, `# V2` and `# V3` - * @param versions Versions tab content - * @param editor editor section to inspect for headings - */ -async function checkVersions(versions: Locator, editor: EditorSection) { - expect(await versions.getByRole('link')).toHaveCount(3) - // the oldest version is at the end of the versions list - await versions.getByRole('link').nth(2).click() - await expect(editor.getHeading({ name: 'V1' })).toBeVisible() - await versions.getByRole('link').nth(1).click() - await expect(editor.getHeading({ name: 'V2' })).toBeVisible() - // current version - await versions.getByRole('link').nth(0).click() - // https://github.com/nextcloud/viewer/issues/3052 - // await expect(editor.getHeading({ name: 'V3' })).toBeVisible() -} diff --git a/playwright/start-nextcloud-server.mjs b/playwright/start-nextcloud-server.mjs index 83d0ee70a15..44b623fd503 100644 --- a/playwright/start-nextcloud-server.mjs +++ b/playwright/start-nextcloud-server.mjs @@ -33,13 +33,7 @@ async function start() { const appinfo = readFileSync('appinfo/info.xml').toString() const maxVersion = appinfo.match(//)?.[1] - let branch = 'master' - if (maxVersion) { - const refs = execSync('git ls-remote --refs').toString('utf-8') - branch = refs.includes(`refs/heads/stable${maxVersion}`) - ? `stable${maxVersion}` - : branch - } + let branch = 'stable34' return await startNextcloud(branch, true, { exposePort: 8089, @@ -65,7 +59,7 @@ if (await isServerRunning()) { } else { const ip = await start() await waitOnNextcloud(ip) - await configureNextcloud(['text', 'viewer']) + await configureNextcloud(['text']) } // Idle to wait for shutdown diff --git a/playwright/support/fixtures/settings.ts b/playwright/support/fixtures/settings.ts new file mode 100644 index 00000000000..bc1418f9649 --- /dev/null +++ b/playwright/support/fixtures/settings.ts @@ -0,0 +1,20 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import type { User } from './User.ts' + +/** + * Set a user-level configuration value for the Text app. + * + * @param user The user to do the request + * @param key The setting key to set + * @param value The value + */ +export async function setTextSetting(user: User, key: string, value: number | string): Promise { + await user.request.post('/index.php/apps/text/settings', { + data: { key, value }, + failOnStatusCode: true, + }) +} diff --git a/playwright/support/fixtures/webdav.ts b/playwright/support/fixtures/webdav.ts new file mode 100644 index 00000000000..ac25c117e1e --- /dev/null +++ b/playwright/support/fixtures/webdav.ts @@ -0,0 +1,105 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import type { User } from './User.ts' + +import { JSDOM } from 'jsdom' + +/** A parsed set of WebDAV properties for a single resource. Includes `d:href` for path-based lookup. */ +export type PropfindResult = Record + +export const PROPERTY_WORKSPACE = 'nc:rich-workspace' +export const PROPERTY_WORKSPACE_FILE = 'nc:rich-workspace-file' +export const PROPERTY_WORKSPACE_FLAT = 'nc:rich-workspace-flat' +export const PROPERTY_WORKSPACE_FILE_FLAT = 'nc:rich-workspace-file-flat' + +const DAV_NS = 'DAV:' +const NC_NS = 'http://nextcloud.org/ns' +const OC_NS = 'http://owncloud.org/ns' + +/** + * Delete a WebDAV resource (file or folder). Silently ignores 404. + * + * @param user The user to do the request + * @param path The WebDAV path to the file or folder + */ +export async function deleteWebDAVResource(user: User, path: string): Promise { + await user.request.delete(`/remote.php/webdav${path}`, { failOnStatusCode: false }) +} + +/** + * Send a PROPFIND request and return one parsed result per d:response. + * + * The first entry is always the requested resource itself; subsequent entries + * are its children (depth > 0). Each entry contains a `d:href` key so callers + * can locate a specific resource by path without relying on response ordering: + * + * const folder = results.find(r => r['d:href']?.endsWith('/my-folder/')) + * + * Only properties from `200 OK` propstats are included; `404 Not Found` propstats + * are silently skipped. + * + * @param user The user to do the request + * @param path The WebDAV path to query; use '/' for the user root + * @param depth The Depth header value (0 or 1) + * @param properties DAV properties to request, e.g. ['nc:rich-workspace-flat']. Defaults to nc:rich-workspace and nc:rich-workspace-file. + */ +export async function propfindFolder( + user: User, + path: string, + depth: number, + properties: string[] | null = null, +): Promise { + const defaultProperties = [PROPERTY_WORKSPACE, PROPERTY_WORKSPACE_FILE] + const props = properties ?? defaultProperties + const propsXml = props.map((p) => `<${p} />`).join('\n\t\t') + + const requestPath = `/remote.php/webdav${path}` + const response = await user.request.fetch(requestPath, { + method: 'PROPFIND', + headers: { + Depth: String(depth), + 'Content-Type': 'application/xml', + }, + data: ` + + + ${propsXml} + +`, + failOnStatusCode: false, + }) + + const body = await response.text() + const xmlDoc = new JSDOM(body, { contentType: 'text/xml' }).window.document + const responses = xmlDoc.getElementsByTagNameNS(DAV_NS, 'response') + + return Array.from(responses).map((resp) => { + const entry: PropfindResult = {} + entry['d:href'] = resp.getElementsByTagNameNS(DAV_NS, 'href')[0]?.textContent ?? '' + + Array.from(resp.getElementsByTagNameNS(DAV_NS, 'propstat')).forEach((propStat) => { + const status = propStat.getElementsByTagNameNS(DAV_NS, 'status')[0]?.textContent + if (status?.includes('404')) { + return + } + + const prop = propStat.getElementsByTagNameNS(DAV_NS, 'prop')[0] + Array.from(prop?.children ?? []).forEach((child) => { + const ns = child.namespaceURI + const local = child.localName + const key = ns === NC_NS + ? `nc:${local}` + : ns === OC_NS + ? `oc:${local}` + : local + entry[key] = child.textContent || '' + }) + }) + return entry + }) +}