|
4 | 4 | */ |
5 | 5 | // @ts-expect-error The package is currently broken - but works... |
6 | 6 | import { deleteDownloadsFolderBeforeEach } from 'cypress-delete-downloads-folder' |
7 | | -import { createShare, getShareUrl, setupPublicShare, type ShareContext } from './setup-public-share.ts' |
| 7 | +import { createShare, getShareUrl, openLinkShareDetails, setupPublicShare, type ShareContext } from './setup-public-share.ts' |
8 | 8 | import { getRowForFile, getRowForFileId, triggerActionForFile, triggerActionForFileId } from '../../files/FilesUtils.ts' |
9 | 9 | import { zipFileContains } from '../../../support/utils/assertions.ts' |
| 10 | +import type { User } from '@nextcloud/cypress' |
10 | 11 |
|
11 | 12 | describe('files_sharing: Public share - downloading files', { testIsolation: true }, () => { |
12 | 13 |
|
@@ -170,4 +171,98 @@ describe('files_sharing: Public share - downloading files', { testIsolation: tru |
170 | 171 | }) |
171 | 172 | }) |
172 | 173 | }) |
| 174 | + |
| 175 | + describe('download permission - link share', () => { |
| 176 | + let context: ShareContext |
| 177 | + beforeEach(() => { |
| 178 | + cy.createRandomUser().then((user) => { |
| 179 | + cy.mkdir(user, '/test') |
| 180 | + |
| 181 | + context = { user } |
| 182 | + createShare(context, 'test') |
| 183 | + cy.login(context.user) |
| 184 | + cy.visit('/apps/files') |
| 185 | + }) |
| 186 | + }) |
| 187 | + |
| 188 | + deleteDownloadsFolderBeforeEach() |
| 189 | + |
| 190 | + it('download permission is retained', () => { |
| 191 | + getRowForFile('test').should('be.visible') |
| 192 | + triggerActionForFile('test', 'details') |
| 193 | + |
| 194 | + openLinkShareDetails(0) |
| 195 | + |
| 196 | + cy.intercept('PUT', '**/ocs/v2.php/apps/files_sharing/api/v1/shares/*').as('update') |
| 197 | + |
| 198 | + cy.findByRole('checkbox', { name: /hide download/i }) |
| 199 | + .should('exist') |
| 200 | + .and('not.be.checked') |
| 201 | + .check({ force: true }) |
| 202 | + cy.findByRole('checkbox', { name: /hide download/i }) |
| 203 | + .should('be.checked') |
| 204 | + cy.findByRole('button', { name: /update share/i }) |
| 205 | + .click() |
| 206 | + |
| 207 | + cy.wait('@update') |
| 208 | + |
| 209 | + openLinkShareDetails(0) |
| 210 | + cy.findByRole('checkbox', { name: /hide download/i }) |
| 211 | + .should('be.checked') |
| 212 | + |
| 213 | + cy.reload() |
| 214 | + |
| 215 | + getRowForFile('test').should('be.visible') |
| 216 | + triggerActionForFile('test', 'details') |
| 217 | + openLinkShareDetails(0) |
| 218 | + cy.findByRole('checkbox', { name: /hide download/i }) |
| 219 | + .should('be.checked') |
| 220 | + }) |
| 221 | + }) |
| 222 | + |
| 223 | + describe('download permission - mail share', () => { |
| 224 | + let user: User |
| 225 | + |
| 226 | + beforeEach(() => { |
| 227 | + cy.createRandomUser().then(($user) => { |
| 228 | + user = $user |
| 229 | + cy.mkdir(user, '/test') |
| 230 | + cy.login(user) |
| 231 | + cy.visit('/apps/files') |
| 232 | + }) |
| 233 | + }) |
| 234 | + |
| 235 | + it('download permission is retained', () => { |
| 236 | + getRowForFile('test').should('be.visible') |
| 237 | + triggerActionForFile('test', 'details') |
| 238 | + |
| 239 | + cy.findByRole('combobox', { name: /Enter external recipients/i }) |
| 240 | + .type('test@example.com') |
| 241 | + |
| 242 | + cy.get('.option[sharetype="4"][user="test@example.com"]') |
| 243 | + .parent('li') |
| 244 | + .click() |
| 245 | + cy.findByRole('button', { name: /advanced settings/i }) |
| 246 | + .should('be.visible') |
| 247 | + .click() |
| 248 | + |
| 249 | + cy.intercept('PUT', '**/ocs/v2.php/apps/files_sharing/api/v1/shares/*').as('update') |
| 250 | + |
| 251 | + cy.findByRole('checkbox', { name: /hide download/i }) |
| 252 | + .should('exist') |
| 253 | + .and('not.be.checked') |
| 254 | + .check({ force: true }) |
| 255 | + cy.findByRole('button', { name: /save share/i }) |
| 256 | + .click() |
| 257 | + |
| 258 | + cy.wait('@update') |
| 259 | + |
| 260 | + openLinkShareDetails(1) |
| 261 | + cy.findByRole('button', { name: /advanced settings/i }) |
| 262 | + .click() |
| 263 | + cy.findByRole('checkbox', { name: /hide download/i }) |
| 264 | + .should('exist') |
| 265 | + .and('be.checked') |
| 266 | + }) |
| 267 | + }) |
173 | 268 | }) |
0 commit comments