aboutsummaryrefslogtreecommitdiffstats
path: root/cypress/e2e/files_versions/version_sharing.cy.ts
blob: e978cb42fd9ee9a1939109500b906ff733732ab3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
 * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
import type { User } from '@nextcloud/cypress'
import { openVersionsPanel, setupTestSharedFileFromUser, uploadThreeVersions } from './filesVersionsUtils.ts'
import { navigateToFolder, triggerActionForFile } from '../files/FilesUtils.ts'

describe('Versions on shares', () => {
	const randomSharedFolderName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10)
	const randomFileName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
	const randomFilePath = `${randomSharedFolderName}/${randomFileName}`
	let alice: User
	let bob: User

	before(() => {
		cy.createRandomUser()
			.then((user) => {
				alice = user
			})
			.then(() => {
				cy.mkdir(alice, `/${randomSharedFolderName}`)
				return setupTestSharedFileFromUser(alice, randomSharedFolderName, {})
			})
			.then((user) => { bob = user })
			.then(() => uploadThreeVersions(alice, randomFilePath))
	})

	it('See sharees display name as author', () => {
		cy.login(bob)
		cy.visit('/apps/files')

		navigateToFolder(randomSharedFolderName)

		triggerActionForFile(randomFileName, 'details')
		cy.findByRole('tab', { name: 'Versions' }).click()

		cy.findByRole('tabpanel', { name: 'Versions' })
			.findByRole('list', { name: 'File versions' })
			.findAllByRole('listitem')
			.first()
			.find('[data-cy-files-version-author-name]')
			.should('be.visible')
			.and('contain.text', alice.userId)
	})
})