Skip to content
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
4 changes: 2 additions & 2 deletions cypress/e2e/with_mock_data/catalogueCategories.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('Catalogue Category', () => {
name: 'Test ' + index.toString(),
parent_id: null,
code: index.toString(),
is_flagged: false,
is_leaf: false,
created_time: '2024-01-01T12:00:00.000+00:00',
modified_time: '2024-01-02T13:10:10.000+00:00',
Expand Down Expand Up @@ -109,8 +110,6 @@ describe('Catalogue Category', () => {
});
cy.findByText('This catalogue category is not critical.');

cy.findByRole('button', { name: 'Go to page 2' }).click();

cy.findByRole('dialog')
.should('be.visible')
.within(() => {
Expand Down Expand Up @@ -146,6 +145,7 @@ describe('Catalogue Category', () => {
'?state=N4IgDiBcpghg5gUwMoEsBeioBYCsAacBRASQDsATRADygAYBfBoA'
);

cy.findByText('Test 1').should('exist');
cy.findByText('Test 1').click();
cy.location('search').should('eq', '');
cy.findByRole('combobox', { name: 'Categories per page' }).within(() =>
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/with_mock_data/catalogueItems.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,11 +809,12 @@ describe('Catalogue Items', () => {
);

cy.findByText('Cameras 25').should('exist');
cy.findByText('Cameras 1').should('not.exist');

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

cy.findByText('Cameras 25').should('exist');
cy.findByText('Cameras 1').should('exist');
cy.findByText('Cameras 25').should('not.exist');

cy.location('search').should('eq', '');
});
Expand Down
30 changes: 15 additions & 15 deletions cypress/e2e/with_mock_data/items.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,21 +890,21 @@ describe('Items', () => {
).should('exist');

cy.findByText('Attachments').click();
cy.findByText('Total Attachments: 20').should('be.visible');
cy.findByText('Total Attachments: 35').should('be.visible');

cy.findAllByText('safety-protocols.pdf').should('have.length', 4);
cy.findAllByText('camera-setup-guide.docx').should('have.length', 4);
cy.findAllByText('experiment-results.rtf').should('have.length', 4);
cy.findAllByText('laser-calibration.txt').should('have.length', 3);
cy.findAllByText('safety-protocols.pdf').should('have.length', 8);
cy.findAllByText('camera-setup-guide.docx').should('have.length', 8);
cy.findAllByText('experiment-results.rtf').should('have.length', 7);
cy.findAllByText('laser-calibration.txt').should('have.length', 7);
cy.findByText('Last modified').scrollIntoView();
cy.findAllByText('02 Jan 2024 13:10').should('have.length', 15);
cy.findAllByText('02 Jan 2024 13:10').should('have.length', 30);

cy.findByRole('button', { name: 'Go to page 2' }).scrollIntoView();
cy.findByRole('button', { name: 'Go to page 2' }).click();
cy.findAllByText('safety-protocols.pdf').should('have.length', 1);
cy.findAllByText('camera-setup-guide.docx').should('have.length', 1);
cy.findAllByText('experiment-results.rtf').should('have.length', 1);
cy.findAllByText('laser-calibration.txt').should('have.length', 2);
cy.findAllByText('experiment-results.rtf').should('have.length', 2);
cy.findAllByText('laser-calibration.txt').should('have.length', 1);
cy.findByText('Last modified').scrollIntoView();
cy.findAllByText('02 Jan 2024 13:10').should('have.length', 5);
});
Expand All @@ -916,17 +916,17 @@ describe('Items', () => {
).should('exist');

cy.findByText('Attachments').click();
cy.findAllByText('Safety Protocols').should('have.length', 4);
cy.findAllByText('Camera Setup Guide').should('have.length', 4);
cy.findAllByText('Safety Protocols').should('have.length', 8);
cy.findAllByText('Camera Setup Guide').should('have.length', 8);

cy.findByRole('button', { name: 'Clear Filters' }).should('be.disabled');
cy.findByLabelText('Filter by File name').type('camera');
cy.findAllByText('Safety Protocols').should('not.exist');
cy.findAllByText('Camera Setup Guide').should('have.length', 5);
cy.findAllByText('Camera Setup Guide').should('have.length', 9);

cy.findByRole('button', { name: 'Clear Filters' }).click();
cy.findAllByText('Safety Protocols').should('have.length', 4);
cy.findAllByText('Camera Setup Guide').should('have.length', 4);
cy.findAllByText('Safety Protocols').should('have.length', 8);
cy.findAllByText('Camera Setup Guide').should('have.length', 8);
cy.findByRole('button', { name: 'Clear Filters' }).should('be.disabled');
});

Expand Down Expand Up @@ -1223,13 +1223,13 @@ describe('Items', () => {
).should('exist');

cy.findByText('Gallery').click();
cy.findAllByText('stfc-logo-blue-text.png').should('have.length', 8);
cy.findAllByText('stfc-logo-blue-text.png').should('have.length', 15);
cy.findByRole('button', { name: 'Show/Hide filters' }).click();
cy.findByRole('button', { name: 'Clear Filters' }).should('be.disabled');
cy.findByLabelText('Filter by File name').type('logo1.png');
cy.findByAltText('test').should('not.exist');
cy.findByRole('button', { name: 'Clear Filters' }).click();
cy.findAllByText('stfc-logo-blue-text.png').should('have.length', 8);
cy.findAllByText('stfc-logo-blue-text.png').should('have.length', 15);
cy.findByRole('button', { name: 'Show/Hide filters' }).click();
cy.findByLabelText('Filter by File name').should('not.visible');
});
Expand Down
72 changes: 36 additions & 36 deletions cypress/e2e/with_mock_data/systems.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,21 @@ describe('Systems', () => {
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(0)
.within(() => {
cy.findByText('15').should('be.visible');
cy.findByText('30').should('be.visible');
});
cy.findAllByRole('combobox', { name: 'Rows per page' }).eq(0).click();
cy.findByRole('listbox').within(() => {
cy.findByText(30).click();
cy.findByText(45).click();
});
cy.location('search').should(
'eq',
'?subState=N4IgDiBcpghg5gUwMoEsBeioGYAMAacBRASQDsATRADylwF96g'
'?subState=N4IgDiBcpghg5gUwMoEsBeioBYCsAacBRASQDsATRADygAYBfBoA'
);
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(0)
.within(() => {
cy.findByText('15').should('not.exist');
cy.findByText('30').should('be.visible');
cy.findByText('30').should('not.exist');
cy.findByText('45').should('be.visible');
});

// Rows per page (items)
Expand All @@ -108,23 +108,23 @@ describe('Systems', () => {
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(1)
.within(() => {
cy.findByText('15').should('be.visible');
cy.findByText('30').should('be.visible');
});
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(1)
.click({ force: true });
cy.findByRole('listbox').within(() => {
cy.findByText(30).click();
cy.findByText(45).click();
});
cy.location('search', { timeout: 10000 }).should(
'eq',
'?subState=N4IgDiBcpghg5gUwMoEsBeioGYAMAacBRASQDsATRADylwF96g&state=N4IgDiBcpghg5gUwMoEsBeioGYAMAacBRASQDsATRADylwF96g'
'?subState=N4IgDiBcpghg5gUwMoEsBeioBYCsAacBRASQDsATRADygAYBfBoA&state=N4IgDiBcpghg5gUwMoEsBeioBYCsAacBRASQDsATRADygAYBfBoA'
);
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(1)
.within(() => {
cy.findByText('15').should('not.exist');
cy.findByText('30').should('be.visible');
cy.findByText('30').should('not.exist');
cy.findByText('45').should('be.visible');
});

//Ensure same state is recovered
Expand All @@ -134,33 +134,33 @@ describe('Systems', () => {
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(0)
.within(() => {
cy.findByText('15').should('not.exist');
cy.findByText('30').should('be.visible');
cy.findByText('30').should('not.exist');
cy.findByText('45').should('be.visible');
});
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(1)
.within(() => {
cy.findByText('30').should('not.exist');
cy.findByText('15').should('be.visible');
cy.findByText('45').should('not.exist');
cy.findByText('30').should('be.visible');
});
cy.location('search').should(
'eq',
'?subState=N4IgDiBcpghg5gUwMoEsBeioGYAMAacBRASQDsATRADylwF96g'
'?subState=N4IgDiBcpghg5gUwMoEsBeioBYCsAacBRASQDsATRADygAYBfBoA'
);

cy.go('back');
cy.findByText('Smaller laser').should('be.visible');
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(0)
.within(() => {
cy.findByText('30').should('not.exist');
cy.findByText('15').should('be.visible');
cy.findByText('45').should('not.exist');
cy.findByText('30').should('be.visible');
});
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(1)
.within(() => {
cy.findByText('30').should('not.exist');
cy.findByText('15').should('be.visible');
cy.findByText('45').should('not.exist');
cy.findByText('30').should('be.visible');
});
cy.location('search').should('eq', '');
});
Expand All @@ -176,21 +176,21 @@ describe('Systems', () => {
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(0)
.within(() => {
cy.findByText('15').should('be.visible');
cy.findByText('30').should('be.visible');
});
cy.findAllByRole('combobox', { name: 'Rows per page' }).eq(0).click();
cy.findByRole('listbox').within(() => {
cy.findByText(30).click();
cy.findByText(45).click();
});
cy.location('search').should(
'eq',
'?subState=N4IgDiBcpghg5gUwMoEsBeioGYAMAacBRASQDsATRADylwF96g'
'?subState=N4IgDiBcpghg5gUwMoEsBeioBYCsAacBRASQDsATRADygAYBfBoA'
);
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(0)
.within(() => {
cy.findByText('15').should('not.exist');
cy.findByText('30').should('be.visible');
cy.findByText('30').should('not.exist');
cy.findByText('45').should('be.visible');
});

// Rows per page (items)
Expand All @@ -201,23 +201,23 @@ describe('Systems', () => {
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(1)
.within(() => {
cy.findByText('15').should('be.visible');
cy.findByText('30').should('be.visible');
});
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(1)
.click({ force: true });
cy.findByRole('listbox').within(() => {
cy.findByText(30).click();
cy.findByText(45).click();
});
cy.location('search').should(
'eq',
'?subState=N4IgDiBcpghg5gUwMoEsBeioGYAMAacBRASQDsATRADylwF96g&state=N4IgDiBcpghg5gUwMoEsBeioGYAMAacBRASQDsATRADylwF96g'
'?subState=N4IgDiBcpghg5gUwMoEsBeioBYCsAacBRASQDsATRADygAYBfBoA&state=N4IgDiBcpghg5gUwMoEsBeioBYCsAacBRASQDsATRADygAYBfBoA'
);
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(1)
.within(() => {
cy.findByText('15').should('not.exist');
cy.findByText('30').should('be.visible');
cy.findByText('30').should('not.exist');
cy.findByText('45').should('be.visible');
});

// Navigate deeper
Expand All @@ -228,10 +228,10 @@ describe('Systems', () => {
cy.findByText('Pulse Laser').should('be.visible');
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(0)
.within(() => cy.findByText('15').should('be.visible'));
.within(() => cy.findByText('30').should('be.visible'));
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(1)
.within(() => cy.findByText('15').should('be.visible'));
.within(() => cy.findByText('30').should('be.visible'));
cy.location('search').should('eq', '');

//Ensure same state is recovered
Expand All @@ -244,19 +244,19 @@ describe('Systems', () => {
// Rows per page
cy.location('search').should(
'eq',
'?subState=N4IgDiBcpghg5gUwMoEsBeioGYAMAacBRASQDsATRADylwF96g&state=N4IgDiBcpghg5gUwMoEsBeioGYAMAacBRASQDsATRADylwF96g'
'?subState=N4IgDiBcpghg5gUwMoEsBeioBYCsAacBRASQDsATRADygAYBfBoA&state=N4IgDiBcpghg5gUwMoEsBeioBYCsAacBRASQDsATRADygAYBfBoA'
);
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(0)
.within(() => {
cy.findByText('15').should('not.exist');
cy.findByText('30').should('be.visible');
cy.findByText('30').should('not.exist');
cy.findByText('45').should('be.visible');
});
cy.findAllByRole('combobox', { name: 'Rows per page' })
.eq(1)
.within(() => {
cy.findByText('15').should('not.exist');
cy.findByText('30').should('be.visible');
cy.findByText('30').should('not.exist');
cy.findByText('45').should('be.visible');
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/api/attachments.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('attachments api functions', () => {
expect(result.current.isSuccess).toBeTruthy();
});

expect(result.current.data?.length).toEqual(20);
expect(result.current.data?.length).toEqual(35);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/api/images.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('images api functions', () => {
expect(result.current.isSuccess).toBeTruthy();
});

expect(result.current.data?.length).toEqual(20);
expect(result.current.data?.length).toEqual(35);
});

it('sends request to fetch primary image data and returns successful response', async () => {
Expand Down
21 changes: 12 additions & 9 deletions src/catalogue/category/catalogueCardView.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import DeleteIcon from '@mui/icons-material/Delete';
import DriveFileMoveOutlinedIcon from '@mui/icons-material/DriveFileMoveOutlined';
import EditIcon from '@mui/icons-material/Edit';
import FolderCopyOutlinedIcon from '@mui/icons-material/FolderCopyOutlined';
import InfoOutlined from '@mui/icons-material/InfoOutlined';
import SaveAsIcon from '@mui/icons-material/SaveAs';
import {
Box,
Expand Down Expand Up @@ -34,8 +35,17 @@ import {
useGetCatalogueCategories,
useGetCatalogueCategory,
} from '../../api/catalogueCategories';
import { APISettingsContext } from '../../apiConfigProvider.component';
import CardViewFilters from '../../common/cardView/cardViewFilters.component';
import {
DEFAULT_ROWS_PER_PAGE_VALUE,
ROWS_PER_PAGE_OPTIONS,
} from '../../common/consts';
import ErrorPage from '../../common/errorPage.component';
import MRTTopTableAlert from '../../common/mrtTopTableAlert.component';
import { usePreservedTableState } from '../../common/preservedTableState.component';
import { useAppSelector } from '../../state/hook';
import { selectCriticality } from '../../state/slices/criticalitySlice';
import {
COLUMN_FILTER_BOOLEAN_OPTIONS,
COLUMN_FILTER_FUNCTIONS,
Expand All @@ -53,13 +63,6 @@ import {
} from '../../utils';
import CatalogueCard from './catalogueCard.component';
import CatalogueCategoryDialog from './catalogueCategoryDialog.component';

import InfoOutlined from '@mui/icons-material/InfoOutlined';
import { APISettingsContext } from '../../apiConfigProvider.component';
import ErrorPage from '../../common/errorPage.component';
import MRTTopTableAlert from '../../common/mrtTopTableAlert.component';
import { useAppSelector } from '../../state/hook';
import { selectCriticality } from '../../state/slices/criticalitySlice';
import CatalogueCategoryDirectoryDialog from './catalogueCategoryDirectoryDialog.component';
import DeleteCatalogueCategoryDialog from './deleteCatalogueCategoryDialog.component';

Expand Down Expand Up @@ -363,7 +366,7 @@ function CatalogueCardView() {

const { preservedState, onPreservedStatesChange } = usePreservedTableState({
initialState: {
pagination: { pageSize: 30, pageIndex: 0 },
pagination: { pageSize: DEFAULT_ROWS_PER_PAGE_VALUE, pageIndex: 0 },
columnFilterFns: initialColumnFilterFnState,
},
storeInUrl: true,
Expand Down Expand Up @@ -433,7 +436,7 @@ function CatalogueCardView() {
},
muiPaginationProps: {
color: 'secondary',
rowsPerPageOptions: [30, 45, 60],
rowsPerPageOptions: ROWS_PER_PAGE_OPTIONS,
shape: 'rounded',
variant: 'outlined',
},
Expand Down
Loading
Loading