Skip to content

Commit

Permalink
nested routes for systems #1213
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadkitenge committed Dec 20, 2024
1 parent 85b30b6 commit 4b3fb09
Show file tree
Hide file tree
Showing 9 changed files with 436 additions and 243 deletions.
6 changes: 4 additions & 2 deletions cypress/e2e/with_api/systems/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ export const copyToSystems = (values: {
.click();
}

cy.findByRole('button', { name: 'Copy to' }).click();
cy.findByRole('button', { name: 'Subsystems more options' }).click();
cy.findByRole('menuitem', { name: 'Copy to' }).click();

cy.findByRole('dialog').within(() => {
cy.findByText('Storage').click();
Expand Down Expand Up @@ -109,7 +110,8 @@ export const moveToSystems = (values: {
.click();
}

cy.findByRole('button', { name: 'Move to' }).click();
cy.findByRole('button', { name: 'Subsystems more options' }).click();
cy.findByRole('menuitem', { name: 'Move to' }).click();

cy.findByRole('dialog').within(() => {
cy.findByText('Storage').click();
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/with_api/systems/systems.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
addSystems,
copyToSystems,
deleteSystem,
duplicateSystem,
editSystems,
modifySystem,
moveItemToSystem,
moveToSystems,
duplicateSystem,
} from './functions';

describe('systems', () => {
Expand Down
10 changes: 7 additions & 3 deletions cypress/e2e/with_mock_data/systems.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,9 @@ describe('Systems', () => {
cy.findByRole('row', { name: 'Toggle select row Pulse Laser' })
.findByRole('checkbox')
.click();
cy.findByRole('button', { name: 'Move to' }).click();

cy.findByRole('button', { name: 'Systems more options' }).click();
cy.findByRole('menuitem', { name: 'Copy to' }).click();

cy.findByRole('dialog')
.should('be.visible')
Expand All @@ -684,7 +686,8 @@ describe('Systems', () => {
.findByRole('checkbox')
.click();

cy.findByRole('button', { name: 'Move to' }).click();
cy.findByRole('button', { name: 'Systems more options' }).click();
cy.findByRole('menuitem', { name: 'Move to' }).click();

cy.startSnoopingBrowserMockedRequest();

Expand Down Expand Up @@ -727,7 +730,8 @@ describe('Systems', () => {
.findByRole('checkbox')
.click();

cy.findByRole('button', { name: 'Copy to' }).click();
cy.findByRole('button', { name: 'Systems more options' }).click();
cy.findByRole('menuitem', { name: 'Copy to' }).click();

cy.startSnoopingBrowserMockedRequest();

Expand Down
28 changes: 22 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
tokenRefreshed,
} from './state/scigateway.actions';
import Systems from './systems/systems.component';
import SystemsContainer from './systems/systemsContainer.component';
import ViewTabs from './view/viewTabs.component';

export const paths = {
Expand All @@ -49,7 +50,8 @@ export const paths = {
adminUsageStatuses: '/admin-ims/usage-statuses',
homepage: '/ims',
catalogue: '/catalogue/*',
systems: '/systems/*',
systems: '/systems',
system: '/systems/:system_id',
manufacturers: '/manufacturers',
manufacturer: '/manufacturers/:manufacturer_id',
catalogueItem: '/catalogue/item/:catalogue_item_id',
Expand Down Expand Up @@ -80,14 +82,12 @@ const router = createBrowserRouter([
{
Component: Layout,
children: [
{ path: paths.any, Component: ViewTabs },
{ path: paths.root, Component: HomePage },
{ path: paths.homepage, Component: HomePage },
{
path: paths.admin,
Component: AdminContainer,
children: [
{ path: '', Component: AdminCardView },
{ index: true, Component: AdminCardView },
{ path: paths.adminUnits, Component: Units },
{ path: paths.adminUsageStatuses, Component: UsageStatuses },
{
Expand All @@ -111,12 +111,28 @@ const router = createBrowserRouter([
path: paths.item,
Component: ItemsLandingPage,
},
{ path: paths.systems, Component: Systems },
{
path: paths.systems,
Component: SystemsContainer,
children: [
{ index: true, Component: Systems },
{ path: paths.system, Component: Systems },
{
path: '*',
Component: () => (
<ErrorPage
boldErrorText="Invalid System Route"
errorText="The system route you are trying to access doesn't exist. Please click the Home button to navigate back to the System Home page."
/>

Check warning on line 126 in src/App.tsx

View check run for this annotation

Codecov / codecov/patch

src/App.tsx#L123-L126

Added lines #L123 - L126 were not covered by tests
),
},
],
},
{
path: paths.manufacturers,
Component: ManufacturerContainer,
children: [
{ path: '', Component: ManufacturerTable },
{ index: true, Component: ManufacturerTable },
{ path: paths.manufacturer, Component: ManufacturerLandingPage },
{
path: '*',
Expand Down
149 changes: 149 additions & 0 deletions src/systems/__snapshots__/systemsContainer.component.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Systems Container > renders root systems correctly 1`] = `
<DocumentFragment>
<div
class="MuiBox-root css-10klw3m"
>
<div
class="MuiGrid-root MuiGrid-container css-15vbc7x-MuiGrid-root"
>
<div
style="display: flex; align-items: center; padding-top: 20px; padding-bottom: 20px;"
>
<div
class="MuiBox-root css-70qvj9"
>
<span
aria-label="Systems Home"
class=""
data-mui-internal-clone-element="true"
>
<button
aria-label="navigate to systems 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"
/>
</nav>
</div>
</div>
</div>
</div>
</DocumentFragment>
`;

exports[`Systems Container > renders units breadcrumbs correctly 1`] = `
<DocumentFragment>
<div
class="MuiBox-root css-10klw3m"
>
<div
class="MuiGrid-root MuiGrid-container css-15vbc7x-MuiGrid-root"
>
<div
style="display: flex; align-items: center; padding-top: 20px; padding-bottom: 20px;"
>
<div
class="MuiBox-root css-70qvj9"
>
<span
aria-label="Systems Home"
class=""
data-mui-internal-clone-element="true"
>
<button
aria-label="navigate to systems 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="Giant laser"
class="MuiTypography-root MuiTypography-body1 css-1qs6ojv-MuiTypography-root"
data-mui-internal-clone-element="true"
role="tooltip"
>
Giant laser
</p>
</li>
</ol>
</nav>
</div>
</div>
</div>
</div>
</DocumentFragment>
`;
Loading

0 comments on commit 4b3fb09

Please sign in to comment.