Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add role description tooltip #2304

Merged
merged 2 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 45 additions & 9 deletions ui/src/__tests__/components/role/RoleRow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
*/
import React from 'react';
import RoleRow from '../../../components/role/RoleRow';
import { colors } from '../../../components/denali/styles';
import { renderWithRedux } from '../../../tests_utils/ComponentsTestUtils';
import {colors} from '../../../components/denali/styles';
import {renderWithRedux} from '../../../tests_utils/ComponentsTestUtils';
import { fireEvent, screen, waitFor } from '@testing-library/react';
import { configure } from '@testing-library/dom'
import {act} from "react-dom/test-utils";
import {USER_DOMAIN} from "../../../components/constants/constants";

describe('RoleRow', () => {
it('should render', () => {
Expand All @@ -31,18 +35,50 @@ describe('RoleRow', () => {
const { getByTestId } = renderWithRedux(
<table>
<tbody>
<RoleRow
details={details}
domain={domain}
color={color}
idx={idx}
timeZone={timeZone}
/>
<RoleRow
details={details}
domain={domain}
color={color}
idx={idx}
timeZone={timeZone}
/>
</tbody>
</table>
);
const roleRow = getByTestId('role-row');

expect(roleRow).toMatchSnapshot();
});


it('should display description', async() => {
const details = {
name: 'athens:role.zts_sia_cert_rotate',
description: 'test description',
modified: '2017-08-03T18:44:41.867Z',
};
const domain = 'domain';
const color = colors.row;
const idx = '50';
const timeZone = 'UTC';
renderWithRedux(
<table>
<tbody>
<RoleRow
details={details}
domain={domain}
color={color}
idx={idx}
timeZone={timeZone}
/>
</tbody>
</table>
);

let descriptionIcon = screen.queryByTestId("description-icon");
expect(descriptionIcon).toBeInTheDocument();
fireEvent.mouseEnter(descriptionIcon);
await screen.findByText('test description');

});
});
32 changes: 32 additions & 0 deletions ui/src/__tests__/components/role/RoleSectionRow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import React from 'react';
import RoleSectionRow from '../../../components/role/RoleSectionRow';
import { colors } from '../../../components/denali/styles';
import { renderWithRedux } from '../../../tests_utils/ComponentsTestUtils';
import RoleRow from "../../../components/role/RoleRow";
import {fireEvent, screen} from "@testing-library/react";

describe('RoleRow', () => {
it('should render', () => {
Expand All @@ -43,4 +45,34 @@ describe('RoleRow', () => {

expect(roleSectionRow).toMatchSnapshot();
});

it('should display description', async() => {
const details = {
name: 'athens:role.zts_sia_cert_rotate',
description: 'test description',
modified: '2017-08-03T18:44:41.867Z',
};
const domain = 'domain';
const color = colors.row;
const idx = '50';
const timeZone = 'UTC';
renderWithRedux(
<table>
<tbody>
<RoleSectionRow
details={details}
domain={domain}
color={color}
timeZone={timeZone}
/>
</tbody>
</table>
);

let descriptionIcon = screen.queryByTestId("description-icon");
expect(descriptionIcon).toBeInTheDocument();
fireEvent.mouseEnter(descriptionIcon);
await screen.findByText('test description');

});
});
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ exports[`RoleRow should render 1`] = `
>
ztssia_cert_rotate
</span>

</div>
<div
class="emotion-6 emotion-7"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ exports[`RoleRow should render 1`] = `
>
ztssia_cert_rotate
</span>

</div>
<div
class="emotion-6 emotion-7"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ exports[`RoleTable should render 1`] = `
>
a
</span>

</div>
<div
class="emotion-30 emotion-31"
Expand Down Expand Up @@ -352,6 +353,7 @@ exports[`RoleTable should render 1`] = `
>
b
</span>

</div>
<div
class="emotion-30 emotion-31"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,47 @@ exports[`SettingTable should render setting table 1`] = `
expiration enforced by a user authority configured attribute
</td>
</tr>
<tr
class="emotion-2 emotion-3"
data-testid="setting-row"
>
<td
class="emotion-4 emotion-5"
width="auto"
>
Role Description
</td>
<td
class="emotion-4 emotion-5"
width="auto"
>
<div
class="emotion-35 emotion-36"
>
<div
class="emotion-37 denali-input animated emotion-38 emotion-39"
data-testid="input-wrapper"
>
<input
autocomplete="off"
data-testid="input-node"
id="setting-description"
value=""
/>
<div
class="message"
data-testid="message"
/>
</div>
</div>
</td>
<td
class="emotion-4 emotion-5"
width="auto"
>
Role Description (Optional)
</td>
</tr>
</tbody>
</table>
`;
Loading