|
|
|
|
@ -15,65 +15,63 @@ 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' })
|
|
|
|
|
|
|
|
|
|
const searchForActionInRow = (row: JQuery<HTMLElement>, actionId: string): Cypress.Chainable<JQuery<HTMLElement>> => {
|
|
|
|
|
const action = row.find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
|
|
|
|
|
if (action.length > 0) {
|
|
|
|
|
cy.log('Found action in row')
|
|
|
|
|
return cy.wrap(action)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Else look in the action menu
|
|
|
|
|
const menuButtonId = row.find('button[aria-controls]').attr('aria-controls')
|
|
|
|
|
if (menuButtonId === undefined) {
|
|
|
|
|
return cy.wrap(Cypress.$())
|
|
|
|
|
}
|
|
|
|
|
export const getActionEntryForFileId = (fileid: number, actionId: string) => {
|
|
|
|
|
return getActionButtonForFileId(fileid)
|
|
|
|
|
.should('have.attr', 'aria-controls')
|
|
|
|
|
.then((menuId) => cy.get(`#${menuId}`).find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-unused-expressions
|
|
|
|
|
expect(menuButtonId).not.to.be.undefined
|
|
|
|
|
return cy.get(`#${menuButtonId} [data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
|
|
|
|
|
export const getActionEntryForFile = (file: string, actionId: string) => {
|
|
|
|
|
return getActionButtonForFile(file)
|
|
|
|
|
.should('have.attr', 'aria-controls')
|
|
|
|
|
.then((menuId) => cy.get(`#${menuId}`).find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getActionEntryForFileId = (fileid: number, actionId: string): Cypress.Chainable<JQuery<HTMLElement>> => {
|
|
|
|
|
// If we cannot find the action in the row, it might be in the action menu
|
|
|
|
|
return getRowForFileId(fileid).should('be.visible')
|
|
|
|
|
.then((row) => searchForActionInRow(row, actionId))
|
|
|
|
|
export const getInlineActionEntryForFileId = (fileid: number, actionId: string) => {
|
|
|
|
|
return getActionsForFileId(fileid)
|
|
|
|
|
.find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
|
|
|
|
|
}
|
|
|
|
|
export const getActionEntryForFile = (filename: string, actionId: string): Cypress.Chainable<JQuery<HTMLElement>> => {
|
|
|
|
|
// If we cannot find the action in the row, it might be in the action menu
|
|
|
|
|
return getRowForFile(filename).should('be.visible')
|
|
|
|
|
.then((row) => searchForActionInRow(row, actionId))
|
|
|
|
|
|
|
|
|
|
export const getInlineActionEntryForFile = (file: string, actionId: string) => {
|
|
|
|
|
return getActionsForFile(file)
|
|
|
|
|
.find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const triggerActionForFileId = (fileid: number, actionId: string) => {
|
|
|
|
|
// Even if it's inline, we open the action menu to get all actions visible
|
|
|
|
|
getActionButtonForFileId(fileid).click({ force: true })
|
|
|
|
|
// wait for the actions menu to be visible
|
|
|
|
|
cy.findByRole('menu').findAllByRole('menuitem').first().should('be.visible')
|
|
|
|
|
getActionEntryForFileId(fileid, actionId)
|
|
|
|
|
.find('button').last().as('actionButton')
|
|
|
|
|
getActionButtonForFileId(fileid)
|
|
|
|
|
.as('actionButton')
|
|
|
|
|
.scrollIntoView()
|
|
|
|
|
cy.get('@actionButton')
|
|
|
|
|
.click({ force: true }) // force to avoid issues with overlaying file list header
|
|
|
|
|
getActionEntryForFileId(fileid, actionId)
|
|
|
|
|
.find('button')
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.click({ force: true })
|
|
|
|
|
.click()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const triggerActionForFile = (filename: string, actionId: string) => {
|
|
|
|
|
// Even if it's inline, we open the action menu to get all actions visible
|
|
|
|
|
getActionButtonForFile(filename).click({ force: true })
|
|
|
|
|
// wait for the actions menu to be visible
|
|
|
|
|
cy.findByRole('menu').findAllByRole('menuitem').first().should('be.visible')
|
|
|
|
|
getActionEntryForFile(filename, actionId)
|
|
|
|
|
.find('button').last().as('actionButton')
|
|
|
|
|
getActionButtonForFile(filename)
|
|
|
|
|
.as('actionButton')
|
|
|
|
|
.scrollIntoView()
|
|
|
|
|
cy.get('@actionButton')
|
|
|
|
|
.click({ force: true }) // force to avoid issues with overlaying file list header
|
|
|
|
|
getActionEntryForFile(filename, actionId)
|
|
|
|
|
.find('button')
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.click({ force: true })
|
|
|
|
|
.click()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const triggerInlineActionForFileId = (fileid: number, actionId: string) => {
|
|
|
|
|
getActionsForFileId(fileid).find(`button[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`).should('exist').click()
|
|
|
|
|
getActionsForFileId(fileid)
|
|
|
|
|
.find(`button[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
|
|
|
|
|
.should('exist')
|
|
|
|
|
.click()
|
|
|
|
|
}
|
|
|
|
|
export const triggerInlineActionForFile = (filename: string, actionId: string) => {
|
|
|
|
|
getActionsForFile(filename).find(`button[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`).should('exist').click()
|
|
|
|
|
getActionsForFile(filename)
|
|
|
|
|
.find(`button[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
|
|
|
|
|
.should('exist')
|
|
|
|
|
.click()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const selectAllFiles = () => {
|
|
|
|
|
@ -176,12 +174,17 @@ export const copyFile = (fileName: string, dirPath: string) => {
|
|
|
|
|
|
|
|
|
|
export const renameFile = (fileName: string, newFileName: string) => {
|
|
|
|
|
getRowForFile(fileName)
|
|
|
|
|
.should('exist')
|
|
|
|
|
.scrollIntoView()
|
|
|
|
|
|
|
|
|
|
triggerActionForFile(fileName, 'rename')
|
|
|
|
|
|
|
|
|
|
// intercept the move so we can wait for it
|
|
|
|
|
cy.intercept('MOVE', /\/(remote|public)\.php\/dav\/files\//).as('moveFile')
|
|
|
|
|
|
|
|
|
|
getRowForFile(fileName).find('[data-cy-files-list-row-name] input').type(`{selectAll}${newFileName}{enter}`)
|
|
|
|
|
getRowForFile(fileName)
|
|
|
|
|
.find('[data-cy-files-list-row-name] input')
|
|
|
|
|
.type(`{selectAll}${newFileName}{enter}`)
|
|
|
|
|
|
|
|
|
|
cy.wait('@moveFile')
|
|
|
|
|
}
|
|
|
|
|
|