From f0298dc9ebee2d16bd55b0b24d55da1343a49311 Mon Sep 17 00:00:00 2001 From: Diana Olarte Date: Wed, 24 Sep 2025 21:57:55 +1000 Subject: [PATCH] feat: create a loading page and the AuthZModule --- src/authz-module/constants.ts | 25 +++++++++++++++++++ src/authz-module/index.test.tsx | 43 +++++++++++++++++++++++++++++++++ src/authz-module/index.tsx | 17 ++++++++++++- src/components/LoadingPage.tsx | 16 ++++++++++++ 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 src/authz-module/constants.ts create mode 100644 src/authz-module/index.test.tsx create mode 100644 src/components/LoadingPage.tsx diff --git a/src/authz-module/constants.ts b/src/authz-module/constants.ts new file mode 100644 index 0000000..2da6c73 --- /dev/null +++ b/src/authz-module/constants.ts @@ -0,0 +1,25 @@ +export interface TeamMember { + displayName: string; + username: string; + email: string; + roles: string[]; +} + +export interface LibraryMetadata { + id: string; + org: string; + title: string; + slug: string; +} + +export interface TableCellValue { + row: { + original: T; + }; +} + + +export const ROUTES = { + LIBRARIES_TEAM_PATH: '/libraries/:libraryId', + LIBRARIES_USER_PATH: '/libraries/user/:username' +}; diff --git a/src/authz-module/index.test.tsx b/src/authz-module/index.test.tsx new file mode 100644 index 0000000..dcc018b --- /dev/null +++ b/src/authz-module/index.test.tsx @@ -0,0 +1,43 @@ +import { ComponentType, lazy } from 'react'; +import { render, screen, waitFor } from '@testing-library/react'; +import { MemoryRouter } from 'react-router-dom'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import AuthZModule from './index'; + +jest.mock('./libraries-manager/LibrariesAuthZManager', () => { + return lazy(() => + new Promise<{ default: ComponentType }>(resolve => + setTimeout(() => resolve({ default: () =>
Loaded
}), 100) + ) + ); +}); + +const createTestQueryClient = () => + new QueryClient({ + defaultOptions: { + queries: { + retry: false, + }, + }, + }); + +describe('AuthZModule', () => { + it('renders LoadingPage then LibrariesAuthZManager when route matches', async () => { + const queryClient = createTestQueryClient(); + const path = '/libraries/lib:123'; + + render( + + + + + + ); + + expect(screen.getByTestId('loading-page')).toBeInTheDocument(); + + await waitFor(() => { + expect(screen.getByTestId('libraries-manager')).toBeInTheDocument(); + }); + }); +}); diff --git a/src/authz-module/index.tsx b/src/authz-module/index.tsx index 0eacb4a..b42e041 100644 --- a/src/authz-module/index.tsx +++ b/src/authz-module/index.tsx @@ -1,5 +1,20 @@ +import { Suspense } from 'react'; +import { Routes, Route } from 'react-router-dom'; +import { ErrorBoundary } from '@edx/frontend-platform/react'; +import LoadingPage from '@src/components/LoadingPage'; +import LibrariesAuthZManager from './libraries-manager/LibrariesAuthZManager'; +import { ROUTES } from './constants'; + +import './index.scss'; + const AuthZModule = () => ( -
AuthZ Module
+ + }> + + } /> + + + ); export default AuthZModule; diff --git a/src/components/LoadingPage.tsx b/src/components/LoadingPage.tsx new file mode 100644 index 0000000..bba9389 --- /dev/null +++ b/src/components/LoadingPage.tsx @@ -0,0 +1,16 @@ +import { Spinner, Container } from '@openedx/paragon'; + +const LoadingPage= () => { + return ( + + + + ); +}; + +export default LoadingPage;