managed-user-dropdown-button.spec.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import ManagedUserDropdownButton from '../../../../../../frontend/js/features/group-management/components/managed-users/managed-user-dropdown-button'
  2. describe('ManagedUserDropdownButton', function () {
  3. describe('with managed user', function () {
  4. const user = {
  5. _id: 'some-user',
  6. email: 'some.user@example.com',
  7. first_name: 'Some',
  8. last_name: 'User',
  9. invite: true,
  10. last_active_at: new Date(),
  11. enrollment: {
  12. managedBy: 'some-group',
  13. enrolledAt: new Date(),
  14. },
  15. isEntityAdmin: undefined,
  16. }
  17. beforeEach(function () {
  18. cy.mount(<ManagedUserDropdownButton user={user} />)
  19. })
  20. it('should render the button', function () {
  21. cy.get(`#managed-user-dropdown-${user._id}`).should('exist')
  22. cy.get(`.action-btn`).should('exist')
  23. })
  24. it('should show the menu when the button is clicked', function () {
  25. cy.get('.action-btn').click()
  26. cy.get('.delete-user-action').should('exist')
  27. cy.get('.delete-user-action').then($el => {
  28. Cypress.dom.isVisible($el)
  29. })
  30. })
  31. })
  32. describe('with non-managed user', function () {
  33. const user = {
  34. _id: 'some-user',
  35. email: 'some.user@example.com',
  36. first_name: 'Some',
  37. last_name: 'User',
  38. invite: true,
  39. last_active_at: new Date(),
  40. enrollment: undefined,
  41. isEntityAdmin: undefined,
  42. }
  43. beforeEach(function () {
  44. cy.mount(<ManagedUserDropdownButton user={user} />)
  45. })
  46. it('should render the button', function () {
  47. cy.get(`#managed-user-dropdown-${user._id}`).should('exist')
  48. cy.get(`.action-btn`).should('exist')
  49. })
  50. it('should show the (empty) menu when the button is clicked', function () {
  51. cy.get('.action-btn').click()
  52. cy.get('.no-actions-available').should('exist')
  53. })
  54. })
  55. })