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

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