Skip to content

Commit

Permalink
Merge pull request #1740 from nextcloud/dependabot/npm_and_yarn/fast-…
Browse files Browse the repository at this point in the history
…xml-parser-4.4.1
  • Loading branch information
dependabot[bot] authored Aug 26, 2024
2 parents 75fe5e3 + ca0780b commit ff852b9
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 38 deletions.
3 changes: 1 addition & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ export default defineConfig({
viewportWidth: 1280,
viewportHeight: 720,

// Tries again 2 more times on failure
retries: {
runMode: 2,
runMode: 5,
// do not retry in `cypress open`
openMode: 0,
},
Expand Down
15 changes: 9 additions & 6 deletions cypress/e2e/filesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
*/

export function renameFile(fileName: string, newName: string) {
toggleMenuAction(fileName)
cy.get(`[data-cy-files-list] [data-cy-files-list-row-action="rename"]`).click()
toggleMenuAction(fileName, 'rename')
cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${fileName}"] .files-list__row-rename input`).clear()
cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${fileName}"] .files-list__row-rename input`).type(`${newName}.txt`)
cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${fileName}"] .files-list__row-rename`).submit()
Expand All @@ -28,8 +27,7 @@ export function createFolder (dirName: string) {
}

export function moveFile (fileName: string, dirName: string) {
toggleMenuAction(fileName)
cy.get(`[data-cy-files-list] [data-cy-files-list-row-action="move-copy"]`).click()
toggleMenuAction(fileName, 'move-copy')
cy.get('.file-picker').within(() => {
cy.get(`[data-filename="${dirName}"]`).click()
cy.contains(`Move to ${dirName}`).click()
Expand All @@ -41,14 +39,19 @@ export function getFileListRow(filename: string) {
return cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${CSS.escape(filename)}"]`)
}

export function toggleMenuAction(filename: string) {
export function toggleMenuAction(filename: string, action: 'details'|'favorite'|'move-copy'|'rename') {
getFileListRow(filename)
.find('[data-cy-files-list-row-actions]')
.should('be.visible')

getFileListRow(filename)
.find('[data-cy-files-list-row-actions]')
.findByRole('button', { name: 'Actions' })
.should('be.visible')
.click()

cy.get('[data-cy-files-list-row-action]')
cy.get(`[data-cy-files-list-row-action="${CSS.escape(action)}"]`)
.should('be.visible')
.findByRole('menuitem')
.click()
}
14 changes: 9 additions & 5 deletions cypress/e2e/sidebar.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { createFolder, getFileListRow, goToDir, moveFile, renameFile } from './filesUtils'
import { addComment, addTag, addToFavorites, createPublicShare, removeFromFavorites, showActivityTab } from './sidebarUtils'
import { addComment, addTag, createPublicShare, toggleFavorite, showActivityTab, closeSidebar } from './sidebarUtils'

describe('Check activity listing in the sidebar', { testIsolation: true }, () => {
beforeEach(function() {
Expand All @@ -24,19 +24,22 @@ describe('Check activity listing in the sidebar', { testIsolation: true }, () =>
})

it('Has favorite activity', () => {
addToFavorites('welcome.txt')
toggleFavorite('welcome.txt')
showActivityTab('welcome.txt')
cy.get('.activity-entry').first().should('contains.text', 'Added to favorites')

removeFromFavorites('welcome.txt')
cy.visit('/apps/files')
getFileListRow('welcome.txt').should('be.visible')

toggleFavorite('welcome.txt')
showActivityTab('welcome.txt')
cy.get('.activity-entry').first().should('contains.text', 'Removed from favorites')
})

it('Has share activity', () => {
createPublicShare('welcome.txt')
cy.get('body').contains('Link share created').should('exist')
cy.get('.toast-close').click({ multiple: true })
cy.visit('/apps/files')

showActivityTab('welcome.txt')
cy.get('.activity-entry').first().should('contains.text', 'Shared as public link')
})
Expand All @@ -61,6 +64,7 @@ describe('Check activity listing in the sidebar', { testIsolation: true }, () =>

it('Has tag activity', () => {
addTag('welcome.txt', 'my_tag')
cy.visit('/apps/files')

showActivityTab('welcome.txt')
cy.get('.activity-entry').first().should('contains.text', 'Added system tag')
Expand Down
45 changes: 26 additions & 19 deletions cypress/e2e/sidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ import { toggleMenuAction } from './filesUtils'

function showSidebarForFile(fileName: string) {
closeSidebar()
toggleMenuAction(fileName)
cy.get('[data-cy-files-list-row-action="details"]')
.should('be.visible')
.findByRole('menuitem')
.click()
toggleMenuAction(fileName, 'details')
cy.get('#app-sidebar-vue').should('be.visible')
}

function closeSidebar() {
export function closeSidebar() {
cy.get('body')
.then(($body) => {
if ($body.find('.app-sidebar__close').length !== 0) {
Expand All @@ -27,18 +23,21 @@ function closeSidebar() {

export function showActivityTab(fileName: string) {
showSidebarForFile(fileName)
cy.get('#app-sidebar-vue').contains('Activity').click()
}
cy.get('#app-sidebar-vue')
.findByRole('tab', { name: 'Activity' })
.click()

export function addToFavorites(fileName: string) {
toggleMenuAction(fileName)
cy.get('[data-cy-files-list-row-action="favorite"]').should('contain', 'Add to favorites').click()
cy.get('.toast-close').click()
cy.get('#app-sidebar-vue')
.findByRole('tabpanel', { name: 'Activity' })
.should('be.visible')
}

export function removeFromFavorites(fileName: string) {
toggleMenuAction(fileName)
cy.get('[data-cy-files-list-row-action="favorite"]').should('contain', 'Remove from favorites').click()
export function toggleFavorite(fileName: string) {
cy.intercept('POST', '**/index.php/apps/files/api/v1/files/*').as('setTags')

toggleMenuAction(fileName, 'favorite')
cy.wait('@setTags')

cy.get('.toast-close').click()
}

Expand All @@ -49,11 +48,19 @@ export function removeFromFavorites(fileName: string) {
*/
export function createPublicShare(fileName: string) {
showSidebarForFile(fileName)
cy.get('#app-sidebar-vue').contains('Sharing').click()
cy.get('#app-sidebar-vue')
.findByRole('tab', { name: 'Sharing' })
.click()

cy.intercept('POST', '**/ocs/v2.php/apps/files_sharing/api/v1/shares').as('createShare')

cy.get('#app-sidebar-vue #tab-sharing').should('be.visible')
cy.get('#app-sidebar-vue button.new-share-link').click({ force: true })
cy.get('#app-sidebar-vue .sharing-entry__copy').should('be.visible')
cy.get('#app-sidebar-vue')
.findByRole('tabpanel', { name: 'Sharing' })
.should('be.visible')
.findByRole('button', { name: "Create a new share link" })
.click({ force: true })

cy.wait('@createShare')
closeSidebar()
}

Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ff852b9

Please sign in to comment.