|
| 1 | +/** |
| 2 | + * SPDX-FileCopyrightText: 2024 Ferdinand Thiessen <opensource@fthiessen.de> |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + */ |
| 5 | + |
| 6 | +import { expect } from '@playwright/test' |
| 7 | +import { test } from '../support/fixtures/sharing-user' |
| 8 | + |
| 9 | +test('Share a file read only that cannot be locked by the recipient', async ({ pageOwner, pageRecipient, owner, recipient, request }) => { |
| 10 | + // Create a test file as owner |
| 11 | + const filename = 'test-share.txt' |
| 12 | + const response = await request.put(`/remote.php/dav/files/${owner.userId}/${filename}`, { |
| 13 | + headers: { |
| 14 | + Authorization: `Basic ${Buffer.from(`${owner.userId}:${owner.password}`).toString('base64')}`, |
| 15 | + }, |
| 16 | + data: 'Test file content', |
| 17 | + }) |
| 18 | + expect(response.ok()).toBeTruthy() |
| 19 | + |
| 20 | + // Share the file with recipient |
| 21 | + const shareResponse = await request.post('/ocs/v2.php/apps/files_sharing/api/v1/shares', { |
| 22 | + headers: { |
| 23 | + 'OCS-APIRequest': 'true', |
| 24 | + 'Content-Type': 'application/json', |
| 25 | + Authorization: `Basic ${Buffer.from(`${owner.userId}:${owner.password}`).toString('base64')}`, |
| 26 | + }, |
| 27 | + data: { |
| 28 | + path: `/${filename}`, |
| 29 | + shareType: '0', // User share |
| 30 | + shareWith: recipient.userId, |
| 31 | + permissions: '1', |
| 32 | + }, |
| 33 | + }) |
| 34 | + expect(shareResponse.ok()).toBeTruthy() |
| 35 | + |
| 36 | + // Check recipient cannot lock |
| 37 | + await pageRecipient.goto('/apps/files') |
| 38 | + await pageRecipient.waitForURL(/apps\/files/) |
| 39 | + const rowRecipient = await pageRecipient.getByRole('row', { name: filename }) |
| 40 | + await rowRecipient.getByRole('button', { name: 'Actions' }).click() |
| 41 | + await expect(pageRecipient.getByRole('menuitem', { name: 'Lock file' })).not.toBeVisible() |
| 42 | + |
| 43 | + // Check owner can still lock |
| 44 | + await pageOwner.goto('/apps/files') |
| 45 | + await pageOwner.waitForURL(/apps\/files/) |
| 46 | + const rowOwner = await pageOwner.getByRole('row', { name: filename }) |
| 47 | + await rowOwner.getByRole('button', { name: 'Actions' }).click() |
| 48 | + await expect(pageOwner.getByRole('menuitem', { name: 'Lock file' })).toBeVisible() |
| 49 | +}) |
0 commit comments