Merge pull request #46973 from nextcloud/backport/46432/stable28

This commit is contained in:
John Molakvoæ 2024-08-02 14:57:07 +02:00 committed by GitHub
commit 6ec72ce81d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 201 additions and 46 deletions

View file

@ -434,6 +434,9 @@ export default defineComponent({
// TODO: preserve selection on browsing?
this.selectionStore.reset()
this.resetSearch()
if (window.OCA.Files.Sidebar?.close) {
window.OCA.Files.Sidebar.close()
}
this.fetchContent()
// Scroll to top, force virtual scroller to re-render

View file

@ -110,7 +110,7 @@ import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
import { File, Folder, formatFileSize } from '@nextcloud/files'
import { encodePath } from '@nextcloud/paths'
import { generateRemoteUrl, generateUrl } from '@nextcloud/router'
import { Type as ShareTypes } from '@nextcloud/sharing'
import { ShareTypes } from '@nextcloud/sharing'
import { mdiStar, mdiStarOutline } from '@mdi/js'
import axios from '@nextcloud/axios'
import $ from 'jquery'

View file

@ -73,12 +73,16 @@ window.addEventListener('DOMContentLoaded', function() {
await TabInstance.update(fileInfo)
TabInstance.$mount(el)
},
update(fileInfo) {
TabInstance.update(fileInfo)
},
destroy() {
TabInstance.$destroy()
TabInstance = null
if (TabInstance) {
TabInstance.$destroy()
TabInstance = null
}
},
}))
}

View file

