Skip to content

Commit

Permalink
test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
PurnenduMIshra129th committed Feb 3, 2025
1 parent b122947 commit e4e3401
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
14 changes: 13 additions & 1 deletion src/App.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,19 @@ const MOCKS = [
];

const link = new StaticMockLink(MOCKS, true);
const link2 = new StaticMockLink([], true);
const link2 = new StaticMockLink(
[
{
request: { query: CHECK_AUTH },
result: { data: { checkAuth: null } }, // Simulating logged-out state
},
{
request: { query: VERIFY_ROLE },
result: { data: { verifyRole: null } }, // Ensure verifyRole exists, even if null
},
],
true,
);

const wait = (ms = 100): Promise<void> =>
new Promise((resolve) => setTimeout(resolve, ms));
Expand Down
4 changes: 2 additions & 2 deletions src/components/SecuredRoute/SecuredRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const SecuredRoute = (): JSX.Element => {
} else if (error) {
return <div>Error During Routing ...</div>;
} else {
const isLoggedIn = data.verifyRole.isAuthorized;
const role = data.verifyRole.role;
const role = data?.verifyRole?.role || '';
const isLoggedIn = data?.verifyRole?.isAuthorized ?? false;
const restrictedRoutesForAdmin = ['/member', '/users', '/communityProfile'];
if (isLoggedIn) {
if (role == 'superAdmin') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ const SecuredRouteForUser = (): JSX.Element => {
} else if (error) {
return <div>Error During Routing ...</div>;

Check warning on line 33 in src/components/UserPortal/SecuredRouteForUser/SecuredRouteForUser.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/UserPortal/SecuredRouteForUser/SecuredRouteForUser.tsx#L33

Added line #L33 was not covered by tests
} else {
const isLoggedIn = data.verifyRole.isAuthorized;
const role = data.verifyRole.role;
const role = data?.verifyRole?.role || '';
const isLoggedIn = data?.verifyRole?.isAuthorized ?? false;

if (isLoggedIn) {
if (role == 'user' || role == 'admin' || role == 'superAdmin') {
return <Outlet />;

Check warning on line 40 in src/components/UserPortal/SecuredRouteForUser/SecuredRouteForUser.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/UserPortal/SecuredRouteForUser/SecuredRouteForUser.tsx#L40

Added line #L40 was not covered by tests
Expand Down

0 comments on commit e4e3401

Please sign in to comment.