Skip to content

Commit

Permalink
Integrate spares definition with catalogue items and items #1162
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadkitenge committed Dec 18, 2024
1 parent 97400e7 commit d9388fb
Show file tree
Hide file tree
Showing 20 changed files with 860 additions and 512 deletions.
38 changes: 38 additions & 0 deletions cypress/e2e/with_mock_data/catalogueItems.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
})
);
});
Expand Down
23 changes: 23 additions & 0 deletions cypress/e2e/with_mock_data/items.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
Loading

0 comments on commit d9388fb

Please sign in to comment.