@ -46,6 +46,8 @@ export default defineConfig({
// Disable session isolation
testIsolation: false,
requestTimeout: 30000,
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
async setupNodeEvents(on, config) {

View file

@ -1,27 +1,11 @@
/**
* @copyright Copyright (c) 2024 Ferdinand Thiessen <opensource@fthiessen.de>
*
* @author Ferdinand Thiessen <opensource@fthiessen.de>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 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 { assertNotExistOrNotVisible } from '../settings/usersUtils'
describe('Files: Sidebar', { testIsolation: true }, () => {
let user: User
@ -43,7 +27,10 @@ describe('Files: Sidebar', { testIsolation: true }, () => {
triggerActionForFile('file', 'details')
cy.get('[data-cy-sidebar]').should('be.visible')
cy.get('[data-cy-sidebar]')
.should('be.visible')
.findByRole('heading', { name: 'file' })
.should('be.visible')
})
it('changes the current fileid', () => {
@ -56,22 +43,63 @@ describe('Files: Sidebar', { testIsolation: true }, () => {
cy.url().should('contain', `apps/files/files/${fileId}`)
})
it('closes the sidebar on delete', () => {
it('changes the sidebar content on other file', () => {
cy.visit('/apps/files')
getRowForFile('file').should('be.visible')
triggerActionForFile('file', 'details')
cy.get('[data-cy-sidebar]')
.should('be.visible')
.findByRole('heading', { name: 'file' })
.should('be.visible')
triggerActionForFile('folder', 'details')
cy.get('[data-cy-sidebar]')
.should('be.visible')
.findByRole('heading', { name: 'folder' })
.should('be.visible')
})
it('closes the sidebar on navigation', () => {
cy.visit('/apps/files')
getRowForFile('file').should('be.visible')
getRowForFile('folder').should('be.visible')
// open the sidebar
triggerActionForFile('file', 'details')
// validate it is open
cy.get('[data-cy-sidebar]').should('be.visible')
// wait for the sidebar to be settled
cy.wait(500)
cy.get('[data-cy-sidebar]')
.should('be.visible')
// if we navigate to the folder
navigateToFolder('folder')
// the sidebar should not be visible anymore
cy.get('[data-cy-sidebar]')
.should(assertNotExistOrNotVisible)
})
it('closes the sidebar on delete', () => {
cy.intercept('DELETE', `**/remote.php/dav/files/${user.userId}/file`).as('deleteFile')
// visit the files app
cy.visit('/apps/files')
getRowForFile('file').should('be.visible')
// open the sidebar
triggerActionForFile('file', 'details')
// validate it is open
cy.get('[data-cy-sidebar]').should('be.visible')
// delete the file
triggerActionForFile('file', 'delete')
cy.get('[data-cy-sidebar]').should('not.exist')
cy.wait('@deleteFile', { timeout: 10000 })
// see the sidebar is closed
cy.get('[data-cy-sidebar]')
.should(assertNotExistOrNotVisible)
})
it('changes the fileid on delete', () => {
cy.intercept('DELETE', `**/remote.php/dav/files/${user.userId}/folder/other`).as('deleteFile')
cy.uploadContent(user, new Blob([]), 'text/plain', '/folder/other').then((response) => {
const otherFileId = Number.parseInt(response.headers['oc-fileid'] ?? '0')
cy.login(user)
@ -86,10 +114,10 @@ describe('Files: Sidebar', { testIsolation: true }, () => {
// validate it is open
cy.get('[data-cy-sidebar]').should('be.visible')
cy.url().should('contain', `apps/files/files/${otherFileId}`)
// wait for the sidebar to be settled
cy.wait(500)
triggerActionForFile('other', 'delete')
cy.wait('@deleteFile')
cy.get('[data-cy-sidebar]').should('not.exist')
// Ensure the URL is changed
cy.url().should('not.contain', `apps/files/files/${otherFileId}`)

View file

@ -27,6 +27,7 @@ import { addCommands, User } from '@nextcloud/cypress'
import { basename } from 'path'
// Add custom commands
import '@testing-library/cypress/add-commands'
import 'cypress-if'
import 'cypress-wait-until'
addCommands()

4
dist/files-main.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

128
package-lock.json generated
View file

@ -103,6 +103,7 @@
"@nextcloud/stylelint-config": "^2.1.2",
"@nextcloud/webpack-vue-config": "^6.0.1",
"@pinia/testing": "^0.1.2",
"@testing-library/cypress": "^10.0.2",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/user-event": "^14.4.3",
"@testing-library/vue": "^5.8.3",
@ -117,7 +118,7 @@
"babel-loader-exclude-node-modules-except": "^1.2.1",
"colord": "^2.9.3",
"css-loader": "^6.8.1",
"cypress": "^13.7.3",
"cypress": "^13.13.2",
"cypress-axe": "^1.5.0",
"cypress-if": "^1.10.5",
"cypress-split": "^1.21.0",
@ -5276,6 +5277,121 @@
"string.prototype.matchall": "^4.0.6"
}
},
"node_modules/@testing-library/cypress": {
"version": "10.0.2",
"resolved": "https://registry.npmjs.org/@testing-library/cypress/-/cypress-10.0.2.tgz",
"integrity": "sha512-dKv95Bre5fDmNb9tOIuWedhGUryxGu1GWYWtXDqUsDPcr9Ekld0fiTb+pcBvSsFpYXAZSpmyEjhoXzLbhh06yQ==",
"dev": true,
"dependencies": {
"@babel/runtime": "^7.14.6",
"@testing-library/dom": "^10.1.0"
},
"engines": {
"node": ">=12",
"npm": ">=6"
},
"peerDependencies": {
"cypress": "^12.0.0 || ^13.0.0"
}
},
"node_modules/@testing-library/cypress/node_modules/@testing-library/dom": {
"version": "10.4.0",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz",
"integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==",
"dev": true,
"dependencies": {
"@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5",
"@types/aria-query": "^5.0.1",
"aria-query": "5.3.0",
"chalk": "^4.1.0",
"dom-accessibility-api": "^0.5.9",
"lz-string": "^1.5.0",
"pretty-format": "^27.0.2"
},
"engines": {
"node": ">=18"
}
},
"node_modules/@testing-library/cypress/node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/@testing-library/cypress/node_modules/aria-query": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz",
"integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
"dev": true,
"dependencies": {
"dequal": "^2.0.3"
}
},
"node_modules/@testing-library/cypress/node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/@testing-library/cypress/node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/@testing-library/cypress/node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"node_modules/@testing-library/cypress/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/@testing-library/cypress/node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/@testing-library/dom": {
"version": "9.3.4",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.4.tgz",
@ -9914,13 +10030,13 @@
"dev": true
},
"node_modules/cypress": {
"version": "13.7.3",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-13.7.3.tgz",
"integrity": "sha512-uoecY6FTCAuIEqLUYkTrxamDBjMHTYak/1O7jtgwboHiTnS1NaMOoR08KcTrbRZFCBvYOiS4tEkQRmsV+xcrag==",
"version": "13.13.2",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-13.13.2.tgz",
"integrity": "sha512-PvJQU33933NvS1StfzEb8/mu2kMy4dABwCF+yd5Bi7Qly1HOVf+Bufrygee/tlmty/6j5lX+KIi8j9Q3JUMbhA==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
"@cypress/request": "^3.0.0",
"@cypress/request": "^3.0.1",
"@cypress/xvfb": "^1.2.4",
"@types/sinonjs__fake-timers": "8.1.1",
"@types/sizzle": "^2.3.2",
@ -9959,7 +10075,7 @@
"request-progress": "^3.0.0",
"semver": "^7.5.3",
"supports-color": "^8.1.1",
"tmp": "~0.2.1",
"tmp": "~0.2.3",
"untildify": "^4.0.0",
"yauzl": "^2.10.0"
},

View file

@ -130,6 +130,7 @@
"@nextcloud/stylelint-config": "^2.1.2",
"@nextcloud/webpack-vue-config": "^6.0.1",
"@pinia/testing": "^0.1.2",
"@testing-library/cypress": "^10.0.2",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/user-event": "^14.4.3",
"@testing-library/vue": "^5.8.3",
@ -144,7 +145,7 @@
"babel-loader-exclude-node-modules-except": "^1.2.1",
"colord": "^2.9.3",
"css-loader": "^6.8.1",
"cypress": "^13.7.3",
"cypress": "^13.13.2",
"cypress-axe": "^1.5.0",
"cypress-if": "^1.10.5",
"cypress-split": "^1.21.0",