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

nested routes for systems #1213 #1217

Merged
merged 11 commits into from
Jan 9, 2025
Merged
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
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: 'Systems 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: 'Systems 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
23 changes: 21 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import { MicroFrontendId } from './app.types';
import Catalogue from './catalogue/catalogue.component';
import CatalogueItemsLandingPage from './catalogue/items/catalogueItemsLandingPage.component';
import ErrorPage from './common/errorPage.component';
import ConfigProvider from './configProvider.component';
import handleIMS_APIError from './handleIMS_APIError';
import { HomePage } from './homePage/homePage.component';
Expand All @@ -49,6 +50,7 @@
tokenRefreshed,
} from './state/scigateway.actions';
import Systems from './systems/systems.component';
import SystemsLayout from './systems/systemsLayout.component';
import ViewTabs from './view/viewTabs.component';

export const paths = {
Expand All @@ -59,7 +61,8 @@
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 @@ -115,7 +118,23 @@
path: paths.item,
Component: ItemsLandingPage,
},
{ path: paths.systems, Component: Systems },
{
path: paths.systems,
Component: SystemsLayout,
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 133 in src/App.tsx

View check run for this annotation

Codecov / codecov/patch

src/App.tsx#L130-L133

Added lines #L130 - L133 were not covered by tests
),
},
],
},
{
path: paths.manufacturers,
Component: ManufacturerLayout,
Expand Down
141 changes: 141 additions & 0 deletions src/systems/__snapshots__/systemsLayout.component.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Systems Layout > renders root systems correctly 1`] = `
<DocumentFragment>
<div
class="MuiBox-root css-v2kfba"
>
<div
class="MuiGrid-root MuiGrid-container css-1r501zp-MuiGrid-root"
>
<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>
</DocumentFragment>
`;

exports[`Systems Layout > renders units breadcrumbs correctly 1`] = `
<DocumentFragment>
<div
class="MuiBox-root css-v2kfba"
>
<div
class="MuiGrid-root MuiGrid-container css-1r501zp-MuiGrid-root"
>
<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>
</DocumentFragment>
`;
Loading
Loading