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

Display Block Icon on Disabled User Action Buttons settings and delete #114

Merged
merged 2 commits into from
Feb 1, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ describe('Header Component', () => {
const monthElement = within(leftWrapperElement).getByTestId('month');

expect(monthElement).toBeInTheDocument();
expect(monthElement).toHaveTextContent(
`${expectedStartDate.format('DD MMM')} - ${expectedEndDate.format('DD MMM YYYY')}`
);
const actualTextContent = monthElement.textContent?.trim();
const expectedTextContent = `${expectedStartDate.format('DD MMM')} - ${expectedEndDate.format(
'DD MMM YYYY'
)}`;
expect(actualTextContent).toBe(expectedTextContent);

expect(screen.getByText(exportCSVText)).toBeInTheDocument();

Expand Down
60 changes: 60 additions & 0 deletions src/people/widgetViews/__tests__/UsersList.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom';
import Users from '../organization/UsersList.tsx';

jest.mock('store', () => ({
useStores: () => ({
main: {
bountyRoles: []
},
ui: {
meInfo: {
owner_pubkey: 'mocked_pubkey'
}
}
})
}));

const mockedUsers = [
{
owner_pubkey: 'user1_pubkey',
owner_alias: 'User 1',
img: ''
},
{
owner_pubkey: 'mocked_pubkey',
owner_alias: 'User 2',
img: ''
}
];

const props = {
users: mockedUsers,
userRoles: ['VIEW'],
handleDeleteClick: jest.fn(),
handleSettingsClick: jest.fn(),
org: { owner_pubkey: 'org_pubkey' }
};

describe('Users Component', () => {
test('displays not-allowed cursor over disabled settings button', () => {
// @ts-ignore
const { getAllByTestId } = render(<Users {...props} />);
const settingsIcons = getAllByTestId('settings-icon');
// eslint-disable-next-line @typescript-eslint/typedef
settingsIcons.forEach((icon) => {
expect(icon).toHaveStyle('cursor: not-allowed');
});
});

test('displays not-allowed cursor over disabled delete button', () => {
// @ts-ignore
const { getAllByTestId } = render(<Users {...props} />);
const deleteIcons = getAllByTestId('delete-icon');
// eslint-disable-next-line @typescript-eslint/typedef
deleteIcons.forEach((icon) => {
expect(icon).toHaveStyle('cursor: not-allowed');
});
});
});
6 changes: 4 additions & 2 deletions src/people/widgetViews/organization/UsersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ const Users = (props: UserListProps) => {
<ActionBtn disabled={settingsDisabled}>
<MaterialIcon
disabled={settingsDisabled}
data-testid="settings-icon"
icon={'settings'}
style={{
fontSize: 24,
cursor: 'pointer',
cursor: settingsDisabled ? 'not-allowed' : 'pointer',
color: settingsDisabled ? '#b0b7bc' : '#5f6368'
}}
onClick={() => handleSettingsClick(user)}
Expand All @@ -59,10 +60,11 @@ const Users = (props: UserListProps) => {
<IconWrap>
<ActionBtn disabled={deleteUserDisabled}>
<MaterialIcon
data-testid="delete-icon"
icon={'delete'}
style={{
fontSize: 24,
cursor: 'pointer',
cursor: deleteUserDisabled ? 'not-allowed' : 'pointer',
color: deleteUserDisabled ? '#b0b7bc' : '#5f6368'
}}
onClick={() => {
Expand Down
Loading