1
0

users_columns.cy.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /**
  2. * @copyright 2023 Christopher Ng <chrng8@gmail.com>
  3. *
  4. * @author Christopher Ng <chrng8@gmail.com>
  5. *
  6. * @license AGPL-3.0-or-later
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. import { User } from '@nextcloud/cypress'
  23. import { assertNotExistOrNotVisible, getUserList } from './usersUtils.js'
  24. const admin = new User('admin', 'admin')
  25. describe('Settings: Show and hide columns', function() {
  26. before(function() {
  27. cy.login(admin)
  28. // open the User settings
  29. cy.visit('/settings/users')
  30. })
  31. beforeEach(function() {
  32. // open the settings dialog
  33. cy.contains('button', 'Account management settings').click()
  34. // reset all visibility toggles
  35. cy.get('.modal-container #settings-section_visibility-settings input[type="checkbox"]').uncheck({ force: true })
  36. cy.contains('.modal-container', 'Account management settings').within(() => {
  37. // enable the last login toggle
  38. cy.get('[data-test="showLastLogin"] input[type="checkbox"]').check({ force: true })
  39. // close the settings dialog
  40. cy.get('button.modal-container__close').click()
  41. })
  42. cy.waitUntil(() => cy.get('.modal-container').should(el => assertNotExistOrNotVisible(el)))
  43. })
  44. it('Can show a column', function() {
  45. // see that the language column is not in the header
  46. cy.get('[data-cy-user-list-header-languages]').should('not.exist')
  47. // see that the language column is not in all user rows
  48. cy.get('tbody.user-list__body tr').each(($row) => {
  49. cy.wrap($row).get('[data-test="language"]').should('not.exist')
  50. })
  51. // open the settings dialog
  52. cy.contains('button', 'Account management settings').click()
  53. cy.contains('.modal-container', 'Account management settings').within(() => {
  54. // enable the language toggle
  55. cy.get('[data-test="showLanguages"] input[type="checkbox"]').should('not.be.checked')
  56. cy.get('[data-test="showLanguages"] input[type="checkbox"]').check({ force: true })
  57. cy.get('[data-test="showLanguages"] input[type="checkbox"]').should('be.checked')
  58. // close the settings dialog
  59. cy.get('button.modal-container__close').click()
  60. })
  61. cy.waitUntil(() => cy.get('.modal-container').should(el => assertNotExistOrNotVisible(el)))
  62. // see that the language column is in the header
  63. cy.get('[data-cy-user-list-header-languages]').should('exist')
  64. // see that the language column is in all user rows
  65. getUserList().find('tbody tr').each(($row) => {
  66. cy.wrap($row).get('[data-cy-user-list-cell-language]').should('exist')
  67. })
  68. })
  69. it('Can hide a column', function() {
  70. // see that the last login column is in the header
  71. cy.get('[data-cy-user-list-header-last-login]').should('exist')
  72. // see that the last login column is in all user rows
  73. getUserList().find('tbody tr').each(($row) => {
  74. cy.wrap($row).get('[data-cy-user-list-cell-last-login]').should('exist')
  75. })
  76. // open the settings dialog
  77. cy.contains('button', 'Account management settings').click()
  78. cy.contains('.modal-container', 'Account management settings').within(() => {
  79. // disable the last login toggle
  80. cy.get('[data-test="showLastLogin"] input[type="checkbox"]').should('be.checked')
  81. cy.get('[data-test="showLastLogin"] input[type="checkbox"]').uncheck({ force: true })
  82. cy.get('[data-test="showLastLogin"] input[type="checkbox"]').should('not.be.checked')
  83. // close the settings dialog
  84. cy.get('button.modal-container__close').click()
  85. })
  86. cy.waitUntil(() => cy.contains('.modal-container', 'Account management settings').should(el => assertNotExistOrNotVisible(el)))
  87. // see that the last login column is not in the header
  88. cy.get('[data-cy-user-list-header-last-login]').should('not.exist')
  89. // see that the last login column is not in all user rows
  90. getUserList().find('tbody tr').each(($row) => {
  91. cy.wrap($row).get('[data-cy-user-list-cell-last-login]').should('not.exist')
  92. })
  93. })
  94. })