Skip to content

Commit 2992a04

Browse files
refactor: remove deprecated libraries routes and libraries-manager module (#148)
- Delete entire src/authz-module/libraries-manager/ directory - Remove LIBRARIES_USER_PATH and LIBRARIES_TEAM_PATH from ROUTES - Move ErrorPage component to src/authz-module/components/ErrorPage/ (still used as the module-level error boundary fallback) - Update index.tsx imports and remove library route definitions - Remove library-related test cases from index.test.tsx
1 parent 049ac62 commit 2992a04

42 files changed

Lines changed: 23 additions & 5028 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/authz-module/libraries-manager/ErrorPage/index.test.tsx renamed to src/authz-module/components/ErrorPage/index.test.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,68 @@ import { screen } from '@testing-library/react';
22
import userEvent from '@testing-library/user-event';
33
import { ErrorBoundary } from 'react-error-boundary';
44
import { renderWrapper } from '@src/setupTest';
5-
import LibrariesErrorFallback from './index';
5+
import ErrorFallback from './index';
66

77
const ThrowError = ({ error }: { error:Error }) => {
88
throw error;
99
return null;
1010
};
1111

12-
describe('LibrariesErrorFallback', () => {
12+
describe('ErrorFallback', () => {
1313
it('renders Access Denied for 401', () => {
1414
const error = { name: '', message: 'NO_ACCESS', customAttributes: { httpErrorStatus: 401 } };
1515
renderWrapper(
16-
<ErrorBoundary FallbackComponent={LibrariesErrorFallback}>
16+
<ErrorBoundary FallbackComponent={ErrorFallback}>
1717
<ThrowError error={error} />
1818
</ErrorBoundary>,
1919
);
2020
expect(screen.getByText(/Access Denied/i)).toBeInTheDocument();
21-
expect(screen.getByText(/Back to Libraries/i)).toBeInTheDocument();
21+
expect(screen.getByText(/Back to Studio/i)).toBeInTheDocument();
2222
});
2323

2424
it('renders Not Found for 400 error', () => {
2525
const error = { name: '', message: 'Axios Error (Response): 400', customAttributes: { httpErrorStatus: 400 } };
2626
renderWrapper(
27-
<ErrorBoundary FallbackComponent={LibrariesErrorFallback}>
27+
<ErrorBoundary FallbackComponent={ErrorFallback}>
2828
<ThrowError error={error} />
2929
</ErrorBoundary>,
3030
);
3131
expect(screen.getByText(/Page Not Found/i)).toBeInTheDocument();
32-
expect(screen.getByText(/Back to Libraries/i)).toBeInTheDocument();
32+
expect(screen.getByText(/Back to Studio/i)).toBeInTheDocument();
3333
});
3434

3535
it('renders Not Found for 404', () => {
3636
const error = { name: '', message: 'NOT_FOUND', customAttributes: { httpErrorStatus: 404 } };
3737
renderWrapper(
38-
<ErrorBoundary FallbackComponent={LibrariesErrorFallback}>
38+
<ErrorBoundary FallbackComponent={ErrorFallback}>
3939
<ThrowError error={error} />
4040
</ErrorBoundary>,
4141
);
4242
expect(screen.getByText(/Page Not Found/i)).toBeInTheDocument();
43-
expect(screen.getByText(/Back to Libraries/i)).toBeInTheDocument();
43+
expect(screen.getByText(/Back to Studio/i)).toBeInTheDocument();
4444
});
4545

4646
it('renders Server Error for 500 and shows reload', async () => {
4747
const error = { name: '', message: 'SERVER_ERROR', customAttributes: { httpErrorStatus: 500 } };
4848
renderWrapper(
49-
<ErrorBoundary FallbackComponent={LibrariesErrorFallback}>
49+
<ErrorBoundary FallbackComponent={ErrorFallback}>
5050
<ThrowError error={error} />
5151
</ErrorBoundary>,
5252
);
5353
expect(screen.getByText(/Something went wrong/i)).toBeInTheDocument();
5454
expect(screen.getByText(/Reload Page/i)).toBeInTheDocument();
55-
expect(screen.getByText(/Back to Libraries/i)).toBeInTheDocument();
55+
expect(screen.getByText(/Back to Studio/i)).toBeInTheDocument();
5656
});
5757

5858
it('renders generic error for other error error', () => {
5959
const error = { name: '', message: 'SOMETHING_ELSE', customAttributes: { httpErrorStatus: 418 } };
6060
renderWrapper(
61-
<ErrorBoundary FallbackComponent={LibrariesErrorFallback}>
61+
<ErrorBoundary FallbackComponent={ErrorFallback}>
6262
<ThrowError error={error} />
6363
</ErrorBoundary>,
6464
);
6565
expect(screen.getByText(/Error/i)).toBeInTheDocument();
66-
expect(screen.getByText(/Back to Libraries/i)).toBeInTheDocument();
66+
expect(screen.getByText(/Back to Studio/i)).toBeInTheDocument();
6767
});
6868

6969
it('calls reload action if present', async () => {
@@ -73,7 +73,7 @@ describe('LibrariesErrorFallback', () => {
7373
name: '', message: 'SERVER_ERROR', customAttributes: { httpErrorStatus: 500 }, refetch,
7474
};
7575
renderWrapper(
76-
<ErrorBoundary FallbackComponent={LibrariesErrorFallback} onReset={refetch}>
76+
<ErrorBoundary FallbackComponent={ErrorFallback} onReset={refetch}>
7777
<ThrowError error={error} />
7878
</ErrorBoundary>,
7979
);

src/authz-module/libraries-manager/ErrorPage/index.tsx renamed to src/authz-module/components/ErrorPage/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const ErrorPage = ({ error, resetErrorBoundary }: FallbackProps) => {
8080
{showBackButton && (
8181
<Button
8282
as={Hyperlink}
83-
destination={`${getConfig().COURSE_AUTHORING_MICROFRONTEND_URL}/libraries`}
83+
destination={`${getConfig().COURSE_AUTHORING_MICROFRONTEND_URL}`}
8484
className="m-2"
8585
variant={showReloadButton ? 'outline-primary' : 'primary'}
8686
>
@@ -93,5 +93,5 @@ const ErrorPage = ({ error, resetErrorBoundary }: FallbackProps) => {
9393
);
9494
};
9595

96-
const LibrariesErrorFallback = (props: FallbackProps) => <ErrorPage {...props} />;
97-
export default LibrariesErrorFallback;
96+
const ErrorFallback = (props: FallbackProps) => <ErrorPage {...props} />;
97+
export default ErrorFallback;

src/authz-module/libraries-manager/ErrorPage/messages.ts renamed to src/authz-module/components/ErrorPage/messages.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const messages = defineMessages({
1818
},
1919
'error.page.message.notFound': {
2020
id: 'error.page.message.notFound',
21-
defaultMessage: 'The library you are looking for could not be found.',
21+
defaultMessage: 'The resource you are looking for could not be found.',
2222
description: 'Error message when the resource is not found',
2323
},
2424
'error.page.title.server': {
@@ -48,8 +48,8 @@ const messages = defineMessages({
4848
},
4949
'error.page.action.back': {
5050
id: 'error.page.action.back',
51-
defaultMessage: 'Back to Libraries',
52-
description: 'Label for return to libraries action',
51+
defaultMessage: 'Back to Studio',
52+
description: 'Label for return to Studio action',
5353
},
5454
});
5555

src/authz-module/constants.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,6 @@ export const SKELETON_ROWS = Array.from({ length: 10 }).map(() => ({
530530

531531
export const ROUTES = {
532532
HOME_PATH: '/authz',
533-
LIBRARIES_TEAM_PATH: '/libraries/:libraryId',
534-
LIBRARIES_USER_PATH: '/libraries/:libraryId/:username',
535533
AUDIT_USER_PATH: '/user/:username',
536534
ASSIGN_ROLE_WIZARD_PATH: '/assign-role',
537535
};

src/authz-module/index.test.tsx

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1-
import { ComponentType, lazy } from 'react';
21
import { render, screen, waitFor } from '@testing-library/react';
3-
import { MemoryRouter, Outlet } from 'react-router-dom';
2+
import { MemoryRouter } from 'react-router-dom';
43
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
54
import { initializeMockApp } from '@edx/frontend-platform/testing';
65
import { IntlProvider } from '@edx/frontend-platform/i18n';
76
import { CustomErrors } from '@src/constants';
87
import AuthZModule from './index';
98

10-
jest.mock('./libraries-manager', () => ({
11-
// eslint-disable-next-line no-promise-executor-return
12-
LibrariesLayout: lazy(() => new Promise<{ default: ComponentType<any> }>(resolve => setTimeout(
13-
() => resolve({ default: () => <div><Outlet /></div> }),
14-
100,
15-
))),
16-
LibrariesTeamManager: () => <div>Libraries Team Page</div>,
17-
LibrariesUserManager: () => <div>Libraries User Page</div>,
18-
}));
19-
209
const createTestQueryClient = () => new QueryClient({
2110
defaultOptions: {
2211
queries: {
@@ -32,44 +21,6 @@ describe('AuthZModule', () => {
3221
authenticatedUser: { username: 'testuser' },
3322
});
3423
});
35-
it('renders LoadingPage then LibrariesTeamManager when route matches', async () => {
36-
const queryClient = createTestQueryClient();
37-
const path = '/libraries/lib:123';
38-
39-
render(
40-
<IntlProvider locale="en">
41-
<QueryClientProvider client={queryClient}>
42-
<MemoryRouter initialEntries={[path]}>
43-
<AuthZModule />
44-
</MemoryRouter>
45-
</QueryClientProvider>
46-
</IntlProvider>,
47-
);
48-
49-
expect(document.querySelector('.spinner-border')).toBeInTheDocument();
50-
51-
await waitFor(() => {
52-
expect(screen.getByText('Libraries Team Page')).toBeInTheDocument();
53-
});
54-
});
55-
56-
it('renders LoadingPage then LibrariesUserManager when user route matches', async () => {
57-
const queryClient = createTestQueryClient();
58-
const path = '/libraries/lib:123/testuser';
59-
60-
render(
61-
<IntlProvider locale="en">
62-
<QueryClientProvider client={queryClient}>
63-
<MemoryRouter initialEntries={[path]}>
64-
<AuthZModule />
65-
</MemoryRouter>
66-
</QueryClientProvider>
67-
</IntlProvider>,
68-
);
69-
await waitFor(() => {
70-
expect(screen.getByText('Libraries User Page')).toBeInTheDocument();
71-
});
72-
});
7324

7425
it('renders error boundary fallback when accessing unknown route', async () => {
7526
const queryClient = createTestQueryClient();

src/authz-module/index.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import { Routes, Route } from 'react-router-dom';
33
import { ErrorBoundary } from 'react-error-boundary';
44
import { QueryErrorResetBoundary } from '@tanstack/react-query';
55
import LoadingPage from '@src/components/LoadingPage';
6-
import LibrariesErrorFallback from '@src/authz-module/libraries-manager/ErrorPage';
6+
import ErrorFallback from '@src/authz-module/components/ErrorPage';
77
import { CustomErrors } from '@src/constants';
88
import { ToastManagerProvider } from '@src/components/ToastManager/ToastManagerContext';
9-
import { LibrariesUserManager, LibrariesLayout, LibrariesTeamManager } from './libraries-manager';
109
import AuthzHome from './authz-home';
1110
import AuditUserPage from './audit-user';
1211
import AssignRoleWizardPage from './role-assignation-wizard/AssignRoleWizardPage';
@@ -22,19 +21,12 @@ const NotFoundError = () => {
2221
const AuthZModule = () => (
2322
<QueryErrorResetBoundary>
2423
{({ reset }) => (
25-
<ErrorBoundary fallbackRender={LibrariesErrorFallback} onReset={reset}>
24+
<ErrorBoundary fallbackRender={ErrorFallback} onReset={reset}>
2625
<ToastManagerProvider>
2726
<Suspense fallback={<LoadingPage />}>
2827
<Routes>
29-
<Route element={<LibrariesLayout />}>
30-
<Route path={ROUTES.LIBRARIES_USER_PATH} element={<LibrariesUserManager />} />
31-
<Route path={ROUTES.LIBRARIES_TEAM_PATH} element={<LibrariesTeamManager />} />
32-
</Route>
3328
<Route index element={<AuthzHome />} />
34-
<Route
35-
path={ROUTES.AUDIT_USER_PATH}
36-
element={<AuditUserPage />}
37-
/>
29+
<Route path={ROUTES.AUDIT_USER_PATH} element={<AuditUserPage />} />
3830
<Route path={ROUTES.ASSIGN_ROLE_WIZARD_PATH} element={<AssignRoleWizardPage />} />
3931
<Route path="*" element={<NotFoundError />} />
4032
</Routes>

src/authz-module/libraries-manager/LibrariesTeamManager.test.tsx

Lines changed: 0 additions & 149 deletions
This file was deleted.

0 commit comments

Comments
 (0)