2024-08-16 18:17:24 +02:00
|
|
|
/*!
|
|
|
|
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
*/
|
|
|
|
import type { User } from '@nextcloud/cypress'
|
|
|
|
import { createShare } from './FilesSharingUtils.ts'
|
2025-03-13 18:28:32 +01:00
|
|
|
import { closeSidebar, enableGridMode, getActionButtonForFile, getRowForFile } from '../files/FilesUtils.ts'
|
2024-08-16 18:17:24 +02:00
|
|
|
|
2025-03-13 18:28:32 +01:00
|
|
|
describe('files_sharing: Sharing status action', { testIsolation: true }, () => {
|
2024-08-16 18:17:24 +02:00
|
|
|
/**
|
|
|
|
* Regression test of https://github.com/nextcloud/server/issues/45723
|
|
|
|
*/
|
2025-03-13 18:28:32 +01:00
|
|
|
it('No "shared" tag when user ID is purely numerical but there are no shares', () => {
|
2024-08-16 18:17:24 +02:00
|
|
|
const user = {
|
|
|
|
language: 'en',
|
|
|
|
password: 'test1234',
|
|
|
|
userId: String(Math.floor(Math.random() * 1000)),
|
|
|
|
} as User
|
|
|
|
cy.createUser(user)
|
|
|
|
cy.mkdir(user, '/folder')
|
|
|
|
cy.login(user)
|
|
|
|
|
|
|
|
cy.visit('/apps/files')
|
|
|
|
|
|
|
|
getRowForFile('folder')
|
|
|
|
.should('be.visible')
|
|
|
|
.find('[data-cy-files-list-row-actions]')
|
|
|
|
.findByRole('button', { name: 'Shared' })
|
|
|
|
.should('not.exist')
|
|
|
|
})
|
|
|
|
|
2025-03-13 18:28:32 +01:00
|
|
|
it('Render quick option for sharing', () => {
|
|
|
|
cy.createRandomUser().then((user) => {
|
|
|
|
cy.mkdir(user, '/folder')
|
|
|
|
cy.login(user)
|
|
|
|
|
|
|
|
cy.visit('/apps/files')
|
|
|
|
})
|
|
|
|
|
|
|
|
getRowForFile('folder')
|
|
|
|
.should('be.visible')
|
|
|
|
.find('[data-cy-files-list-row-actions]')
|
|
|
|
.findByRole('button', { name: /Show sharing options/ })
|
|
|
|
.should('be.visible')
|
|
|
|
.click()
|
|
|
|
|
|
|
|
// check the click opened the sidebar
|
|
|
|
cy.get('[data-cy-sidebar]')
|
|
|
|
.should('be.visible')
|
|
|
|
// and ensure the sharing tab is selected
|
|
|
|
.findByRole('tab', { name: 'Sharing', selected: true })
|
|
|
|
.should('exist')
|
|
|
|
})
|
|
|
|
|
2024-11-08 11:02:53 +01:00
|
|
|
describe('Sharing inline status action handling', () => {
|
2024-08-16 18:17:24 +02:00
|
|
|
let user: User
|
|
|
|
let sharee: User
|
|
|
|
|
2025-03-13 18:28:32 +01:00
|
|
|
before(() => {
|
2024-08-16 18:17:24 +02:00
|
|
|
cy.createRandomUser().then(($user) => {
|
2025-03-13 18:28:32 +01:00
|
|
|
sharee = $user
|
2024-08-16 18:17:24 +02:00
|
|
|
})
|
|
|
|
cy.createRandomUser().then(($user) => {
|
2025-03-13 18:28:32 +01:00
|
|
|
user = $user
|
|
|
|
cy.mkdir(user, '/folder')
|
|
|
|
cy.login(user)
|
|
|
|
|
|
|
|
cy.visit('/apps/files')
|
|
|
|
getRowForFile('folder').should('be.visible')
|
|
|
|
|
|
|
|
createShare('folder', sharee.userId)
|
|
|
|
closeSidebar()
|
2024-08-16 18:17:24 +02:00
|
|
|
})
|
2025-03-13 18:28:32 +01:00
|
|
|
cy.logout()
|
2024-08-16 18:17:24 +02:00
|
|
|
})
|
|
|
|
|
2025-03-13 18:28:32 +01:00
|
|
|
it('Render inline status action for sharer', () => {
|
2024-08-16 18:17:24 +02:00
|
|
|
cy.login(user)
|
|
|
|
cy.visit('/apps/files')
|
|
|
|
|
|
|
|
getRowForFile('folder')
|
|
|
|
.should('be.visible')
|
|
|
|
.find('[data-cy-files-list-row-actions]')
|
2025-03-13 18:28:32 +01:00
|
|
|
.findByRole('button', { name: /^Shared with/i })
|
2024-08-16 18:17:24 +02:00
|
|
|
.should('be.visible')
|
|
|
|
})
|
|
|
|
|
2025-03-13 18:28:32 +01:00
|
|
|
it('Render status action in gridview for sharer', () => {
|
2024-08-16 18:17:24 +02:00
|
|
|
cy.login(user)
|
|
|
|
cy.visit('/apps/files')
|
2025-03-13 18:28:32 +01:00
|
|
|
enableGridMode()
|
2024-08-16 18:17:24 +02:00
|
|
|
|
|
|
|
getRowForFile('folder')
|
|
|
|
.should('be.visible')
|
2025-03-13 18:28:32 +01:00
|
|
|
getActionButtonForFile('folder')
|
|
|
|
.click()
|
|
|
|
cy.findByRole('menu')
|
|
|
|
.findByRole('menuitem', { name: /shared with/i })
|
2024-08-16 18:17:24 +02:00
|
|
|
.should('be.visible')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Render inline status action for sharee', () => {
|
2025-03-13 18:28:32 +01:00
|
|
|
cy.login(sharee)
|
2024-08-16 18:17:24 +02:00
|
|
|
cy.visit('/apps/files')
|
2025-03-13 18:28:32 +01:00
|
|
|
|
2024-08-16 18:17:24 +02:00
|
|
|
getRowForFile('folder')
|
|
|
|
.should('be.visible')
|
2025-03-13 18:28:32 +01:00
|
|
|
.find('[data-cy-files-list-row-actions]')
|
|
|
|
.findByRole('button', { name: `Shared by ${user.userId}` })
|
|
|
|
.should('be.visible')
|
|
|
|
})
|
2024-08-16 18:17:24 +02:00
|
|
|
|
2025-03-13 18:28:32 +01:00
|
|
|
it('Render status action in grid view for sharee', () => {
|
2024-08-16 18:17:24 +02:00
|
|
|
cy.login(sharee)
|
|
|
|
cy.visit('/apps/files')
|
|
|
|
|
2025-03-13 18:28:32 +01:00
|
|
|
enableGridMode()
|
|
|
|
|
2024-08-16 18:17:24 +02:00
|
|
|
getRowForFile('folder')
|
|
|
|
.should('be.visible')
|
2025-03-13 18:28:32 +01:00
|
|
|
getActionButtonForFile('folder')
|
|
|
|
.click()
|
|
|
|
cy.findByRole('menu')
|
|
|
|
.findByRole('menuitem', { name: `Shared by ${user.userId}` })
|
2024-08-16 18:17:24 +02:00
|
|
|
.should('be.visible')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|