1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*!
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { User } from '@nextcloud/cypress'
import { getRowForFile } from '../../files/FilesUtils.ts'
import { createShare, setupData } from './setup-public-share.ts'
describe('files_sharing: Public share - setting the default view mode', () => {
let user: User
beforeEach(() => {
cy.createRandomUser()
.then(($user) => (user = $user))
.then(() => setupData(user, 'shared'))
})
it('is by default in list view', () => {
const context = { user }
createShare(context, 'shared')
.then((url) => {
cy.logout()
cy.visit(url!)
// See file is visible
getRowForFile('foo.txt').should('be.visible')
// See we are in list view
cy.findByRole('button', { name: 'Switch to grid view' })
.should('be.visible')
.and('not.be.disabled')
})
})
it('can be toggled by user', () => {
const context = { user }
createShare(context, 'shared')
.then((url) => {
cy.logout()
cy.visit(url!)
// See file is visible
getRowForFile('foo.txt')
.should('be.visible')
// See we are in list view
.find('.files-list__row-icon')
.should(($el) => expect($el.outerWidth()).to.be.lessThan(99))
// See the grid view toggle
cy.findByRole('button', { name: 'Switch to grid view' })
.should('be.visible')
.and('not.be.disabled')
// And can change to grid view
.click()
// See we are in grid view
getRowForFile('foo.txt')
.find('.files-list__row-icon')
.should(($el) => expect($el.outerWidth()).to.be.greaterThan(99))
// See the grid view toggle is now the list view toggle
cy.findByRole('button', { name: 'Switch to list view' })
.should('be.visible')
.and('not.be.disabled')
})
})
it('can be changed to default grid view', () => {
const context = { user }
createShare(context, 'shared')
.then((url) => {
// Can set the "grid" view checkbox
cy.findByRole('list', { name: 'Link shares' })
.findAllByRole('listitem')
.first()
.findByRole('button', { name: /Actions/i })
.click()
cy.findByRole('menuitem', { name: /Customize link/i }).click()
cy.findByRole('checkbox', { name: /Show files in grid view/i })
.scrollIntoView()
cy.findByRole('checkbox', { name: /Show files in grid view/i })
.should('not.be.checked')
.check({ force: true })
// Wait for the share update
cy.intercept('PUT', '**/ocs/v2.php/apps/files_sharing/api/v1/shares/*').as('updateShare')
cy.findByRole('button', { name: 'Update share' }).click()
cy.wait('@updateShare').its('response.statusCode').should('eq', 200)
// Logout and visit the share
cy.logout()
cy.visit(url!)
// See file is visible
getRowForFile('foo.txt').should('be.visible')
// See we are in list view
cy.findByRole('button', { name: 'Switch to list view' })
.should('be.visible')
.and('not.be.disabled')
})
})
})
|