Skip to content

Commit

Permalink
[Roles] Roles Edit page description enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
elena-shostak committed May 15, 2024
1 parent 61be09a commit 1899c2b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -567,11 +567,43 @@ describe('<EditRolePage />', () => {
);
expect(
wrapper.find('input[data-test-subj="roleFormDescriptionInput"]').prop('disabled')
).toBe(false);

).toBe(undefined);
expectSaveFormButtons(wrapper);
});

it('can render a reserved role with description', async () => {
const wrapper = mountWithIntl(
<KibanaContextProvider services={coreStart}>
<EditRolePage
{...getProps({
action: 'edit',
spacesEnabled: false,
role: {
description: 'my reserved role description',
name: 'my custom role',
metadata: {
_reserved: true,
},
elasticsearch: { cluster: ['all'], indices: [], run_as: ['*'] },
kibana: [],
},
})}
/>
</KibanaContextProvider>
);

await waitForRender(wrapper);

expect(wrapper.find('[data-test-subj="roleFormDescriptionTooltip"]')).toHaveLength(1);

expect(wrapper.find('input[data-test-subj="roleFormDescriptionInput"]').prop('value')).toBe(
'my reserved role description'
);
expect(
wrapper.find('input[data-test-subj="roleFormDescriptionInput"]').prop('disabled')
).toBe(true);
});

it('can render when creating a new role', async () => {
const wrapper = mountWithIntl(
<KibanaContextProvider services={coreStart}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,27 @@ export const EditRolePage: FunctionComponent<Props> = ({
/>
}
>
<EuiToolTip content={role.description} display="block">
{isRoleReserved || isRoleReadOnly ? (
<EuiToolTip
content={role.description}
display="block"
data-test-subj="roleFormDescriptionTooltip"
>
<EuiFieldText
name="description"
value={role.description ?? ''}
data-test-subj="roleFormDescriptionInput"
disabled
/>
</EuiToolTip>
) : (
<EuiFieldText
name="description"
value={role.description ?? ''}
onChange={onDescriptionChange}
data-test-subj="roleFormDescriptionInput"
disabled={isRoleReserved || isRoleReadOnly}
/>
</EuiToolTip>
)}
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down

0 comments on commit 1899c2b

Please sign in to comment.