diff --git a/plugins/rbac/src/components/Router.test.tsx b/plugins/rbac/src/components/Router.test.tsx
index ce4fb2acd5..830aceb646 100644
--- a/plugins/rbac/src/components/Router.test.tsx
+++ b/plugins/rbac/src/components/Router.test.tsx
@@ -32,6 +32,10 @@ jest.mock('./CreateRole/EditRolePage', () => ({
EditRolePage: () =>
EditRole
,
}));
+jest.mock('@backstage/core-components', () => ({
+ ErrorPage: jest.fn().mockImplementation(() => Mocked ErrorPage
),
+}));
+
jest.mock('@backstage/plugin-permission-react', () => ({
RequirePermission: jest
.fn()
@@ -67,6 +71,17 @@ describe('Router component', () => {
expect(screen.queryByText('RBAC')).not.toBeInTheDocument();
});
+ it('should render ErrorPage when rbac-backend plugin is disabled', () => {
+ configMock.getOptionalBoolean.mockReturnValueOnce(false);
+ render(
+
+
+ ,
+ );
+
+ expect(screen.queryByText('Mocked ErrorPage')).toBeInTheDocument();
+ });
+
it('renders RoleOverviewPage when path matches roleRouteRef', () => {
render(
diff --git a/plugins/rbac/src/components/Router.tsx b/plugins/rbac/src/components/Router.tsx
index f487586f4b..396d4c81f6 100644
--- a/plugins/rbac/src/components/Router.tsx
+++ b/plugins/rbac/src/components/Router.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import { Route, Routes } from 'react-router-dom';
+import { ErrorPage } from '@backstage/core-components';
import { configApiRef, useApi } from '@backstage/core-plugin-api';
import { RequirePermission } from '@backstage/plugin-permission-react';
@@ -25,7 +26,13 @@ export const Router = ({ useHeader = true }: { useHeader?: boolean }) => {
const isRBACPluginEnabled = config.getOptionalBoolean('permission.enabled');
if (!isRBACPluginEnabled) {
- return null;
+ return (
+
+ );
}
return (