|
| 1 | +/*! |
| 2 | + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + */ |
| 5 | +import type { User } from '@nextcloud/cypress' |
| 6 | +import { createShare } from './FilesSharingUtils.ts' |
| 7 | +import { closeSidebar, getRowForFile } from '../files/FilesUtils.ts' |
| 8 | + |
| 9 | +describe('files_sharing: Files inline status action', { testIsolation: true }, () => { |
| 10 | + /** |
| 11 | + * Regression test of https://github.com/nextcloud/server/issues/45723 |
| 12 | + */ |
| 13 | + it('No "shared" tag when user ID is purely numerical', () => { |
| 14 | + const user = { |
| 15 | + language: 'en', |
| 16 | + password: 'test1234', |
| 17 | + userId: String(Math.floor(Math.random() * 1000)), |
| 18 | + } as User |
| 19 | + cy.createUser(user) |
| 20 | + cy.mkdir(user, '/folder') |
| 21 | + cy.login(user) |
| 22 | + |
| 23 | + cy.visit('/apps/files') |
| 24 | + |
| 25 | + getRowForFile('folder') |
| 26 | + .should('be.visible') |
| 27 | + .find('[data-cy-files-list-row-actions]') |
| 28 | + .findByRole('button', { name: 'Shared' }) |
| 29 | + .should('not.exist') |
| 30 | + }) |
| 31 | + |
| 32 | + describe('', () => { |
| 33 | + let user: User |
| 34 | + let sharee: User |
| 35 | + |
| 36 | + beforeEach(() => { |
| 37 | + cy.createRandomUser().then(($user) => { |
| 38 | + user = $user |
| 39 | + }) |
| 40 | + cy.createRandomUser().then(($user) => { |
| 41 | + sharee = $user |
| 42 | + }) |
| 43 | + }) |
| 44 | + |
| 45 | + it('Render quick option for sharing', () => { |
| 46 | + cy.mkdir(user, '/folder') |
| 47 | + cy.login(user) |
| 48 | + |
| 49 | + cy.visit('/apps/files') |
| 50 | + getRowForFile('folder') |
| 51 | + .should('be.visible') |
| 52 | + |
| 53 | + getRowForFile('folder') |
| 54 | + .should('be.visible') |
| 55 | + .find('[data-cy-files-list-row-actions]') |
| 56 | + .findByRole('button', { name: /Show sharing options/ }) |
| 57 | + .should('be.visible') |
| 58 | + .click() |
| 59 | + |
| 60 | + // check the click opened the sidebar |
| 61 | + cy.get('[data-cy-sidebar]') |
| 62 | + .should('be.visible') |
| 63 | + // and ensure the sharing tab is selected |
| 64 | + .findByRole('tab', { name: 'Sharing', selected: true }) |
| 65 | + .should('exist') |
| 66 | + }) |
| 67 | + |
| 68 | + it('Render inline status action for sharer', () => { |
| 69 | + cy.mkdir(user, '/folder') |
| 70 | + cy.login(user) |
| 71 | + |
| 72 | + cy.visit('/apps/files') |
| 73 | + getRowForFile('folder') |
| 74 | + .should('be.visible') |
| 75 | + createShare('folder', sharee.userId) |
| 76 | + closeSidebar() |
| 77 | + |
| 78 | + getRowForFile('folder') |
| 79 | + .should('be.visible') |
| 80 | + .find('[data-cy-files-list-row-actions]') |
| 81 | + .findByRole('button', { name: 'Shared' }) |
| 82 | + .should('be.visible') |
| 83 | + }) |
| 84 | + |
| 85 | + it('Render inline status action for sharee', () => { |
| 86 | + cy.mkdir(user, '/folder') |
| 87 | + cy.login(user) |
| 88 | + |
| 89 | + cy.visit('/apps/files') |
| 90 | + getRowForFile('folder') |
| 91 | + .should('be.visible') |
| 92 | + createShare('folder', sharee.userId) |
| 93 | + closeSidebar() |
| 94 | + |
| 95 | + cy.login(sharee) |
| 96 | + cy.visit('/apps/files') |
| 97 | + |
| 98 | + getRowForFile('folder') |
| 99 | + .should('be.visible') |
| 100 | + .find('[data-cy-files-list-row-actions]') |
| 101 | + .findByRole('button', { name: `Shared by ${user.userId}` }) |
| 102 | + .should('be.visible') |
| 103 | + }) |
| 104 | + }) |
| 105 | +}) |
0 commit comments