Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSEGOG-361 view all users on admin page #514

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cypress/e2e/users.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
describe('Users', () => {
it('should users table correctly', () => {
cy.visit('/admin/users');
cy.findByText('user1').should('exist');
cy.findAllByText('FedID').should('have.length', 5);
cy.findAllByText('/users POST').should('have.length', 3);
});

it('should load 404 page correctly', () => {
cy.visit('/admin/invalid');

cy.findByText(
`We're sorry, the page you requested was not found on the server. If you entered the URL manually please check your spelling and try again. Otherwise, return to the`,
{ exact: false }
).should('exist');

cy.findByRole('link', { name: 'home page' }).should('exist');
});
});
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
"hacktimer": "1.1.3",
"husky": "9.1.1",
"loglevel": "1.9.1",
"material-react-table": "^2.13.0",
"msw": "2.7.0",
"react": "18.3.1",
"react-colorful": "5.6.1",
"react-dom": "18.3.1",
"react-redux": "9.2.0",
"react-router-dom": "7.1.1",
"single-spa-react": "6.0.2",
"typescript": "5.6.2",
"vite": "5.4.11"
Expand Down
7 changes: 7 additions & 0 deletions public/operationsgateway-settings.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
"link": "/og",
"displayName": "OperationsGateway",
"order": 0
},
{
"section": "Admin",
"link": "/admin/users",
"displayName": "Users",
"admin": true,
"order": 1
}
],
"pluginHost": "http://localhost:3000"
Expand Down
7 changes: 7 additions & 0 deletions server/e2e-settings-mocked.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
"link": "/operationsgateway",
"displayName": "OperationsGateway",
"order": 0
},
{
"section": "Admin",
"link": "/admin/users",
"displayName": "Users",
"admin": true,
"order": 1
}
],
"pluginHost": "http://localhost:3000"
Expand Down
3 changes: 3 additions & 0 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { flushPromises } from './testUtils';
vi.mock('loglevel');

describe('App', () => {
afterEach(() => {
vi.restoreAllMocks();
});
it('renders without crashing', async () => {
const el = document.createElement('div');
const root = createRoot(el);
Expand Down
48 changes: 45 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import {
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import React from 'react';
import { connect, Provider } from 'react-redux';
import { createBrowserRouter, Outlet, RouterProvider } from 'react-router';
import UsersTable from './admin/users/usersTable.component';
import './App.css';
import { MicroFrontendId } from './app.types';
import OGThemeProvider from './ogThemeProvider.component';
import PageNotFoundComponent from './pageNotFound/pageNotFound.component';
import Preloader from './preloader/preloader.component';
import SettingsMenuItems from './settingsMenuItems.component';
import { requestPluginRerender } from './state/scigateway.actions';
Expand All @@ -18,6 +21,12 @@ import ViewTabs from './views/viewTabs.component';
import OpenWindows from './windows/openWindows.component';
import { WindowContextProvider } from './windows/windowContext';

export const paths = {
any: '*',
admin: '/admin',
adminUsers: '/admin/users',
};

const queryClient = new QueryClient({
defaultOptions: {
queries: {
Expand All @@ -41,7 +50,7 @@ function mapPreloaderStateToProps(state: RootState): { loading: boolean } {

export const ConnectedPreloader = connect(mapPreloaderStateToProps)(Preloader);

const App: React.FunctionComponent = () => {
const Layout: React.FunctionComponent = () => {
const dispatch = store.dispatch;
React.useEffect(() => {
dispatch(configureApp());
Expand Down Expand Up @@ -80,7 +89,7 @@ const App: React.FunctionComponent = () => {
<Preloader loading={true}>Finished loading</Preloader>
}
>
<ViewTabs />
<Outlet />
{/* Open windows is it's own component so that the open windows are always mounted
no matter which other components the user has mounted in ViewTabs etc. */}
<OpenWindows />
Expand All @@ -96,4 +105,37 @@ const App: React.FunctionComponent = () => {
);
};

export default App;
const router = createBrowserRouter(
[
{
Component: Layout,
children: [
{ path: paths.any, Component: ViewTabs },
{
path: paths.admin,
Component: Outlet,
ErrorBoundary: PageNotFoundComponent,
children: [
{ path: paths.adminUsers, Component: UsersTable },
{
path: '*',
Component: PageNotFoundComponent,
},
],
},
],
},
],
{
future: {
v7_relativeSplatPath: true,
v7_fetcherPersist: true,
v7_normalizeFormMethod: true,
v7_partialHydration: true,
v7_skipActionErrorRevalidation: true,
},
}
);
export default function App() {
return <RouterProvider router={router} />;
}
Loading
Loading