Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
20 changes: 0 additions & 20 deletions .eslintrc.js

This file was deleted.

6 changes: 6 additions & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,9 @@ path = ["openapi.json", "src/types/openapi/openapi.ts"]
precedence = "aggregate"
SPDX-FileCopyrightText = "2024 Nextcloud GmbH and Nextcloud contributors"
SPDX-License-Identifier = "AGPL-3.0-or-later"

[[annotations]]
path = ["eslint-suppressions.json"]
precedence = "aggregate"
SPDX-FileCopyrightText = "2025 Nextcloud GmbH and Nextcloud contributors"
SPDX-License-Identifier = "AGPL-3.0-or-later"
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
const babelConfig = require('@nextcloud/babel-config')
babelConfig.presets.push('@babel/preset-typescript')

module.exports = babelConfig
2 changes: 2 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { configureNextcloud, startNextcloud, stopNextcloud, waitOnNextcloud } from '@nextcloud/cypress/docker'
import { defineConfig } from 'cypress'
import cypressSplit from 'cypress-split'
import vitePreprocessor from 'cypress-vite'

export default defineConfig({
projectId: 'xcmgay',
Expand Down Expand Up @@ -40,6 +41,7 @@ export default defineConfig({
// You may want to clean this up later by importing these.
async setupNodeEvents(on, config) {
cypressSplit(on, config)
on('file:preprocessor', vitePreprocessor())

// Remove container after run
on('after:run', () => {
Expand Down
15 changes: 0 additions & 15 deletions cypress/.eslintrc.js

This file was deleted.

19 changes: 9 additions & 10 deletions cypress/e2e/encryption.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { User } from '@nextcloud/cypress'

import { randHash } from '../utils/index.js'
import { getRowForFile, moveFile, triggerActionForFile } from './files/filesUtils.ts'
import {
addUserToGroup,
createGroup,
Expand All @@ -20,15 +25,9 @@ import {
PERMISSION_DELETE,
PERMISSION_READ,
PERMISSION_WRITE,
} from './groupfoldersUtils'

import { getRowForFile, moveFile, triggerActionForFile } from './files/filesUtils'

import { randHash } from '../utils'

import type { User } from '@nextcloud/cypress'
} from './groupfoldersUtils.ts'

export const assertFileContent = (fileName: string, expectedContent: string) => {
export function assertFileContent(fileName: string, expectedContent: string) {
cy.intercept({ method: 'GET', times: 1, url: 'remote.php/**' }).as('downloadFile')
getRowForFile(fileName).should('be.visible')
triggerActionForFile(fileName, 'download')
Expand All @@ -38,7 +37,7 @@ export const assertFileContent = (fileName: string, expectedContent: string) =>

describe('Groupfolders encryption behavior', () => {
let user1: User
let groupFolderId: string
let groupFolderId: string | undefined
let groupName: string
let groupFolderName: string

Expand All @@ -55,7 +54,7 @@ describe('Groupfolders encryption behavior', () => {
groupFolderName = `test_group_folder_${randHash()}`

cy.createRandomUser()
.then(_user => {
.then((_user) => {
user1 = _user
})
createGroup(groupName)
Expand Down
39 changes: 19 additions & 20 deletions cypress/e2e/files/filesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,38 @@ export const getActionsForFile = (filename: string) => getRowForFile(filename).f
export const getActionButtonForFileId = (fileid: number) => getActionsForFileId(fileid).findByRole('button', { name: 'Actions' })
export const getActionButtonForFile = (filename: string) => getActionsForFile(filename).findByRole('button', { name: 'Actions' })

export const triggerActionForFileId = (fileid: number, actionId: string) => {
export function triggerActionForFileId(fileid: number, actionId: string) {
getActionButtonForFileId(fileid).click()
// Getting the last button to avoid the one from popup fading out
cy.get(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"] > button`).last()
.should('exist').click()
}
export const triggerActionForFile = (filename: string, actionId: string) => {
export function triggerActionForFile(filename: string, actionId: string) {
getActionButtonForFile(filename).click()
// Getting the last button to avoid the one from popup fading out
cy.get(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"] > button`).last()
.should('exist').click()
}

export const triggerInlineActionForFileId = (fileid: number, actionId: string) => {
export function triggerInlineActionForFileId(fileid: number, actionId: string) {
getActionsForFileId(fileid).find(`button[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`).should('exist').click()
}
export const triggerInlineActionForFile = (filename: string, actionId: string) => {
export function triggerInlineActionForFile(filename: string, actionId: string) {
getActionsForFile(filename).get(`button[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`).should('exist').click()
}

export const selectAllFiles = () => {
export function selectAllFiles() {
cy.get('[data-cy-files-list-selection-checkbox]')
.findByRole('checkbox', { checked: false })
.click({ force: true })
}
export const deselectAllFiles = () => {
export function deselectAllFiles() {
cy.get('[data-cy-files-list-selection-checkbox]')
.findByRole('checkbox', { checked: true })
.click({ force: true })
}

export const selectRowForFile = (filename: string, options: Partial<Cypress.ClickOptions> = {}) => {
export function selectRowForFile(filename: string, options: Partial<Cypress.ClickOptions> = {}) {
getRowForFile(filename)
.find('[data-cy-files-list-row-checkbox]')
.findByRole('checkbox')
Expand All @@ -53,14 +53,13 @@ export const selectRowForFile = (filename: string, options: Partial<Cypress.Clic
cy.get('[data-cy-files-list-selection-checkbox]').findByRole('checkbox').should('satisfy', (elements) => {
return elements.length === 1 && (elements[0].checked === true || elements[0].indeterminate === true)
})

}

export const triggerSelectionAction = (actionId: string) => {
export function triggerSelectionAction(actionId: string) {
cy.get(`button[data-cy-files-list-selection-action="${CSS.escape(actionId)}"]`).should('exist').click()
}

export const moveFile = (fileName: string, dirPath: string) => {
export function moveFile(fileName: string, dirPath: string) {
getRowForFile(fileName).should('be.visible')
triggerActionForFile(fileName, 'move-copy')

Expand Down Expand Up @@ -95,7 +94,7 @@ export const moveFile = (fileName: string, dirPath: string) => {
})
}

export const copyFile = (fileName: string, dirPath: string) => {
export function copyFile(fileName: string, dirPath: string) {
getRowForFile(fileName).should('be.visible')
triggerActionForFile(fileName, 'move-copy')

Expand Down Expand Up @@ -130,7 +129,7 @@ export const copyFile = (fileName: string, dirPath: string) => {
})
}

export const renameFile = (fileName: string, newFileName: string) => {
export function renameFile(fileName: string, newFileName: string) {
getRowForFile(fileName)
triggerActionForFile(fileName, 'rename')

Expand All @@ -143,7 +142,7 @@ export const renameFile = (fileName: string, newFileName: string) => {
cy.wait('@moveFile')
}

export const createShare = (fileName: string, username: string) => {
export function createShare(fileName: string, username: string) {
openSharingPanel(fileName)

cy.get('#app-sidebar-vue').within(() => {
Expand All @@ -160,34 +159,33 @@ export const createShare = (fileName: string, username: string) => {
cy.wait('@saveShare')
}

export const openSharingPanel = (fileName: string) => {
export function openSharingPanel(fileName: string) {
triggerActionForFile(fileName, 'details')

cy.get('#app-sidebar-vue')
.get('[aria-controls="tab-sharing"]')
.click()
}

export const navigateToFolder = (dirPath: string) => {
export function navigateToFolder(dirPath: string) {
const directories = dirPath.split('/')
directories.forEach((directory) => {
getRowForFile(directory).should('be.visible').find('[data-cy-files-list-row-name-link]').click({ force: true })
})

}

export const closeSidebar = () => {
export function closeSidebar() {
// {force: true} as it might be hidden behind toasts
cy.get('[data-cy-sidebar] .app-sidebar__close').click({ force: true })
}

export const clickOnBreadcrumbs = (label: string) => {
export function clickOnBreadcrumbs(label: string) {
cy.intercept('PROPFIND', /\/remote.php\/dav\//).as('propfind')
cy.get('[data-cy-files-content-breadcrumbs]').contains(label).click()
cy.wait('@propfind')
}

export const createFolder = (folderName: string) => {
export function createFolder(folderName: string) {
cy.intercept('MKCOL', /\/remote.php\/dav\/files\//).as('createFolder')

// TODO: replace by proper data-cy selectors
Expand All @@ -204,14 +202,15 @@ export const createFolder = (folderName: string) => {

/**
* Check validity of an input element
*
* @param validity The expected validity message (empty string means it is valid)
* @example
* ```js
* cy.findByRole('textbox')
* .should(haveValidity(/must not be empty/i))
* ```
*/
export const haveValidity = (validity: string | RegExp) => {
export function haveValidity(validity: string | RegExp) {
if (typeof validity === 'string') {
return (el: JQuery<HTMLElement>) => expect((el.get(0) as HTMLInputElement).validationMessage).to.equal(validity)
}
Expand Down
15 changes: 9 additions & 6 deletions cypress/e2e/files_versions/filesVersionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
/* eslint-disable jsdoc/require-jsdoc */

import type { User } from '@nextcloud/cypress'
import { addUserToGroup, createGroup, createGroupFolder, PERMISSION_DELETE, PERMISSION_READ, PERMISSION_WRITE } from '../groupfoldersUtils'
import { navigateToFolder } from '../files/filesUtils'

import { navigateToFolder } from '../files/filesUtils.ts'
import { addUserToGroup, createGroup, createGroupFolder, PERMISSION_DELETE, PERMISSION_READ, PERMISSION_WRITE } from '../groupfoldersUtils.ts'

type SetupInfo = {
dataSnapshot: string
Expand All @@ -31,7 +32,9 @@ export function setupFilesVersions(): Cypress.Chainable<SetupInfo> {
setupInfo.fileName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
setupInfo.filePath = `${setupInfo.groupFolderName}/${setupInfo.fileName}`

cy.createRandomUser().then(_user => { setupInfo.user = _user })
cy.createRandomUser().then((_user) => {
setupInfo.user = _user
})
createGroup(setupInfo.groupName)

cy.then(() => {
Expand All @@ -55,7 +58,7 @@ export function setupFilesVersions(): Cypress.Chainable<SetupInfo> {
})
}

export const uploadThreeVersions = (user: User, fileName: string) => {
export function uploadThreeVersions(user: User, fileName: string) {
// A new version will not be created if the changes occur
// within less than one second of each other.
// eslint-disable-next-line cypress/no-unnecessary-waiting
Expand All @@ -72,7 +75,7 @@ export function openVersionsPanel(fileName: string) {
cy.intercept({ method: 'PROPFIND', times: 1, url: '**/dav/versions/*/versions/**' }).as('getVersions')

// Open the versions tab
cy.window().then(win => {
cy.window().then((win) => {
win.OCA.Files.Sidebar.setActiveTab('version_vue')
win.OCA.Files.Sidebar.open(`/${fileName}`)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/files_versions/version_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { setupFilesVersions } from './filesVersionsUtils'
import { setupFilesVersions } from './filesVersionsUtils.ts'

describe('Versions creation', () => {
beforeEach(() => {
Expand Down
12 changes: 7 additions & 5 deletions cypress/e2e/files_versions/version_cross_storage_move.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import type { User } from '@nextcloud/cypress'

import { PERMISSION_DELETE, PERMISSION_READ, PERMISSION_WRITE, addUserToGroup, createGroup, createGroupFolder } from '../groupfoldersUtils'
import { assertVersionContent, nameVersion, openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils'
import { closeSidebar, copyFile, moveFile, navigateToFolder } from '../files/filesUtils'
import { closeSidebar, copyFile, moveFile, navigateToFolder } from '../files/filesUtils.ts'
import { addUserToGroup, createGroup, createGroupFolder, PERMISSION_DELETE, PERMISSION_READ, PERMISSION_WRITE } from '../groupfoldersUtils.ts'
import { assertVersionContent, nameVersion, openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils.ts'

export const clickOnBreadcumbs = (label: string) => {
export function clickOnBreadcumbs(label: string) {
cy.intercept({ method: 'PROPFIND', url: /\/remote.php\/dav\// }).as('propfind')
cy.get('[data-cy-files-content-breadcrumbs]').contains(label).click()
cy.wait('@propfind')
Expand Down Expand Up @@ -49,7 +49,9 @@ describe('Versions cross storage move', () => {
randomGroupName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10)
randomGroupFolderName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10)

cy.createRandomUser().then(_user => { user = _user })
cy.createRandomUser().then((_user) => {
user = _user
})
createGroup(randomGroupName)

cy.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/files_versions/version_deletion.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { deleteVersion, setupFilesVersions } from './filesVersionsUtils'
import { deleteVersion, setupFilesVersions } from './filesVersionsUtils.ts'

describe('Versions restoration', () => {
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/files_versions/version_download.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { assertVersionContent, setupFilesVersions } from './filesVersionsUtils'
import { assertVersionContent, setupFilesVersions } from './filesVersionsUtils.ts'

describe('Versions download', () => {
beforeEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/files_versions/version_expiration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { closeSidebar } from '../files/filesUtils'
import { assertVersionContent, nameVersion, openVersionsPanel, setupFilesVersions } from './filesVersionsUtils'
import { closeSidebar } from '../files/filesUtils.ts'
import { assertVersionContent, nameVersion, openVersionsPanel, setupFilesVersions } from './filesVersionsUtils.ts'

describe('Versions expiration', () => {
let randomFilePath: string
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/files_versions/version_naming.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { nameVersion, setupFilesVersions } from './filesVersionsUtils'
import { nameVersion, setupFilesVersions } from './filesVersionsUtils.ts'

describe('Versions naming', () => {
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/files_versions/version_restoration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { assertVersionContent, doesNotHaveAction, restoreVersion, setupFilesVersions } from './filesVersionsUtils'
import { assertVersionContent, doesNotHaveAction, restoreVersion, setupFilesVersions } from './filesVersionsUtils.ts'

describe('Versions restoration', () => {
before(() => {
Expand Down
Loading
Loading