1- /**
1+ /*
22 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
33 * SPDX-License-Identifier: AGPL-3.0-or-later
44 */
5+
56import type { User } from '@nextcloud/e2e-test-server/cypress'
67
78import { randomBytes } from 'crypto'
8- import { closeSidebar , getRowForFile , triggerActionForFile } from '../files/FilesUtils.ts'
9+ import { getRowForFile } from '../files/FilesUtils.ts'
10+ import { addTagToFile } from './utils.ts'
911
1012describe ( 'Systemtags: Files integration' , { testIsolation : true } , ( ) => {
1113 let user : User
@@ -21,31 +23,7 @@ describe('Systemtags: Files integration', { testIsolation: true }, () => {
2123
2224 it ( 'See first assigned tag in the file list' , ( ) => {
2325 const tag = randomBytes ( 8 ) . toString ( 'base64' )
24-
25- cy . intercept ( 'PROPFIND' , `**/remote.php/dav/files/${ user . userId } /file.txt` ) . as ( 'getNode' )
26- getRowForFile ( 'file.txt' ) . should ( 'be.visible' )
27- triggerActionForFile ( 'file.txt' , 'details' )
28- cy . wait ( '@getNode' )
29-
30- cy . get ( '[data-cy-sidebar]' )
31- . should ( 'be.visible' )
32- . findByRole ( 'button' , { name : 'Actions' } )
33- . should ( 'be.visible' )
34- . click ( )
35-
36- cy . findByRole ( 'menuitem' , { name : 'Tags' } )
37- . should ( 'be.visible' )
38- . click ( )
39-
40- cy . intercept ( 'PUT' , '**/remote.php/dav/systemtags-relations/files/**' ) . as ( 'assignTag' )
41-
42- getCollaborativeTagsInput ( )
43- . type ( `{selectAll}${ tag } {enter}` )
44- cy . wait ( '@assignTag' )
45- cy . wait ( '@getNode' )
46-
47- // Close the sidebar and reload to check the file list
48- closeSidebar ( )
26+ addTagToFile ( 'file.txt' , tag )
4927 cy . reload ( )
5028
5129 getRowForFile ( 'file.txt' )
@@ -58,38 +36,8 @@ describe('Systemtags: Files integration', { testIsolation: true }, () => {
5836 it ( 'See two assigned tags are also shown in the file list' , ( ) => {
5937 const tag1 = randomBytes ( 5 ) . toString ( 'base64' )
6038 const tag2 = randomBytes ( 5 ) . toString ( 'base64' )
61-
62- cy . intercept ( 'PROPFIND' , `**/remote.php/dav/files/${ user . userId } /file.txt` ) . as ( 'getNode' )
63- getRowForFile ( 'file.txt' ) . should ( 'be.visible' )
64- triggerActionForFile ( 'file.txt' , 'details' )
65- cy . wait ( '@getNode' )
66-
67- cy . get ( '[data-cy-sidebar]' )
68- . should ( 'be.visible' )
69- . findByRole ( 'button' , { name : 'Actions' } )
70- . should ( 'be.visible' )
71- . click ( )
72-
73- cy . findByRole ( 'menuitem' , { name : 'Tags' } )
74- . should ( 'be.visible' )
75- . click ( )
76-
77- cy . intercept ( 'PUT' , '**/remote.php/dav/systemtags-relations/files/**' ) . as ( 'assignTag' )
78-
79- // Assign first tag
80- getCollaborativeTagsInput ( )
81- . type ( `{selectAll}${ tag1 } {enter}` )
82- cy . wait ( '@assignTag' )
83- cy . wait ( '@getNode' )
84-
85- // Assign second tag
86- getCollaborativeTagsInput ( )
87- . type ( `{selectAll}${ tag2 } {enter}` )
88- cy . wait ( '@assignTag' )
89- cy . wait ( '@getNode' )
90-
91- // Close the sidebar and reload to check the file list
92- closeSidebar ( )
39+ addTagToFile ( 'file.txt' , tag1 )
40+ addTagToFile ( 'file.txt' , tag2 )
9341 cy . reload ( )
9442
9543 getRowForFile ( 'file.txt' )
@@ -104,44 +52,9 @@ describe('Systemtags: Files integration', { testIsolation: true }, () => {
10452 const tag1 = randomBytes ( 4 ) . toString ( 'base64' )
10553 const tag2 = randomBytes ( 4 ) . toString ( 'base64' )
10654 const tag3 = randomBytes ( 4 ) . toString ( 'base64' )
107-
108- cy . intercept ( 'PROPFIND' , `**/remote.php/dav/files/${ user . userId } /file.txt` ) . as ( 'getNode' )
109- getRowForFile ( 'file.txt' ) . should ( 'be.visible' )
110- triggerActionForFile ( 'file.txt' , 'details' )
111- cy . wait ( '@getNode' )
112-
113- cy . get ( '[data-cy-sidebar]' )
114- . should ( 'be.visible' )
115- . findByRole ( 'button' , { name : 'Actions' } )
116- . should ( 'be.visible' )
117- . click ( )
118-
119- cy . findByRole ( 'menuitem' , { name : 'Tags' } )
120- . should ( 'be.visible' )
121- . click ( )
122-
123- cy . intercept ( 'PUT' , '**/remote.php/dav/systemtags-relations/files/**' ) . as ( 'assignTag' )
124-
125- // Assign first tag
126- getCollaborativeTagsInput ( )
127- . type ( `{selectAll}${ tag1 } {enter}` )
128- cy . wait ( '@assignTag' )
129- cy . wait ( '@getNode' )
130-
131- // Assign second tag
132- getCollaborativeTagsInput ( )
133- . type ( `{selectAll}${ tag2 } {enter}` )
134- cy . wait ( '@assignTag' )
135- cy . wait ( '@getNode' )
136-
137- // Assign third tag
138- getCollaborativeTagsInput ( )
139- . type ( `{selectAll}${ tag3 } {enter}` )
140- cy . wait ( '@assignTag' )
141- cy . wait ( '@getNode' )
142-
143- // Close the sidebar and reload to check the file list
144- closeSidebar ( )
55+ addTagToFile ( 'file.txt' , tag1 )
56+ addTagToFile ( 'file.txt' , tag2 )
57+ addTagToFile ( 'file.txt' , tag3 )
14558 cy . reload ( )
14659
14760 getRowForFile ( 'file.txt' )
@@ -163,10 +76,3 @@ describe('Systemtags: Files integration', { testIsolation: true }, () => {
16376 } )
16477 } )
16578} )
166-
167- function getCollaborativeTagsInput ( ) : Cypress . Chainable < JQuery < HTMLElement > > {
168- return cy . get ( '[data-cy-sidebar]' )
169- . findByRole ( 'combobox' , { name : / c o l l a b o r a t i v e t a g s / i } )
170- . should ( 'be.visible' )
171- . should ( 'not.have.attr' , 'disabled' , { timeout : 5000 } )
172- }
0 commit comments