Skip to content

Commit 45e085a

Browse files
committed
Merge branch 'create-banner-when-spares-filter-is-applied-#1587' into spares-filter-button-bug-1588
2 parents 5c29ffe + 6652971 commit 45e085a

File tree

5 files changed

+27
-31
lines changed

5 files changed

+27
-31
lines changed

cypress/e2e/with_mock_data/items.cy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ describe('Items', () => {
508508

509509
cy.findByText('Spares Definition Filter Applied').should('exist');
510510
cy.findByLabelText(
511-
'Items that are contained within this system type Storage are classified as spares'
511+
'Items that are contained within the system type Storage are classified as spares'
512512
).should('exist');
513513

514514
cy.findByRole('button', { name: 'Clear Filters' }).click();
@@ -536,15 +536,15 @@ describe('Items', () => {
536536

537537
cy.findByText('Spares Definition Filter Applied').should('exist');
538538
cy.findByLabelText(
539-
'Items that are contained within this system type Storage are classified as spares'
539+
'Items that are contained within the system type Storage are classified as spares'
540540
).should('exist');
541541

542542
cy.findAllByRole('button', { name: 'Column Actions' }).eq(3).click();
543543
cy.findByText('Group by Asset Number').click();
544544

545545
cy.findByText('Spares Definition Filter Applied').should('exist');
546546
cy.findByLabelText(
547-
'Items that are contained within this system type Storage are classified as spares'
547+
'Items that are contained within the system type Storage are classified as spares'
548548
).should('exist');
549549

550550
cy.findByRole('button', { name: 'Clear Filters' }).click();

src/catalogue/items/catalogueItemsTable.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,11 @@ const CatalogueItemsTable = (props: CatalogueItemsTableProps) => {
823823
table.getFilteredSelectedRowModel().rows.length > 0 ||
824824
table.getState().grouping.length > 0;
825825
return {
826-
// Breadcrumbs + Mui table V2 + extra
827826
sx: {
828827
height: dense
829828
? '360.4px'
830829
: getPageHeightCalc(
830+
// Breadcrumbs + Mui table V2 + extra
831831
`50px + 110px + 48px ${showAlert ? '+ 58.75px' : ''}`
832832
),
833833
flexShrink: 1,

src/items/__snapshots__/itemsTable.component.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ exports[`Items Table > renders correctly part 1 due column virtualisation 1`] =
15231523
class="MuiCollapse-wrapperInner MuiCollapse-vertical css-1i4ywhz-MuiCollapse-wrapperInner"
15241524
>
15251525
<div
1526-
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-z99vq8-MuiPaper-root-MuiAlert-root"
1526+
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-ltczp2-MuiPaper-root-MuiAlert-root"
15271527
role="alert"
15281528
style="--Paper-shadow: none;"
15291529
>
@@ -3194,7 +3194,7 @@ exports[`Items Table > renders correctly part 2 due column virtualisation 1`] =
31943194
class="MuiCollapse-wrapperInner MuiCollapse-vertical css-1i4ywhz-MuiCollapse-wrapperInner"
31953195
>
31963196
<div
3197-
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-z99vq8-MuiPaper-root-MuiAlert-root"
3197+
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-ltczp2-MuiPaper-root-MuiAlert-root"
31983198
role="alert"
31993199
style="--Paper-shadow: none;"
32003200
>
@@ -5082,7 +5082,7 @@ exports[`Items Table > renders the dense table correctly 1`] = `
50825082
class="MuiCollapse-wrapperInner MuiCollapse-vertical css-1i4ywhz-MuiCollapse-wrapperInner"
50835083
>
50845084
<div
5085-
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-z99vq8-MuiPaper-root-MuiAlert-root"
5085+
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-colorInfo MuiAlert-standardInfo MuiAlert-standard css-ltczp2-MuiPaper-root-MuiAlert-root"
50865086
role="alert"
50875087
style="--Paper-shadow: none;"
50885088
>

src/items/itemsTable.component.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { fireEvent, screen, waitFor } from '@testing-library/react';
22
import userEvent, { UserEvent } from '@testing-library/user-event';
3+
import { DefaultBodyType, http, HttpResponse, PathParams } from 'msw';
34
import {
45
CatalogueCategory,
56
CatalogueItem,
67
SparesDefinition,
78
} from '../api/api.types';
9+
import { server } from '../mocks/server';
10+
import SystemTypesJSON from '../mocks/SystemTypes.json';
811
import {
912
getCatalogueCategoryById,
1013
getCatalogueItemById,
1114
renderComponentWithRouterProvider,
1215
} from '../testUtils';
1316
import ItemsTable, { ItemTableProps } from './itemsTable.component';
14-
import { server } from '../mocks/server';
15-
import { DefaultBodyType, http, HttpResponse, PathParams } from 'msw';
16-
import SystemTypesJSON from '../mocks/SystemTypes.json';
1717

1818
describe('Items Table', () => {
1919
vi.setConfig({ testTimeout: 10000 });
@@ -240,7 +240,7 @@ describe('Items Table', () => {
240240

241241
expect(
242242
screen.getByLabelText(
243-
'Items that are contained within this system type Storage are classified as spares'
243+
'Items that are contained within the system type Storage are classified as spares'
244244
)
245245
).toBeInTheDocument();
246246

@@ -282,7 +282,7 @@ describe('Items Table', () => {
282282

283283
expect(
284284
screen.getByLabelText(
285-
'Items that are contained within this system type Storage are classified as spares'
285+
'Items that are contained within the system type Storage are classified as spares'
286286
)
287287
).toBeInTheDocument();
288288

@@ -314,7 +314,7 @@ describe('Items Table', () => {
314314
).toBeInTheDocument();
315315
});
316316

317-
it('sets the spares definition filter and clears the spares filters (multiples systems types in spares definition)', async () => {
317+
it('sets the spares definition filter and clears the spares filters (multiple systems types in spares definition)', async () => {
318318
server.use(
319319
http.get<PathParams, DefaultBodyType, SparesDefinition>(
320320
'/v1/settings/spares-definition',
@@ -352,7 +352,7 @@ describe('Items Table', () => {
352352

353353
expect(
354354
screen.getByLabelText(
355-
'Items that are contained within these system types Storage, Scrapped are classified as spares'
355+
'Items that are contained within a system type of one of Storage or Scrapped are classified as spares'
356356
)
357357
).toBeInTheDocument();
358358

src/items/itemsTable.component.tsx

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { InfoOutlined } from '@mui/icons-material';
12
import AddIcon from '@mui/icons-material/Add';
23
import ClearIcon from '@mui/icons-material/Clear';
34
import DeleteIcon from '@mui/icons-material/Delete';
@@ -60,7 +61,6 @@ import {
6061
import DeleteItemDialog from './deleteItemDialog.component';
6162
import ItemDialog from './itemDialog.component';
6263
import ItemsDetailsPanel from './itemsDetailsPanel.component';
63-
import { InfoOutlined } from '@mui/icons-material';
6464

6565
export interface ItemTableProps {
6666
catalogueCategory: CatalogueCategory;
@@ -536,25 +536,17 @@ export function ItemsTable(props: ItemTableProps) {
536536
//MRT
537537
mrtTheme,
538538
//MUI
539-
muiToolbarAlertBannerProps: {
540-
sx: {
541-
'& .MuiAlert-message': {
542-
maxWidth: undefined,
543-
width: '100%',
544-
},
545-
},
546-
},
547539
muiTableContainerProps: ({ table }) => {
548540
const showAlert =
549541
table.getState().showAlertBanner ||
550542
table.getFilteredSelectedRowModel().rows.length > 0 ||
551543
table.getState().grouping.length > 0;
552544
return {
553-
// Breadcrumbs + Mui table V2 + extra
554545
sx: {
555546
height: dense
556547
? '360.4px'
557548
: getPageHeightCalc(
549+
// Breadcrumbs + Mui table V2 + extra
558550
`50px + 110px + 48px ${showAlert ? '+ 64px' : ''} ${isSparesFilterApplied ? ' + 54px' : ''}`
559551
),
560552
flexShrink: 1,
@@ -761,20 +753,24 @@ export function ItemsTable(props: ItemTableProps) {
761753
})}
762754
>
763755
<Grid container alignItems="center" sx={{ px: 1, py: 0.5 }}>
764-
<Grid size={2}> </Grid>
756+
<Grid size={2} />
765757
<Grid size={8}>
766758
<Box display="flex" alignItems="center" justifyContent="center">
767759
<Typography variant="inherit" sx={{ pr: 1 }}>
768760
Spares Definition Filter Applied
769761
</Typography>
770762
<Tooltip
771-
title={`Items that are contained within ${
763+
title={
772764
sparesDefinition.system_types.length === 1
773-
? 'this system type'
774-
: 'these system types'
775-
} ${sparesDefinition.system_types
776-
.map((sys) => sys.value)
777-
.join(', ')} are classified as spares`}
765+
? `Items that are contained within the system type ${sparesDefinition.system_types[0].value} are classified as spares`
766+
: `Items that are contained within a system type of one of ${sparesDefinition.system_types
767+
.map((sys) => sys.value)
768+
.join(', ')
769+
.replace(
770+
/, ([^,]*)$/,
771+
' or $1'
772+
)} are classified as spares`
773+
}
778774
>
779775
<InfoOutlined fontSize="small" />
780776
</Tooltip>

0 commit comments

Comments
 (0)