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

Usertype removal - part 1 #1858

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cfead02
Merge pull request #10 from PalisadoesFoundation/develop
pranshugupta54 Mar 13, 2024
d4c2c01
Merge remote-tracking branch 'upstream/develop' into dev-latest
pranshugupta54 Mar 27, 2024
aa561d6
Merge remote-tracking branch 'upstream/develop' into dev-latest
pranshugupta54 Mar 27, 2024
f9973f9
Merge remote-tracking branch 'upstream/develop' into dev-latest
pranshugupta54 Mar 27, 2024
0a32b82
Merge remote-tracking branch 'upstream/develop' into dev-latest
pranshugupta54 Mar 27, 2024
dec053f
Merge remote-tracking branch 'upstream/develop' into dev-latest
pranshugupta54 Mar 29, 2024
2a2c202
Merge remote-tracking branch 'upstream/develop' into usertype-removal
pranshugupta54 Mar 30, 2024
d1fbff3
Merge remote-tracking branch 'upstream/develop' into usertype-removal
pranshugupta54 Mar 31, 2024
53fb4b8
delete org fix
pranshugupta54 Mar 31, 2024
c96a944
refactor duplicate code files
pranshugupta54 Mar 31, 2024
95341a9
refactor userType code in Users.tsx
pranshugupta54 Mar 31, 2024
c3c8704
userType fix App.test
pranshugupta54 Mar 31, 2024
17ee8cf
Merge remote-tracking branch 'upstream/develop' into usertype-removal
pranshugupta54 Mar 31, 2024
dec0064
fix leftdrawer
pranshugupta54 Mar 31, 2024
6f4937c
settings test
pranshugupta54 Mar 31, 2024
819dfd8
events n profile dropdown
pranshugupta54 Mar 31, 2024
8d15c65
rename file
pranshugupta54 Mar 31, 2024
901a1e5
Fix import casing in OrganizationScreen and SuperAdminScreen
pranshugupta54 Mar 31, 2024
c43231d
Rename profileDropdown.module.css to ProfileDropdown.module.css
pranshugupta54 Mar 31, 2024
d7d55ce
Rename profileDropdown.test.tsx to ProfileDropdown.test.tsx
pranshugupta54 Mar 31, 2024
319bcd8
Rename profileDropdown.tsx to ProfileDropdown.tsx
pranshugupta54 Mar 31, 2024
1c56543
variable rename
pranshugupta54 Mar 31, 2024
aa29464
remove unused code
pranshugupta54 Mar 31, 2024
083eafb
fix test and remove userType in OrgSettings
pranshugupta54 Mar 31, 2024
6ddd9a9
Remove unnecessary beforeEach block in LeftDrawerOrg.test.tsx
pranshugupta54 Apr 1, 2024
9a69f11
Merge remote-tracking branch 'upstream/develop' into usertype-removal
pranshugupta54 Apr 1, 2024
e3a7b25
superadmin screen test
pranshugupta54 Apr 1, 2024
bf6fecd
unused code
pranshugupta54 Apr 1, 2024
2d999ee
login test data fix
pranshugupta54 Apr 1, 2024
5851ffd
unused
pranshugupta54 Apr 1, 2024
f25be48
unused
pranshugupta54 Apr 1, 2024
022cade
fixed userType to userRole
pranshugupta54 Apr 1, 2024
dc1ecfb
Remove InterfaceQueryRequestListItem interface
pranshugupta54 Apr 1, 2024
321df12
deleteOrg test fix
pranshugupta54 Apr 1, 2024
5906b79
typos
pranshugupta54 Apr 1, 2024
9b40829
Update OrganizationDashboard.test.tsx
pranshugupta54 Apr 2, 2024
5c038ba
added files with eslint issue
pranshugupta54 Apr 2, 2024
f51ffdd
Update pre-commit
pranshugupta54 Apr 2, 2024
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
1 change: 0 additions & 1 deletion src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const MOCKS = [
phone: {
mobile: '+8912313112',
},
userType: 'SUPERADMIN',
},
},
},
Expand Down
12 changes: 6 additions & 6 deletions src/components/DeleteOrg/DeleteOrg.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ afterEach(() => {
describe('Delete Organization Component', () => {
test('should be able to Toggle Delete Organization Modal', async () => {
mockURL = '456';
setItem('UserType', 'SUPERADMIN');
setItem('SuperAdmin', true);
render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
Expand All @@ -140,7 +140,7 @@ describe('Delete Organization Component', () => {

test('should be able to Toggle Delete Organization Modal When Organization is Sample Organization', async () => {
mockURL = '123';
setItem('UserType', 'SUPERADMIN');
setItem('SuperAdmin', true);
render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
Expand All @@ -164,7 +164,7 @@ describe('Delete Organization Component', () => {

test('Delete organization functionality should work properly', async () => {
mockURL = '456';
setItem('UserType', 'SUPERADMIN');
setItem('SuperAdmin', true);
render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
Expand All @@ -183,7 +183,7 @@ describe('Delete Organization Component', () => {

test('Delete organization functionality should work properly for sample org', async () => {
mockURL = '123';
setItem('UserType', 'SUPERADMIN');
setItem('SuperAdmin', true);
render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
Expand All @@ -204,7 +204,7 @@ describe('Delete Organization Component', () => {

test('Error handling for IS_SAMPLE_ORGANIZATION_QUERY mock', async () => {
mockURL = '123';
setItem('UserType', 'SUPERADMIN');
setItem('SuperAdmin', true);
jest.spyOn(toast, 'error');
render(
<MockedProvider addTypename={false} link={link2}>
Expand All @@ -228,7 +228,7 @@ describe('Delete Organization Component', () => {

test('Error handling for DELETE_ORGANIZATION_MUTATION mock', async () => {
mockURL = '456';
setItem('UserType', 'SUPERADMIN');
setItem('SuperAdmin', true);
render(
<MockedProvider addTypename={false} link={link2}>
<BrowserRouter>
Expand Down
4 changes: 2 additions & 2 deletions src/components/DeleteOrg/DeleteOrg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function deleteOrg(): JSX.Element {
const navigate = useNavigate();
const [showDeleteModal, setShowDeleteModal] = useState(false);
const { getItem } = useLocalStorage();
const canDelete = getItem('UserType') === 'SUPERADMIN';
const canDelete = getItem('SuperAdmin');
const toggleDeleteModal = (): void => setShowDeleteModal(!showDeleteModal);

const [del] = useMutation(DELETE_ORGANIZATION_MUTATION);
Expand Down Expand Up @@ -55,7 +55,7 @@ function deleteOrg(): JSX.Element {
},
});
navigate('/orglist');
} catch (error: any) {
} catch (error) {
errorHandler(t, error);
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/components/LeftDrawer/LeftDrawer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ afterEach(() => {
});

describe('Testing Left Drawer component for SUPERADMIN', () => {
beforeEach(() => {
setItem('UserType', 'SUPERADMIN');
});
test('Component should be rendered properly', () => {
setItem('UserImage', '');
setItem('UserImage', '');
Expand Down Expand Up @@ -134,9 +131,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => {
});

describe('Testing Left Drawer component for ADMIN', () => {
beforeEach(() => {
setItem('UserType', 'ADMIN');
});
test('Components should be rendered properly', () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand Down
1 change: 0 additions & 1 deletion src/components/LeftDrawer/LeftDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const leftDrawer = ({ hideDrawer }: InterfaceLeftDrawerProps): JSX.Element => {
const { t } = useTranslation('translation', { keyPrefix: 'leftDrawer' });

const { getItem } = useLocalStorage();
const userType = getItem('UserType');
const superAdmin = getItem('SuperAdmin');
const role = superAdmin ? 'SuperAdmin' : 'Admin';

Expand Down
4 changes: 0 additions & 4 deletions src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,6 @@ const linkImage = new StaticMockLink(MOCKS_WITH_IMAGE, true);
const linkEmpty = new StaticMockLink(MOCKS_EMPTY, true);

describe('Testing LeftDrawerOrg component for SUPERADMIN', () => {
beforeEach(() => {
setItem('UserType', 'SUPERADMIN');
});

test('Component should be rendered properly', async () => {
setItem('UserImage', '');
setItem('SuperAdmin', true);
Expand Down
2 changes: 1 addition & 1 deletion src/components/OrganizationScreen/OrganizationScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { updateTargets } from 'state/action-creators';
import type { RootState } from 'state/reducers';
import type { TargetsType } from 'state/reducers/routesReducer';
import styles from './OrganizationScreen.module.css';
import ProfileDropdown from 'components/ProfileDropdown/profileDropdown';
import ProfileDropdown from 'components/ProfileDropdown/ProfileDropdown';

const OrganizationScreen = (): JSX.Element => {
const location = useLocation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { act, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { BrowserRouter } from 'react-router-dom';
import ProfileDropdown from './profileDropdown';
import ProfileDropdown from './ProfileDropdown';
import 'jest-localstorage-mock';
import { MockedProvider } from '@apollo/react-testing';
import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Avatar from 'components/Avatar/Avatar';
import React from 'react';
import { ButtonGroup, Dropdown } from 'react-bootstrap';
import { useNavigate, useParams } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import useLocalStorage from 'utils/useLocalstorage';
import styles from './profileDropdown.module.css';
import styles from './ProfileDropdown.module.css';
import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations';
import { useMutation } from '@apollo/client';

Expand All @@ -12,7 +12,7 @@ const profileDropdown = (): JSX.Element => {
const { getItem } = useLocalStorage();
const superAdmin = getItem('SuperAdmin');
const adminFor = getItem('AdminFor');
const userType = superAdmin
const userRole = superAdmin
? 'SuperAdmin'
: adminFor?.length > 0
? 'Admin'
Expand Down Expand Up @@ -67,7 +67,7 @@ const profileDropdown = (): JSX.Element => {
{displayedName}
</span>
<span className={styles.secondaryText} data-testid="display-type">
{`${userType}`}
{`${userRole}`}
</span>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jest.mock('react-toastify', () => ({
}));

beforeEach(() => {
setItem('UserType', 'ADMIN');
setItem('id', '123');
});

Expand Down
2 changes: 0 additions & 2 deletions src/components/SuperAdminScreen/SuperAdminScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ const clickToggleMenuBtn = (toggleButton: HTMLElement): void => {

describe('Testing LeftDrawer in SuperAdminScreen', () => {
test('Testing LeftDrawer in page functionality', async () => {
setItem('UserType', 'SUPERADMIN');

render(
<MockedProvider addTypename={false}>
<BrowserRouter>
Expand Down
7 changes: 5 additions & 2 deletions src/components/SuperAdminScreen/SuperAdminScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Button from 'react-bootstrap/Button';
import { useTranslation } from 'react-i18next';
import { Outlet, useLocation } from 'react-router-dom';
import styles from './SuperAdminScreen.module.css';
import ProfileDropdown from 'components/ProfileDropdown/profileDropdown';
import ProfileDropdown from 'components/ProfileDropdown/ProfileDropdown';

const superAdminScreen = (): JSX.Element => {
const location = useLocation();
Expand Down Expand Up @@ -71,7 +71,10 @@ const superAdminScreen = (): JSX.Element => {

export default superAdminScreen;

const map: any = {
const map: Record<
string,
'orgList' | 'requests' | 'users' | 'memberDetail' | 'communityProfile'
> = {
orglist: 'orgList',
requests: 'requests',
users: 'users',
Expand Down
6 changes: 4 additions & 2 deletions src/components/UserPortal/Login/Login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ const MOCKS = [
login: {
user: {
_id: '1',
userType: 'ADMIN',
adminApproved: false,
firstName: 'firstname',
lastName: 'secondname',
email: '[email protected]',
image: 'image',
},
appUserProfile: {
adminFor: {},
isSuperAdmin: false,
},
accessToken: 'accessToken',
refreshToken: 'refreshToken',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ const renderStartPostModal = (
lastName: 'dsza',
email: '[email protected]',
appLanguageCode: 'en',
userType: 'USER',
pluginCreationAllowed: true,
adminApproved: true,
createdAt: '2023-02-18T09:22:27.969Z',
Expand Down
47 changes: 0 additions & 47 deletions src/screens/MemberDetail/MemberDetail.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ import { BrowserRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import { store } from 'state/store';
import { I18nextProvider } from 'react-i18next';
import {
ADD_ADMIN_MUTATION,
UPDATE_USERTYPE_MUTATION,
UPDATE_USER_MUTATION,
} from 'GraphQl/Mutations/mutations';
import { USER_DETAILS } from 'GraphQl/Queries/Queries';
import i18nForTest from 'utils/i18nForTest';
import { StaticMockLink } from 'utils/StaticMockLink';
Expand Down Expand Up @@ -120,20 +115,6 @@ const MOCKS1 = [
},
},
},
{
request: {
query: ADD_ADMIN_MUTATION,
variables: {
userid: '123',
orgid: '456',
},
},
result: {
data: {
success: true,
},
},
},
];

const MOCKS2 = [
Expand Down Expand Up @@ -224,20 +205,6 @@ const MOCKS2 = [
},
},
},
{
request: {
query: ADD_ADMIN_MUTATION,
variables: {
userid: '123',
orgid: '456',
},
},
result: {
data: {
success: true,
},
},
},
];
const MOCKS3 = [
{
Expand Down Expand Up @@ -327,20 +294,6 @@ const MOCKS3 = [
},
},
},
{
request: {
query: ADD_ADMIN_MUTATION,
variables: {
userid: '123',
orgid: '456',
},
},
result: {
data: {
success: true,
},
},
},
];

const link1 = new StaticMockLink(MOCKS1, true);
Expand Down
2 changes: 1 addition & 1 deletion src/screens/MemberDetail/MemberDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
maritalStatusEnum,
genderEnum,
employmentStatusEnum,
} from 'utils/memberFields';
} from 'utils/formEnumFields';
import DynamicDropDown from 'components/DynamicDropDown/DynamicDropDown';

type MemberDetailProps = {
Expand Down
4 changes: 2 additions & 2 deletions src/screens/OrgSettings/OrgSettings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('Organisation Settings Page', () => {

test('should render props and text elements test for the screen', async () => {
window.location.assign('/orgsetting/id=123');
setItem('UserType', 'SUPERADMIN');
setItem('SuperAdmin', true);
render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
Expand Down Expand Up @@ -140,7 +140,7 @@ describe('Organisation Settings Page', () => {

test('should render appropriate settings based on the orgSetting state', async () => {
window.location.assign('/orgsetting/id=123');
setItem('UserType', 'SUPERADMIN');
setItem('SuperAdmin', true);

const { queryByText } = render(
<MockedProvider addTypename={false} link={link}>
Expand Down
8 changes: 7 additions & 1 deletion src/screens/OrganizationEvents/OrganizationEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ function organizationEvents(): JSX.Element {
});

const userId = getItem('id') as string;
const userRole = getItem('UserType') as string;
const superAdmin = getItem('SuperAdmin');
const adminFor = getItem('AdminFor');
const userRole = superAdmin
? 'SUPERADMIN'
: adminFor?.length > 0
? 'ADMIN'
: 'USER';

const [create, { loading: loading2 }] = useMutation(CREATE_EVENT_MUTATION);

Expand Down
1 change: 0 additions & 1 deletion src/screens/Requests/Requests.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ describe('Testing Requests screen', () => {

test(`Component should be rendered properly when user is not Admin
and or userId does not exists in localstorage`, async () => {
setItem('UserType', 'SUPERADMIN');
setItem('id', '');
render(
<MockedProvider addTypename={false} link={link}>
Expand Down
2 changes: 0 additions & 2 deletions src/screens/UserPortal/Settings/Settings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ const Mocks1 = [
mobile: '+174567890',
},
image: 'https://api.dicebear.com/5.x/initials/svg?seed=John%20Doe',
userType: 'user',
_id: '65ba1621b7b00c20e5f1d8d2',
},
},
Expand Down Expand Up @@ -98,7 +97,6 @@ const Mocks2 = [
mobile: '',
},
image: '',
userType: 'user',
_id: '65ba1621b7b00c20e5f1d8d2',
},
},
Expand Down
Loading
Loading