33 * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
44 * SPDX-License-Identifier: AGPL-3.0-or-later
55 */
6- // dist file might not be built when running eslint only
7- // eslint-disable-next-line import/no-unresolved,n/no-missing-import
8- import { Folder , Permission , addNewFileMenuEntry , type Entry } from '@nextcloud/files'
6+ import { Folder , Permission } from '@nextcloud/files'
97import { generateRemoteUrl } from '@nextcloud/router'
108import { UploadPicker , UploadStatus , getUploader } from '../../../lib/index.ts'
119
@@ -39,8 +37,9 @@ describe('UploadPicker rendering', () => {
3937 }
4038 cy . mount ( UploadPicker , { propsData } )
4139 cy . get ( '[data-cy-upload-picker]' ) . should ( 'be.visible' )
42- cy . get ( '[data-cy-upload-picker]' ) . shouldHaveTrimmedText ( 'New' )
40+ cy . get ( '[data-cy-upload-picker]' ) . should ( 'contain.text' , 'New' )
4341 cy . get ( '[data-cy-upload-picker] [data-cy-upload-picker-input]' ) . should ( 'exist' )
42+ cy . get ( '[data-cy-upload-picker] [data-cy-upload-picker-progress]' ) . should ( 'not.be.visible' )
4443 } )
4544
4645 it ( 'Does NOT render without a destination' , ( ) => {
@@ -68,22 +67,22 @@ describe('UploadPicker valid uploads', () => {
6867 cy . mount ( UploadPicker , { propsData } ) . as ( 'uploadPicker' )
6968
7069 // Label is displayed before upload
71- cy . get ( '[data-cy-upload-picker]' ) . shouldHaveTrimmedText ( 'New' )
70+ cy . get ( '[data-cy-upload-picker]' )
71+ . contains ( 'button' , 'New' )
72+ . should ( 'be.visible' )
7273
7374 // Check and init aliases
7475 cy . get ( '[data-cy-upload-picker] [data-cy-upload-picker-input]' ) . as ( 'input' ) . should ( 'exist' )
75- cy . get ( '[data-cy-upload-picker] . upload-picker__progress ' ) . as ( 'progress' ) . should ( 'exist' )
76+ cy . get ( '[data-cy-upload-picker] [data-cy- upload-picker-progress] ' ) . as ( 'progress' ) . should ( 'exist' )
7677 } )
7778
7879 afterEach ( ( ) => resetDocument ( ) )
7980
8081 it ( 'Uploads a file' , ( ) => {
81- // Intercept single upload
82+ const { promise , resolve } = Promise . withResolvers < void > ( )
8283 cy . intercept ( 'PUT' , '/remote.php/dav/files/*/*' , ( req ) => {
83- req . reply ( {
84- statusCode : 201 ,
85- delay : 2000 ,
86- } )
84+ req . reply ( { statusCode : 201 } )
85+ req . on ( 'response' , async ( ) => await promise )
8786 } ) . as ( 'upload' )
8887
8988 cy . get ( '@input' ) . attachFile ( {
@@ -95,16 +94,20 @@ describe('UploadPicker valid uploads', () => {
9594 lastModified : new Date ( ) . getTime ( ) ,
9695 } )
9796
98- cy . get ( '[data-cy-upload-picker] .upload-picker__progress' )
99- . as ( 'progress' )
100- . should ( 'be.visible' )
101-
102- // Label gets hidden during upload
103- cy . get ( '[data-cy-upload-picker]' ) . should ( 'not.have.text' , 'New' )
97+ cy . get ( '@progress' ) . should ( 'be.visible' )
98+ cy . get ( '[data-cy-upload-picker]' )
99+ . within ( ( ) => {
100+ // Label gets hidden during upload
101+ cy . contains ( 'button' , 'New' ) . should ( 'not.exist' )
102+ // but the button exists
103+ cy . get ( 'button[data-cy-upload-picker-add]' )
104+ . should ( 'be.visible' )
105+ . and ( 'have.attr' , 'aria-label' , 'New' )
106+ } )
107+ . then ( ( ) => resolve ( ) )
104108
105109 cy . wait ( '@upload' ) . then ( ( ) => {
106- cy . get ( '[data-cy-upload-picker] .upload-picker__progress' )
107- . as ( 'progress' )
110+ cy . get ( '@progress' )
108111 . should ( 'not.be.visible' )
109112
110113 // Label is displayed again after upload
0 commit comments