diff --git a/packages/cpt-ui/__tests__/EpsRoleSelectionPage.test.tsx b/packages/cpt-ui/__tests__/EpsRoleSelectionPage.test.tsx
index e6f710bbbc..09087ed7e7 100644
--- a/packages/cpt-ui/__tests__/EpsRoleSelectionPage.test.tsx
+++ b/packages/cpt-ui/__tests__/EpsRoleSelectionPage.test.tsx
@@ -270,6 +270,43 @@ describe("RoleSelectionPage", () => {
expect(screen.getByText("Admin")).toBeInTheDocument()
})
+ it("doesnt render the roles without access title or table when no rolesWithoutAccess are present", () => {
+ mockUseAuth.mockReturnValue({
+ isSigningIn: false,
+ selectedRole: {
+ role_id: "1"
+ },
+ rolesWithAccess: [
+ {
+ role_id: "2",
+ role_name: "Pharmacist",
+ org_code: "ABC",
+ org_name: "Pharmacy Org"
+ },
+ {
+ role_id: "3",
+ role_name: "Technician",
+ org_code: "XYZ",
+ org_name: "Tech Org"
+ },
+ {
+ role_id: "1",
+ role_name: "Admin",
+ org_code: "ZZZ",
+ org_name: "Same Org"
+ }
+ ],
+ rolesWithoutAccess: [],
+ error: null,
+ hasSingleRoleAccess: jest.fn().mockReturnValue(false)
+ })
+ render(
+
+ )
+ expect(screen.queryByText("View your roles without access to the Prescription Tracker.")).not.toBeInTheDocument()
+ expect(screen.queryByTestId("roles-without-access-table")).not.toBeInTheDocument()
+ })
+
it("renders EpsCard components for roles with access", () => {
mockUseAuth.mockReturnValue({
isSigningIn: false,
diff --git a/packages/cpt-ui/src/components/EpsRoleSelectionPage.tsx b/packages/cpt-ui/src/components/EpsRoleSelectionPage.tsx
index f557ddaa94..4000f0910c 100644
--- a/packages/cpt-ui/src/components/EpsRoleSelectionPage.tsx
+++ b/packages/cpt-ui/src/components/EpsRoleSelectionPage.tsx
@@ -352,7 +352,6 @@ export default function RoleSelectionPage({
)}
-
{(auth.rolesWithAccess.length > 0) && (roleComponentProps.rolesWithAccess.length > 0) && (
@@ -398,39 +397,39 @@ export default function RoleSelectionPage({
)}
-
-
- {rolesWithoutAccessHeader}
-
-
- {roles_without_access_table_title}
-
-
-
-
-
- {organisation}
- {role}
-
-
-
- {roleComponentProps.rolesWithoutAccess.map(
- (roleItem: RolesWithoutAccessProps) => (
-
-
- {roleItem.orgName} (ODS: {roleItem.odsCode})
-
-
- {roleItem.roleName}
-
-
- )
- )}
-
-
-
-
-
+ {roleComponentProps.rolesWithoutAccess?.length > 0 && (
+
+ {rolesWithoutAccessHeader}
+
+
+ {roles_without_access_table_title}
+
+
+
+
+
+ {organisation}
+ {role}
+
+
+
+ {roleComponentProps.rolesWithoutAccess.map(
+ (roleItem: RolesWithoutAccessProps) => (
+
+
+ {roleItem.orgName} (ODS: {roleItem.odsCode})
+
+
+ {roleItem.roleName}
+
+
+ ))}
+
+
+
+
+
+ )}
}