diff --git a/cypress/e2e/with_mock_data/catalogueItems.cy.ts b/cypress/e2e/with_mock_data/catalogueItems.cy.ts index 1c31bd91c..2ad44d17c 100644 --- a/cypress/e2e/with_mock_data/catalogueItems.cy.ts +++ b/cypress/e2e/with_mock_data/catalogueItems.cy.ts @@ -509,6 +509,26 @@ describe('Catalogue Items', () => { .should('include', '_blank'); // Check target attribute value }); + it('checks the href property of the number of spares (Table)', () => { + cy.findByRole('button', { name: 'Show/Hide columns' }).click(); + cy.findByText('Hide all').click(); + + cy.findByText('Number of spares').click(); + + cy.findAllByText('2') + .first() + .should('have.attr', 'href') + .should( + 'include', + '/catalogue/item/1/items?state=N4IgxgYiBcDaoEsAmMQIC4FMC2A6ArgM4CGA5pgPqHrHpEgA0IAbsQDb6YzwjoCeABy7QQ1AE4IAdqUYt2nVADlMAdxABfBqH5DU4qTKasOwkAFVCmFOoC6t9UA' + ); + + cy.findAllByText('2').first().click({ force: true }); + + cy.findByText('vYs9Vxx6yWbn').should('exist'); + cy.findByText('Zf7P8Qu8TD8c').should('not.exist'); + }); + it('displays the expired landing page message and navigates back to the catalogue home', () => { cy.visit('/catalogue/item/1fds'); @@ -910,6 +930,22 @@ describe('Catalogue Items', () => { cy.url().should('contain', 'catalogue/item/89/items'); }); + it('can navigate to an items page (with applied spares definition) from the landing page', () => { + cy.visit('/catalogue/5'); + cy.findByText('Energy Meters 26').click(); + cy.findByText('1') + .should('have.attr', 'href') + .should( + 'include', + '/catalogue/item/89/items?state=N4IgxgYiBcDaoEsAmMQIC4FMC2A6ArgM4CGA5pgPqHrHpEgA0IAbsQDb6YzwjoCeABy7QQ1AE4IAdqUYt2nVADlMAdxABfBqH5DU4qTKasOwkAFVCmFOoC6t9UA' + ); + + cy.findByText('1').click(); + + cy.findByText('qKcw2send4S8').should('exist'); + cy.findByText('0QcKayBCxRm4').should('not.exist'); + }); + it('opens add dialog for categories in directory and has functionality of duplicate', () => { cy.visit('/catalogue/5'); cy.findAllByLabelText('Toggle select row').first().click(); @@ -1059,6 +1095,7 @@ describe('Catalogue Items', () => { notes: 'Need to find new manufacturer. 26', created_time: '2024-01-01T12:00:00.000+00:00', modified_time: '2024-01-02T13:10:10.000+00:00', + number_of_spares: 1, }) ); expect(JSON.stringify(await patchRequests[1].json())).equal( @@ -1086,6 +1123,7 @@ describe('Catalogue Items', () => { notes: 'Need to find new manufacturer. 27', created_time: '2024-01-01T12:00:00.000+00:00', modified_time: '2024-01-02T13:10:10.000+00:00', + number_of_spares: 2, }) ); }); diff --git a/cypress/e2e/with_mock_data/items.cy.ts b/cypress/e2e/with_mock_data/items.cy.ts index 0e46a41fd..01c6f5b62 100644 --- a/cypress/e2e/with_mock_data/items.cy.ts +++ b/cypress/e2e/with_mock_data/items.cy.ts @@ -20,6 +20,29 @@ describe('Items', () => { cy.findByText('Beam Characterization').should('be.visible'); }); + it('should be able to set and unset spares filter', () => { + cy.visit('/catalogue/item/1/items'); + + cy.findByText('5YUQDDjKpz2z').should('exist'); + cy.findByText('vYs9Vxx6yWbn').should('exist'); + cy.findByText('PcfCM1jp0SUV').should('exist'); + cy.findByText('Zf7P8Qu8TD8c').should('exist'); + + cy.findByText('Apply spares filter').click(); + + cy.findByText('5YUQDDjKpz2z').should('not.exist'); + cy.findByText('vYs9Vxx6yWbn').should('exist'); + cy.findByText('PcfCM1jp0SUV').should('exist'); + cy.findByText('Zf7P8Qu8TD8c').should('not.exist'); + + cy.findByRole('button', { name: 'Clear Filters' }).click(); + + cy.findByText('5YUQDDjKpz2z').should('exist'); + cy.findByText('vYs9Vxx6yWbn').should('exist'); + cy.findByText('PcfCM1jp0SUV').should('exist'); + cy.findByText('Zf7P8Qu8TD8c').should('exist'); + }); + it('should be able to navigate back to the catalogue home step by step', () => { cy.visit('/catalogue/item/1/items/KvT2Ox7n'); diff --git a/src/admin/__snapshots__/adminCard.component.test.tsx.snap b/src/admin/__snapshots__/adminCard.component.test.tsx.snap index fc9d9d6cd..d44f961eb 100644 --- a/src/admin/__snapshots__/adminCard.component.test.tsx.snap +++ b/src/admin/__snapshots__/adminCard.component.test.tsx.snap @@ -69,351 +69,6 @@ exports[`AdminCard Component > dialog > renders correctly with "dialog" type 1`] `; -exports[`AdminCard Component > link > link > renders correctly with "page" type and link 1`] = ` - -
- -
-
-
-
-

- Go to Dashboard -

-
-
-
-
- -
-
-
- -
-
-
-
-

- Go to Dashboard -

-
-
-
-
- -
-
- -`; - -exports[`AdminCard Component > link > renders correctly with "page" type and link 1`] = ` - -
- -
-
-
-
-

- Go to Dashboard -

-
-
-
-
- -
-
-
- -
-
-
-
-

- Go to Dashboard -

-
-
-
-
- -
-
- -`; - -exports[`AdminCard Component > page > dialog > renders correctly with "dialog" type 1`] = ` - -
- -
-
- -
- -`; - -exports[`AdminCard Component > page > dialog > renders correctly with "dialog" type and link 1`] = ` - -
- -
-
- -
- -`; - -exports[`AdminCard Component > page > dialog > renders correctly with "page" type and link 1`] = ` - -
- -
-
- -
- -`; - exports[`AdminCard Component > page > renders correctly with "page" type 1`] = `
@@ -482,72 +137,3 @@ exports[`AdminCard Component > page > renders correctly with "page" type 1`] =
`; - -exports[`AdminCard Component > page > renders correctly with "page" type and link 1`] = ` - -
- -
-
-
-
-

- Go to Dashboard -

-
-
-
-
- -
-
-
- -
-
-
-
-

- Go to Dashboard -

-
-
-
-
- -
-
- -`; diff --git a/src/api/api.types.tsx b/src/api/api.types.tsx index e7d312262..4b1333255 100644 --- a/src/api/api.types.tsx +++ b/src/api/api.types.tsx @@ -191,6 +191,7 @@ export interface CatalogueItem Required> { id: string; properties: Property[]; + number_of_spares?: number; } // ------------------------------------ ITEMS ------------------------------------------------ diff --git a/src/catalogue/items/__snapshots__/catalogueItemsDetailsPanel.component.test.tsx.snap b/src/catalogue/items/__snapshots__/catalogueItemsDetailsPanel.component.test.tsx.snap index d3a66a7df..28ec6ad09 100644 --- a/src/catalogue/items/__snapshots__/catalogueItemsDetailsPanel.component.test.tsx.snap +++ b/src/catalogue/items/__snapshots__/catalogueItemsDetailsPanel.component.test.tsx.snap @@ -134,6 +134,25 @@ exports[`Catalogue Items details panel > renders details panel correctly (None v
+
+

+ Number of spares +

+

+ + 2 + +

+
@@ -698,6 +717,25 @@ exports[`Catalogue Items details panel > renders details panel correctly (when t
+
+

+ Number of spares +

+

+ + 2 + +

+
@@ -1262,6 +1300,25 @@ exports[`Catalogue Items details panel > renders details panel correctly (with o
+
+

+ Number of spares +

+

+ + 2 + +

+
@@ -1786,6 +1843,25 @@ exports[`Catalogue Items details panel > renders details panel correctly 1`] = `
+
+

+ Number of spares +

+

+ + 1 + +

+
@@ -2320,6 +2396,25 @@ exports[`Catalogue Items details panel > renders manufacturer panel correctly 1`
+
+

+ Number of spares +

+

+ + 1 + +

+
@@ -2853,6 +2948,25 @@ exports[`Catalogue Items details panel > renders notes panel correctly 1`] = `
+
+

+ Number of spares +

+

+ + 1 + +

+
@@ -3386,6 +3500,25 @@ exports[`Catalogue Items details panel > renders properties panel correctly 1`]
+
+

+ Number of spares +

+

+ + 1 + +

+
diff --git a/src/catalogue/items/__snapshots__/catalogueItemsTable.component.test.tsx.snap b/src/catalogue/items/__snapshots__/catalogueItemsTable.component.test.tsx.snap index 7ab38971e..7bd5bbaff 100644 --- a/src/catalogue/items/__snapshots__/catalogueItemsTable.component.test.tsx.snap +++ b/src/catalogue/items/__snapshots__/catalogueItemsTable.component.test.tsx.snap @@ -338,12 +338,12 @@ exports[`Catalogue Items Table > renders the dense table correctly 1`] = `
renders the dense table correctly 1`] = `

renders the dense table correctly 1`] = `

renders correctly part 2 due column virtualisation 1`] = Clear Filters + + + + + Apply spares filter + +
renders the dense table correctly 1`] = `
renders the dense table correctly 1`] = `

renders the dense table correctly 1`] = `

renders the dense table correctly 1`] = `

renders the dense table correctly 1`] = `

renders the dense table correctly 1`] = `