Skip to content

Commit 803d17c

Browse files
committed
test(cypress): harden assertions
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent ac6ca13 commit 803d17c

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

cypress/e2e/files/FilesUtils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export function triggerActionForFile(filename: string, actionId: string) {
8686
.as('actionButton')
8787
.scrollIntoView()
8888
cy.get('@actionButton')
89+
.should('have.attr', 'aria-expanded', 'false')
8990
.click({ force: true }) // force to avoid issues with overlaying file list header
9091
getActionEntryForFile(filename, actionId)
9192
.find('button')
@@ -287,7 +288,10 @@ export function navigateToFolder(dirPath: string) {
287288
export function closeSidebar() {
288289
// {force: true} as it might be hidden behind toasts
289290
cy.get('[data-cy-sidebar] .app-sidebar__close').click({ force: true })
290-
cy.get('[data-cy-sidebar]').should('not.be.visible')
291+
cy.get('[data-cy-sidebar]')
292+
.should('not.be.visible')
293+
// eslint-disable-next-line cypress/no-unnecessary-waiting -- wait for the animation to finish
294+
cy.wait(300)
291295
}
292296

293297
/**

cypress/e2e/files_sharing/FilesSharingUtils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import { triggerActionForFile } from '../files/FilesUtils.ts'
6+
import { closeSidebar, triggerActionForFile } from '../files/FilesUtils.ts'
77

88
export interface ShareSetting {
99
read: boolean
@@ -18,6 +18,7 @@ export interface ShareSetting {
1818

1919
export function createShare(fileName: string, username: string, shareSettings: Partial<ShareSetting> = {}) {
2020
openSharingPanel(fileName)
21+
cy.intercept('POST', '**/ocs/v2.php/apps/files_sharing/api/v1/shares').as('createShare')
2122

2223
cy.get('#app-sidebar-vue').within(() => {
2324
cy.intercept({ times: 1, method: 'GET', url: '**/apps/files_sharing/api/v1/sharees?*' }).as('userSearch')
@@ -30,6 +31,9 @@ export function createShare(fileName: string, username: string, shareSettings: P
3031

3132
// HACK: Save the share and then update it, as permissions changes are currently not saved for new share.
3233
cy.get('[data-cy-files-sharing-share-editor-action="save"]').click({ scrollBehavior: 'nearest' })
34+
cy.wait('@createShare')
35+
36+
closeSidebar()
3337
updateShare(fileName, 0, shareSettings)
3438
}
3539

cypress/e2e/files_sharing/limit_to_same_group.cy.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ describe('Limit to sharing to people in the same group', () => {
2929
cy.createRandomUser()
3030
.then((user) => {
3131
alice = user
32-
cy.createRandomUser()
3332
})
33+
cy.createRandomUser()
3434
.then((user) => {
3535
bob = user
3636

@@ -49,9 +49,12 @@ describe('Limit to sharing to people in the same group', () => {
4949
cy.login(alice)
5050
cy.visit('/apps/files')
5151
createShare(randomFileName1, bob.userId)
52+
cy.logout()
53+
5254
cy.login(bob)
5355
cy.visit('/apps/files')
5456
createShare(randomFileName2, alice.userId)
57+
cy.logout()
5558
})
5659
})
5760

0 commit comments

Comments
 (0)