aboutsummaryrefslogtreecommitdiffstats
path: root/cypress/e2e/systemtags/files-sidebar.cy.ts
blob: c6e6fda50d452ec1f40e47238e2752727e6a4b47 (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
/**
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

import type { User } from '@nextcloud/cypress'
import { randomBytes } from 'crypto'
import { getRowForFile, triggerActionForFile } from '../files/FilesUtils.ts'

describe('Systemtags: Files sidebar integration', { testIsolation: true }, () => {
	let user: User

	beforeEach(() => cy.createRandomUser().then(($user) => {
		user = $user

		cy.mkdir(user, '/folder')
		cy.uploadContent(user, new Blob([]), 'text/plain', '/file.txt')
		cy.login(user)
	}))

	it('Can assign tags using the sidebar', () => {
		const tag = randomBytes(8).toString('base64')
		cy.visit('/apps/files')

		getRowForFile('file.txt').should('be.visible')
		triggerActionForFile('file.txt', 'details')

		cy.get('[data-cy-sidebar]')
			.should('be.visible')
			.findByRole('button', { name: 'Actions' })
			.should('be.visible')
			.click()

		cy.findByRole('menuitem', { name: 'Tags' })
			.click()

		cy.intercept('PUT', '**/remote.php/dav/systemtags-relations/files/**').as('assignTag')
		cy.get('[data-cy-sidebar]')
			.findByRole('combobox', { name: /collaborative tags/i })
			.should('be.visible')
			.type(`${tag}{enter}`)
		cy.wait('@assignTag')
	})
})