-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(files): add selection cypress tests
Signed-off-by: skjnldsv <[email protected]>
- Loading branch information
Showing
6 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import type { User } from '@nextcloud/cypress' | ||
import { deselectAllFiles, selectAllFiles, selectRowForFile } from './FilesUtils' | ||
|
||
const files = { | ||
'image.jpg': 'image/jpeg', | ||
'document.pdf': 'application/pdf', | ||
'archive.zip': 'application/zip', | ||
'audio.mp3': 'audio/mpeg', | ||
'video.mp4': 'video/mp4', | ||
'readme.md': 'text/markdown', | ||
'welcome.txt': 'text/plain', | ||
} | ||
const filesCount = Object.keys(files).length | ||
|
||
describe('files: Select all files', { testIsolation: true }, () => { | ||
let user: User | ||
|
||
before(() => { | ||
cy.createRandomUser().then(($user) => { | ||
user = $user | ||
Object.keys(files).forEach((file) => { | ||
cy.uploadContent(user, new Blob(), files[file], '/' + file) | ||
}) | ||
}) | ||
}) | ||
|
||
beforeEach(() => { | ||
cy.login(user) | ||
cy.visit('/apps/files') | ||
}) | ||
|
||
it('Can select and unselect all files', () => { | ||
cy.get('[data-cy-files-list-row-fileid]').should('have.length', filesCount) | ||
cy.get('[data-cy-files-list-row-checkbox]').should('have.length', filesCount) | ||
|
||
selectAllFiles() | ||
|
||
cy.get('.files-list__selected').should('have.text', '7 selected') | ||
cy.get('[data-cy-files-list-row-checkbox]').findByRole('checkbox').should('be.checked') | ||
|
||
deselectAllFiles() | ||
|
||
cy.get('.files-list__selected').should('not.exist') | ||
cy.get('[data-cy-files-list-row-checkbox]').findByRole('checkbox').should('not.be.checked') | ||
}) | ||
|
||
it('Can select some files randomly', () => { | ||
const randomFiles = Object.keys(files).reduce((acc, file) => { | ||
if (Math.random() > 0.1) { | ||
acc.push(file) | ||
} | ||
return acc | ||
}, [] as string[]) | ||
|
||
randomFiles.forEach(name => selectRowForFile(name)) | ||
|
||
cy.get('.files-list__selected').should('have.text', `${randomFiles.length} selected`) | ||
cy.get('[data-cy-files-list-row-checkbox] input[type="checkbox"]:checked').should('have.length', randomFiles.length) | ||
}) | ||
|
||
it('Can select range of files with shift key', () => { | ||
cy.get('[data-cy-files-list-row-checkbox]').should('have.length', filesCount) | ||
selectRowForFile('audio.mp3') | ||
cy.window().trigger('keydown', { shiftKey: true }) | ||
selectRowForFile('readme.md', { shiftKey: true }) | ||
cy.window().trigger('keyup', { shiftKey: false }) | ||
|
||
cy.get('.files-list__selected').should('have.text', '4 selected') | ||
cy.get('[data-cy-files-list-row-checkbox] input[type="checkbox"]:checked').should('have.length', 4) | ||
|
||
}) | ||
}) |
File renamed without changes.