1
0

users_columns.cy.ts 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: AGPL-3.0-or-later
  4. */
  5. import { User } from '@nextcloud/cypress'
  6. import { assertNotExistOrNotVisible, getUserList } from './usersUtils.js'
  7. const admin = new User('admin', 'admin')
  8. describe('Settings: Show and hide columns', function() {
  9. before(function() {
  10. cy.login(admin)
  11. // open the User settings
  12. cy.visit('/settings/users')
  13. })
  14. beforeEach(function() {
  15. // open the settings dialog
  16. cy.contains('button', 'Account management settings').click()
  17. // reset all visibility toggles
  18. cy.get('.modal-container #settings-section_visibility-settings input[type="checkbox"]').uncheck({ force: true })
  19. cy.contains('.modal-container', 'Account management settings').within(() => {
  20. // enable the last login toggle
  21. cy.get('[data-test="showLastLogin"] input[type="checkbox"]').check({ force: true })
  22. // close the settings dialog
  23. cy.get('button.modal-container__close').click()
  24. })
  25. cy.waitUntil(() => cy.get('.modal-container').should(el => assertNotExistOrNotVisible(el)))
  26. })
  27. it('Can show a column', function() {
  28. // see that the language column is not in the header
  29. cy.get('[data-cy-user-list-header-languages]').should('not.exist')
  30. // see that the language column is not in all user rows
  31. cy.get('tbody.user-list__body tr').each(($row) => {
  32. cy.wrap($row).get('[data-test="language"]').should('not.exist')
  33. })
  34. // open the settings dialog
  35. cy.contains('button', 'Account management settings').click()
  36. cy.contains('.modal-container', 'Account management settings').within(() => {
  37. // enable the language toggle
  38. cy.get('[data-test="showLanguages"] input[type="checkbox"]').should('not.be.checked')
  39. cy.get('[data-test="showLanguages"] input[type="checkbox"]').check({ force: true })
  40. cy.get('[data-test="showLanguages"] input[type="checkbox"]').should('be.checked')
  41. // close the settings dialog
  42. cy.get('button.modal-container__close').click()
  43. })
  44. cy.waitUntil(() => cy.get('.modal-container').should(el => assertNotExistOrNotVisible(el)))
  45. // see that the language column is in the header
  46. cy.get('[data-cy-user-list-header-languages]').should('exist')
  47. // see that the language column is in all user rows
  48. getUserList().find('tbody tr').each(($row) => {
  49. cy.wrap($row).get('[data-cy-user-list-cell-language]').should('exist')
  50. })
  51. })
  52. it('Can hide a column', function() {
  53. // see that the last login column is in the header
  54. cy.get('[data-cy-user-list-header-last-login]').should('exist')
  55. // see that the last login column is in all user rows
  56. getUserList().find('tbody tr').each(($row) => {
  57. cy.wrap($row).get('[data-cy-user-list-cell-last-login]').should('exist')
  58. })
  59. // open the settings dialog
  60. cy.contains('button', 'Account management settings').click()
  61. cy.contains('.modal-container', 'Account management settings').within(() => {
  62. // disable the last login toggle
  63. cy.get('[data-test="showLastLogin"] input[type="checkbox"]').should('be.checked')
  64. cy.get('[data-test="showLastLogin"] input[type="checkbox"]').uncheck({ force: true })
  65. cy.get('[data-test="showLastLogin"] input[type="checkbox"]').should('not.be.checked')
  66. // close the settings dialog
  67. cy.get('button.modal-container__close').click()
  68. })
  69. cy.waitUntil(() => cy.contains('.modal-container', 'Account management settings').should(el => assertNotExistOrNotVisible(el)))
  70. // see that the last login column is not in the header
  71. cy.get('[data-cy-user-list-header-last-login]').should('not.exist')
  72. // see that the last login column is not in all user rows
  73. getUserList().find('tbody tr').each(($row) => {
  74. cy.wrap($row).get('[data-cy-user-list-cell-last-login]').should('not.exist')
  75. })
  76. })
  77. })