mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
49eafa2712
[web] Managed Users offboarding UI GitOrigin-RevId: ee4a1ae7cdb0022839ef232836ef6933443400fc
107 lines
3.2 KiB
TypeScript
107 lines
3.2 KiB
TypeScript
import OffboardManagedUserModal from '../../../../../../frontend/js/features/group-management/components/managed-users/offboard-managed-user-modal'
|
|
import sinon from 'sinon'
|
|
|
|
describe('OffboardManagedUserModal', 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,
|
|
}
|
|
const otherUser = {
|
|
_id: 'other-user',
|
|
email: 'other.user@example.com',
|
|
first_name: 'Other',
|
|
last_name: 'User',
|
|
invite: false,
|
|
last_active_at: new Date(),
|
|
enrollment: {
|
|
managedBy: `${groupId}`,
|
|
enrolledAt: new Date(),
|
|
},
|
|
isEntityAdmin: undefined,
|
|
}
|
|
const allMembers = [user, otherUser]
|
|
|
|
beforeEach(function () {
|
|
cy.mount(
|
|
<OffboardManagedUserModal
|
|
user={user}
|
|
allMembers={allMembers}
|
|
groupId={groupId}
|
|
onClose={sinon.stub()}
|
|
/>
|
|
)
|
|
})
|
|
|
|
it('should render the modal', function () {
|
|
cy.get('#delete-user-form').should('exist')
|
|
})
|
|
|
|
it('should disable the button if a recipient is not selected', function () {
|
|
// Button should be disabled initially
|
|
cy.get('button[type="submit"]').should('be.disabled')
|
|
|
|
// Not selecting a recipient...
|
|
|
|
// Fill in the email input
|
|
cy.get('#supplied-email-input').type(user.email)
|
|
|
|
// Button still disabled
|
|
cy.get('button[type="submit"]').should('be.disabled')
|
|
})
|
|
|
|
it('should disable the button if the email is not filled in', function () {
|
|
// Button should be disabled initially
|
|
cy.get('button[type="submit"]').should('be.disabled')
|
|
|
|
// Select a recipient
|
|
cy.get('#recipient-select-input').select('other.user@example.com')
|
|
|
|
// Not filling in the email...
|
|
|
|
// Button still disabled
|
|
cy.get('button[type="submit"]').should('be.disabled')
|
|
})
|
|
|
|
it('should disable the button if the email does not match the user', function () {
|
|
// Button should be disabled initially
|
|
cy.get('button[type="submit"]').should('be.disabled')
|
|
|
|
// Select a recipient
|
|
cy.get('#recipient-select-input').select('other.user@example.com')
|
|
|
|
// Fill in the email input, with the wrong email address
|
|
cy.get('#supplied-email-input').type('totally.wrong@example.com')
|
|
|
|
// Button still disabled
|
|
cy.get('button[type="submit"]').should('be.disabled')
|
|
})
|
|
|
|
it('should fill out the form, and enable the delete button', function () {
|
|
// Button should be disabled initially
|
|
cy.get('button[type="submit"]').should('be.disabled')
|
|
|
|
// Select a recipient
|
|
cy.get('#recipient-select-input').select('other.user@example.com')
|
|
|
|
// Button still disabled
|
|
cy.get('button[type="submit"]').should('be.disabled')
|
|
|
|
// Fill in the email input
|
|
cy.get('#supplied-email-input').type(user.email)
|
|
|
|
// Button should be enabled now
|
|
cy.get('button[type="submit"]').should('not.be.disabled')
|
|
})
|
|
})
|
|
})
|