-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UIU-2951: ECS - Prevent editing of specific shadow user data (#2560)
* UIU-2951: hide accordion section for shadow users * UIU-2951: ECS - Prevent editing of specific shadow user data * tests: fix failing tests * refactor: disable add button with disabled: true * test: improve tests
- Loading branch information
1 parent
b7b3b6e
commit 79713d2
Showing
16 changed files
with
200 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import { screen } from '@folio/jest-config-stripes/testing-library/react'; | ||
import userEvent from '@folio/jest-config-stripes/testing-library/user-event'; | ||
import { Form } from 'react-final-form'; | ||
|
||
import '__mock__/stripesComponents.mock'; | ||
import { screen } from '@folio/jest-config-stripes/testing-library/react'; | ||
import userEvent from '@folio/jest-config-stripes/testing-library/user-event'; | ||
|
||
import renderWithRouter from 'helpers/renderWithRouter'; | ||
import EditContactInfo from './EditContactInfo'; | ||
|
||
jest.unmock('@folio/stripes/components'); | ||
|
||
const onSubmit = jest.fn(); | ||
|
||
const arrayMutators = { | ||
|
@@ -28,7 +29,8 @@ const renderEditContactInfo = (props) => { | |
<EditContactInfo {...props} /> | ||
</> | ||
); | ||
renderWithRouter( | ||
|
||
return renderWithRouter( | ||
<Form | ||
id="form-user" | ||
mutators={{ | ||
|
@@ -71,9 +73,21 @@ describe('Render Edit contact Information component', () => { | |
renderEditContactInfo(props); | ||
expect(screen.getByText('AddressEditList')).toBeInTheDocument(); | ||
}); | ||
|
||
it('Must be rendered', async () => { | ||
renderEditContactInfo(props); | ||
await userEvent.type(document.querySelector('[id="adduser_email"]'), '[email protected]'); | ||
expect(document.querySelector('[id="adduser_email"]').value).toBe('[email protected]'); | ||
|
||
const emailInput = screen.getByRole('textbox', { name: /email/i }); | ||
|
||
await userEvent.type(emailInput, '[email protected]'); | ||
expect(emailInput.value).toBe('[email protected]'); | ||
}); | ||
|
||
it('should render with disabled fields', () => { | ||
renderEditContactInfo({ ...props, disabled: true }); | ||
|
||
expect(screen.getByRole('textbox', { name: /email/i })).toBeDisabled(); | ||
expect(screen.getByRole('textbox', { name: /mobilePhone/i })).toBeDisabled(); | ||
expect(screen.getByLabelText('ui-users.contact.phone')).toBeDisabled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,9 @@ | |
&:focus { | ||
outline: none; | ||
} | ||
|
||
&:disabled { | ||
color: var(--checkable-disabled-fill); | ||
cursor: not-allowed; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ jest.unmock('@folio/stripes/smart-components'); | |
|
||
const renderCreateResetPasswordControl = (props) => renderWithRouter(<CreateResetPasswordControl {...props} />); | ||
|
||
const propData = (postMock) => { | ||
const propData = (postMock, disabled = false) => { | ||
return { | ||
email: '[email protected]', | ||
name: 'sample', | ||
|
@@ -22,6 +22,7 @@ const propData = (postMock) => { | |
POST: postMock, | ||
} | ||
}, | ||
disabled, | ||
}; | ||
}; | ||
|
||
|
@@ -42,6 +43,13 @@ describe('CreateResetPasswordControl component', () => { | |
await waitFor(() => userEvent.click(screen.getByText('ui-users.extended.sendResetPassword'))); | ||
await waitFor(() => expect(screen.getByText('ui-users.extended.copyLink')).toBeInTheDocument()); | ||
}); | ||
it('should link be disabled', () => { | ||
const mockFunc = jest.fn(() => new Promise((resolve, _) => { | ||
resolve({ ok: true, link: 'bl-users/password-reset/link' }); | ||
})); | ||
renderCreateResetPasswordControl(propData(mockFunc, true)); | ||
expect(screen.getByText('ui-users.extended.sendResetPassword')).toBeDisabled(); | ||
}); | ||
/* Can be uncommented after the createResetpasswordControl modal logic is reworked. Should add an assertion at the end after the results */ | ||
// it('If it redirects after POST fails', async () => { | ||
// const mockFunc = jest.fn(() => new Promise((_, reject) => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,11 @@ import { screen } from '@folio/jest-config-stripes/testing-library/react'; | |
import { Form } from 'react-final-form'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import '__mock__/stripesComponents.mock'; | ||
|
||
import renderWithRouter from 'helpers/renderWithRouter'; | ||
import EditExtendedInfo from './EditExtendedInfo'; | ||
|
||
jest.unmock('@folio/stripes/components'); | ||
|
||
const onSubmit = jest.fn(); | ||
|
||
const arrayMutators = { | ||
|
@@ -28,7 +28,8 @@ const renderEditExtendedInfo = (props) => { | |
<EditExtendedInfo {...props} /> | ||
</> | ||
); | ||
renderWithRouter( | ||
|
||
return renderWithRouter( | ||
<Form | ||
id="form-user" | ||
mutators={{ | ||
|
@@ -120,4 +121,8 @@ describe('Render Extended User Information component', () => { | |
renderEditExtendedInfo(props); | ||
expect(screen.getByText('[email protected]')).toBeInTheDocument(); | ||
}); | ||
it('should fields to be disabled', () => { | ||
renderEditExtendedInfo({ ...props, disabled: true }); | ||
expect(screen.getAllByRole('textbox')[0]).toBeDisabled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.