mirror of
https://github.com/nextcloud/server.git
synced 2024-12-29 00:18:42 +00:00
a39f13e94e
This fixes non reactive default action text of the name component. Also use download action as default action so that only one place is needed to define how to download a file. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
146 lines
4.1 KiB
TypeScript
146 lines
4.1 KiB
TypeScript
/*!
|
|
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
import type { User } from '@nextcloud/cypress'
|
|
import { getRowForFile, navigateToFolder, triggerActionForFile } from './FilesUtils'
|
|
import { deleteDownloadsFolderBeforeEach } from 'cypress-delete-downloads-folder'
|
|
|
|
describe('files: Download files using file actions', { testIsolation: true }, () => {
|
|
let user: User
|
|
|
|
deleteDownloadsFolderBeforeEach()
|
|
|
|
beforeEach(() => {
|
|
cy.createRandomUser().then(($user) => {
|
|
user = $user
|
|
})
|
|
})
|
|
|
|
it('can download file', () => {
|
|
cy.uploadContent(user, new Blob(['<content>']), 'text/plain', '/file.txt')
|
|
cy.login(user)
|
|
cy.visit('/apps/files')
|
|
|
|
getRowForFile('file.txt').should('be.visible')
|
|
|
|
triggerActionForFile('file.txt', 'download')
|
|
|
|
const downloadsFolder = Cypress.config('downloadsFolder')
|
|
cy.readFile(`${downloadsFolder}/file.txt`, { timeout: 15000 })
|
|
.should('exist')
|
|
.and('have.length.gt', 8)
|
|
.and('equal', '<content>')
|
|
})
|
|
|
|
/**
|
|
* Regression test of https://github.com/nextcloud/server/issues/44855
|
|
*/
|
|
it('can download file with hash name', () => {
|
|
cy.uploadContent(user, new Blob(['<content>']), 'text/plain', '/#file.txt')
|
|
cy.login(user)
|
|
cy.visit('/apps/files')
|
|
|
|
triggerActionForFile('#file.txt', 'download')
|
|
const downloadsFolder = Cypress.config('downloadsFolder')
|
|
cy.readFile(`${downloadsFolder}/#file.txt`, { timeout: 15000 })
|
|
.should('exist')
|
|
.and('have.length.gt', 8)
|
|
.and('equal', '<content>')
|
|
})
|
|
|
|
/**
|
|
* Regression test of https://github.com/nextcloud/server/issues/44855
|
|
*/
|
|
it('can download file from folder with hash name', () => {
|
|
cy.mkdir(user, '/#folder')
|
|
.uploadContent(user, new Blob(['<content>']), 'text/plain', '/#folder/file.txt')
|
|
cy.login(user)
|
|
cy.visit('/apps/files')
|
|
|
|
navigateToFolder('#folder')
|
|
// All are visible by default
|
|
getRowForFile('file.txt').should('be.visible')
|
|
|
|
triggerActionForFile('file.txt', 'download')
|
|
const downloadsFolder = Cypress.config('downloadsFolder')
|
|
cy.readFile(`${downloadsFolder}/file.txt`, { timeout: 15000 })
|
|
.should('exist')
|
|
.and('have.length.gt', 8)
|
|
.and('equal', '<content>')
|
|
})
|
|
})
|
|
|
|
describe('files: Download files using default action', { testIsolation: true }, () => {
|
|
let user: User
|
|
|
|
deleteDownloadsFolderBeforeEach()
|
|
|
|
beforeEach(() => {
|
|
cy.createRandomUser().then(($user) => {
|
|
user = $user
|
|
})
|
|
})
|
|
|
|
it('can download file', () => {
|
|
cy.uploadContent(user, new Blob(['<content>']), 'text/plain', '/file.txt')
|
|
cy.login(user)
|
|
cy.visit('/apps/files')
|
|
|
|
getRowForFile('file.txt')
|
|
.should('be.visible')
|
|
.findByRole('button', { name: 'Download' })
|
|
.click()
|
|
|
|
const downloadsFolder = Cypress.config('downloadsFolder')
|
|
cy.readFile(`${downloadsFolder}/file.txt`, { timeout: 15000 })
|
|
.should('exist')
|
|
.and('have.length.gt', 8)
|
|
.and('equal', '<content>')
|
|
})
|
|
|
|
/**
|
|
* Regression test of https://github.com/nextcloud/server/issues/44855
|
|
*/
|
|
it('can download file with hash name', () => {
|
|
cy.uploadContent(user, new Blob(['<content>']), 'text/plain', '/#file.txt')
|
|
cy.login(user)
|
|
cy.visit('/apps/files')
|
|
|
|
getRowForFile('#file.txt')
|
|
.should('be.visible')
|
|
.findByRole('button', { name: 'Download' })
|
|
.click()
|
|
|
|
const downloadsFolder = Cypress.config('downloadsFolder')
|
|
cy.readFile(`${downloadsFolder}/#file.txt`, { timeout: 15000 })
|
|
.should('exist')
|
|
.and('have.length.gt', 8)
|
|
.and('equal', '<content>')
|
|
})
|
|
|
|
/**
|
|
* Regression test of https://github.com/nextcloud/server/issues/44855
|
|
*/
|
|
it('can download file from folder with hash name', () => {
|
|
cy.mkdir(user, '/#folder')
|
|
.uploadContent(user, new Blob(['<content>']), 'text/plain', '/#folder/file.txt')
|
|
cy.login(user)
|
|
cy.visit('/apps/files')
|
|
|
|
navigateToFolder('#folder')
|
|
// All are visible by default
|
|
getRowForFile('file.txt')
|
|
.should('be.visible')
|
|
.findByRole('button', { name: 'Download' })
|
|
.click()
|
|
|
|
const downloadsFolder = Cypress.config('downloadsFolder')
|
|
cy.readFile(`${downloadsFolder}/file.txt`, { timeout: 15000 })
|
|
.should('exist')
|
|
.and('have.length.gt', 8)
|
|
.and('equal', '<content>')
|
|
})
|
|
})
|