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