Skip to content

Commit

Permalink
fix(cypress): Show and hide columns
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal committed Aug 2, 2023
1 parent c1f5523 commit 8fa6289
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
28 changes: 28 additions & 0 deletions cypress/e2e/settings/usersUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @copyright 2023 Christopher Ng <[email protected]>
*
* @author Christopher Ng <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

export function assertNotExistOrNotVisible(element: JQuery<HTMLElement>) {
const doesNotExist = element.length === 0
const isNotVisible = !element.is(':visible')

expect(doesNotExist || isNotVisible, 'does not exist or is not visible').to.be.true
}
7 changes: 4 additions & 3 deletions cypress/e2e/settings/users_columns.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

import { User } from '@nextcloud/cypress'
import { assertNotExistOrNotVisible } from './usersUtils.js'

const admin = new User('admin', 'admin')

Expand All @@ -43,7 +44,7 @@ describe('Settings: Show and hide columns', function() {
// close the settings dialog
cy.get('button.modal-container__close').click()
})
cy.waitUntil(() => cy.get('.modal-container').should('not.be.visible'))
cy.waitUntil(() => cy.get('.modal-container').should(el => assertNotExistOrNotVisible(el)))
})

it('Can show a column', function() {
Expand All @@ -68,7 +69,7 @@ describe('Settings: Show and hide columns', function() {
// close the settings dialog
cy.get('button.modal-container__close').click()
})
cy.waitUntil(() => cy.get('.modal-container').should('not.be.visible'))
cy.waitUntil(() => cy.get('.modal-container').should(el => assertNotExistOrNotVisible(el)))

// see that the language column is in the header
cy.get(`.user-list__header tr`).within(() => {
Expand Down Expand Up @@ -103,7 +104,7 @@ describe('Settings: Show and hide columns', function() {
// close the settings dialog
cy.get('button.modal-container__close').click()
})
cy.waitUntil(() => cy.get('.modal-container').should('not.be.visible'))
cy.waitUntil(() => cy.get('.modal-container').should(el => assertNotExistOrNotVisible(el)))

// see that the last login column is not in the header
cy.get(`.user-list__header tr`).within(() => {
Expand Down

0 comments on commit 8fa6289

Please sign in to comment.