Skip to content

Commit

Permalink
Renamed adminContainer to adminLayout for better clarity #1211
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadkitenge committed Jan 6, 2025
1 parent 650ceea commit c48ffc9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 108 deletions.
6 changes: 3 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AxiosError } from 'axios';
import { enGB } from 'date-fns/locale/en-GB';
import { RouterProvider, createBrowserRouter } from 'react-router-dom';
import AdminCardView from './admin/adminCardView.component';
import AdminContainer from './admin/adminContainer.component';
import AdminLayout from './admin/adminLayout.component';
import Units from './admin/units/units.component';
import UsageStatuses from './admin/usageStatuses/usageStatuses.component';
import {
Expand Down Expand Up @@ -84,9 +84,9 @@ const router = createBrowserRouter([
{ path: paths.homepage, Component: HomePage },
{
path: paths.admin,
Component: AdminContainer,
Component: AdminLayout,
children: [
{ path: '', Component: AdminCardView },
{ index: true, Component: AdminCardView },
{ path: paths.adminUnits, Component: Units },
{ path: paths.adminUsageStatuses, Component: UsageStatuses },
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`AdminPage > renders admin home page correctly 1`] = `
exports[`Admin Layout > renders admin layout page correctly 1`] = `
<DocumentFragment>
<div
class="MuiGrid-root MuiGrid-container css-11lq3yg-MuiGrid-root"
Expand Down Expand Up @@ -56,7 +56,7 @@ exports[`AdminPage > renders admin home page correctly 1`] = `
</DocumentFragment>
`;

exports[`AdminPage > renders units breadcrumbs correctly 1`] = `
exports[`Admin Layout > renders units breadcrumbs correctly 1`] = `
<DocumentFragment>
<div
class="MuiGrid-root MuiGrid-container css-11lq3yg-MuiGrid-root"
Expand Down Expand Up @@ -148,99 +148,7 @@ exports[`AdminPage > renders units breadcrumbs correctly 1`] = `
</DocumentFragment>
`;

exports[`AdminPage > renders units breadcrumbs correctly 2`] = `
<DocumentFragment>
<div
class="MuiGrid-root MuiGrid-container css-11lq3yg-MuiGrid-root"
>
<div
style="display: flex; align-items: center;"
>
<div
class="MuiBox-root css-1n998dz"
>
<div
class="MuiBox-root css-70qvj9"
>
<span
aria-label="Admin Home"
class=""
data-mui-internal-clone-element="true"
>
<button
aria-label="navigate to admin home"
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-78trlr-MuiButtonBase-root-MuiIconButton-root"
tabindex="0"
type="button"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root"
data-testid="HomeIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"
/>
</svg>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
</span>
<nav
aria-label="breadcrumb"
class="MuiTypography-root MuiTypography-body1 MuiBreadcrumbs-root css-1mc59t7-MuiTypography-root-MuiBreadcrumbs-root"
>
<ol
class="MuiBreadcrumbs-ol css-4pdmu4-MuiBreadcrumbs-ol"
>
<li
class="MuiBreadcrumbs-li"
>
<div
class="MuiBox-root css-8zy5qf"
/>
</li>
<li
aria-hidden="true"
class="MuiBreadcrumbs-separator css-1wuw8dw-MuiBreadcrumbs-separator"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeSmall css-ptiqhd-MuiSvgIcon-root"
data-testid="NavigateNextIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"
/>
</svg>
</li>
<li
class="MuiBreadcrumbs-li"
>
<p
aria-label="Usage statuses"
class="MuiTypography-root MuiTypography-body1 css-1qs6ojv-MuiTypography-root"
data-mui-internal-clone-element="true"
role="tooltip"
>
Usage statuses
</p>
</li>
</ol>
</nav>
</div>
</div>
</div>
</div>
</DocumentFragment>
`;

exports[`AdminPage > renders usage statuses breadcrumbs correctly 1`] = `
exports[`Admin Layout > renders usage statuses breadcrumbs correctly 1`] = `
<DocumentFragment>
<div
class="MuiGrid-root MuiGrid-container css-11lq3yg-MuiGrid-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { screen, waitFor } from '@testing-library/react';
import userEvent, { UserEvent } from '@testing-library/user-event';
import { paths } from '../App';
import { renderComponentWithRouterProvider } from '../testUtils';
import AdminContainer from './adminContainer.component';
import AdminLayout from './adminLayout.component';

const mockedUseNavigate = vi.fn();

Expand All @@ -11,21 +11,17 @@ vi.mock('react-router-dom', async () => ({
useNavigate: () => mockedUseNavigate,
}));

describe('AdminPage', () => {
describe('Admin Layout', () => {
let user: UserEvent;

beforeEach(() => {
user = userEvent.setup();
});
const createView = (path: string, urlPathKey: keyof typeof paths) => {
return renderComponentWithRouterProvider(
<AdminContainer />,
urlPathKey,
path
);
return renderComponentWithRouterProvider(<AdminLayout />, urlPathKey, path);
};

it('renders admin home page correctly', async () => {
it('renders admin layout page correctly', async () => {
const view = createView('/admin-ims', 'admin');

await waitFor(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const adminBreadCrumbsTrails: { [key: string]: [string, string] } = {
['usage-statuses']: ['usage-statuses', 'Usage statuses'],
};

function AdminContainer() {
function AdminLayout() {
const navigateToAdminFunction = useNavigateToAdminFunction();
const adminPageName = useGetAdminPageName();

Expand Down Expand Up @@ -68,4 +68,4 @@ function AdminContainer() {
);
}

export default AdminContainer;
export default AdminLayout;

0 comments on commit c48ffc9

Please sign in to comment.