Skip to content

Commit 8ab0051

Browse files
committed
test(dav): add e2e tests for availability & absence
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent 41bbe99 commit 8ab0051

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed

cypress/e2e/dav/availability.cy.ts

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { clearState } from '../../support/commonUtils.ts'
7+
8+
describe('Calendar: Availability', { testIsolation: true }, () => {
9+
before(() => {
10+
clearState()
11+
})
12+
13+
it('User can see the availability section in settings', () => {
14+
cy.createRandomUser().then(($user) => {
15+
cy.login($user)
16+
cy.visit('/settings/user')
17+
})
18+
19+
// can see the section
20+
cy.findAllByRole('link', { name: /Availability/ })
21+
.should('be.visible')
22+
.click()
23+
24+
cy.url().should('match', /settings\/user\/availability$/)
25+
cy.findByRole('heading', { name: /Availability/, level: 2 })
26+
.should('be.visible')
27+
})
28+
29+
it('Users can set their availability status', () => {
30+
cy.createRandomUser().then(($user) => {
31+
cy.login($user)
32+
cy.visit('/settings/user/availability')
33+
})
34+
35+
// can see the settings
36+
cy.findByRole('list', { name: 'Weekdays' })
37+
.should('be.visible')
38+
.within(() => {
39+
cy.contains('li', 'Friday')
40+
.should('be.visible')
41+
.should('contain.text', 'No working hours set')
42+
.as('fridayItem')
43+
.findByRole('button', { name: 'Add slot' })
44+
.click()
45+
})
46+
47+
cy.get('@fridayItem')
48+
.findByLabelText(/start time/i)
49+
.type('09:00')
50+
51+
cy.get('@fridayItem')
52+
.findByLabelText(/end time/i)
53+
.type('18:00')
54+
55+
cy.intercept('PROPPATCH', '**/remote.php/dav/calendars/*/inbox').as('saveAvailability')
56+
cy.get('#availability')
57+
.findByRole('button', { name: 'Save' })
58+
.click()
59+
cy.wait('@saveAvailability')
60+
61+
cy.reload()
62+
63+
cy.findByRole('list', { name: 'Weekdays' })
64+
.should('be.visible')
65+
.within(() => {
66+
cy.contains('li', 'Friday')
67+
.should('be.visible')
68+
.should('not.contain.text', 'No working hours set')
69+
})
70+
})
71+
72+
it('Users can set their absence', () => {
73+
cy.createUser({ language: 'en', password: 'password', userId: 'replacement-user' })
74+
cy.createRandomUser().then(($user) => {
75+
cy.login($user)
76+
cy.visit('/settings/user/availability')
77+
})
78+
79+
cy.findByRole('heading', { name: /absence/i }).scrollIntoView()
80+
81+
cy.findByLabelText(/First day/)
82+
.should('be.visible')
83+
.type('2024-12-24')
84+
85+
cy.findByLabelText(/Last day/)
86+
.should('be.visible')
87+
.type('2024-12-28')
88+
89+
cy.findByRole('textbox', { name: /Short absence/ })
90+
.should('be.visible')
91+
.type('Vacation')
92+
cy.findByRole('textbox', { name: /Long absence/ })
93+
.should('be.visible')
94+
.type('Happy holidays!')
95+
96+
cy.intercept('GET', '**/ocs/v2.php/apps/files_sharing/api/v1/sharees?*search=replacement*').as('userSearch')
97+
cy.findByRole('searchbox')
98+
.should('be.visible')
99+
.as('userSearchBox')
100+
.click()
101+
cy.get('@userSearchBox')
102+
.type('replacement')
103+
cy.wait('@userSearch')
104+
105+
cy.findByRole('option', { name: 'replacement-user' })
106+
.click()
107+
108+
cy.intercept('POST', '**/ocs/v2.php/apps/dav/api/v1/outOfOffice/*').as('saveAbsence')
109+
cy.get('#absence')
110+
.findByRole('button', { name: 'Save' })
111+
.click()
112+
cy.wait('@saveAbsence')
113+
114+
cy.reload()
115+
116+
// see its saved
117+
cy.findByLabelText(/First day/)
118+
.should('have.value', '2024-12-24')
119+
cy.findByLabelText(/Last day/)
120+
.should('have.value', '2024-12-28')
121+
cy.findByRole('textbox', { name: /Short absence/ })
122+
.should('have.value', 'Vacation')
123+
cy.findByRole('textbox', { name: /Long absence/ })
124+
.should('have.value', 'Happy holidays!')
125+
cy.findByRole('combobox')
126+
.should('contain.text', 'replacement-user')
127+
})
128+
})

0 commit comments

Comments
 (0)