overleaf-cep/services/web/test/frontend/features/group-management/components/members-table/remove-managed-user-modal.spec.tsx
ilkin-overleaf 272303cb58 Merge pull request #24907 from overleaf/ii-managed-users-make-unmanaged
[web] Release users from managed group

GitOrigin-RevId: 15921286af332d2294fb900ab3055991ca8b1673
2025-06-13 08:05:37 +00:00

96 lines
3.2 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import RemoveManagedUserModal from '@/features/group-management/components/members-table/remove-managed-user-modal'
import sinon from 'sinon'
describe('RemoveManagedUserModal', function () {
describe('happy path', function () {
const groupId = 'some-group'
const user = {
_id: 'some-user',
email: 'some.user@example.com',
first_name: 'Some',
last_name: 'User',
invite: true,
last_active_at: new Date(),
enrollment: {
managedBy: `${groupId}`,
enrolledAt: new Date(),
},
isEntityAdmin: undefined,
}
beforeEach(function () {
cy.mount(
<RemoveManagedUserModal
user={user}
groupId={groupId}
onClose={sinon.stub()}
/>
)
})
it('should render the modal', function () {
cy.findByTestId('release-user-form')
})
it('should render content', function () {
cy.findByText(
`Youre about to remove ${user.first_name} ${user.last_name} (${user.email}). Doing this will mean:`
)
cy.findAllByRole('listitem')
.eq(0)
.contains(/they will be removed from the group/i)
cy.findAllByRole('listitem')
.eq(1)
.contains(/they will no longer be a managed user/i)
cy.findAllByRole('listitem')
.eq(2)
.contains(
/they will retain their existing account on the .* free plan/i
)
cy.findAllByRole('listitem')
.eq(3)
.contains(
/they will retain ownership of projects currently owned by them and any collaborators on those projects will become read-only/i
)
cy.findAllByRole('listitem')
.eq(4)
.contains(
/they will continue to have access to any projects shared with them/i
)
cy.findAllByRole('listitem')
.eq(5)
.contains(
/they wont be able to log in with SSO \(if you have this enabled\)\. they will need to set an .* password/i
)
cy.contains(
/in cases where a user has left your organization and you need to transfer their projects, the delete user option should be used/i
)
})
it('should disable the remove button if the email does not match the user', function () {
// Button should be disabled initially
cy.findByRole('button', { name: /remove user/i }).should('be.disabled')
// Fill in the email input, with the wrong email address
cy.findByLabelText(
/to confirm you want to remove .* please type the email address associated with their account/i
).type('totally.wrong@example.com')
// Button still disabled
cy.findByRole('button', { name: /remove user/i }).should('be.disabled')
})
it('should fill out the form, and enable the remove button', function () {
// Button should be disabled initially
cy.findByRole('button', { name: /remove user/i }).should('be.disabled')
// Fill in the email input
cy.findByLabelText(
/to confirm you want to remove .* please type the email address associated with their account/i
).type(user.email)
// Button should be enabled now
cy.findByRole('button', { name: /remove user/i }).should('be.enabled')
})
})
})