Skip to content

Commit

Permalink
Merge branch 'develop' into pagination-for-catalogue-categories-#219
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoGuarnaccia5 committed Jan 29, 2024
2 parents 849d7c7 + 7aa88f3 commit e016f2e
Show file tree
Hide file tree
Showing 96 changed files with 31,316 additions and 8,439 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: Upload coverage reports to Codecov
if: success()
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3
uses: codecov/codecov-action@4fe8c5f003fae66aa5ebb77cfd3e7bfbbda0b6b0 # v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

Expand All @@ -44,7 +44,7 @@ jobs:

- name: Upload Cypress screenshots
if: failure()
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4
with:
name: OperationsGateway Screenshots
path: cypress/screenshots
Expand Down
28 changes: 0 additions & 28 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

This file was deleted.

875 changes: 0 additions & 875 deletions .yarn/releases/yarn-3.7.0.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.2.cjs

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.7.0.cjs
yarnPath: .yarn/releases/yarn-4.0.2.cjs
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Specify a base image
FROM node:19.2-alpine3.15
FROM node:20.11-alpine3.19

# Set the working directory
WORKDIR /inventory-management-system-run
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Dockerfile to build and serve inventory management system

# Build stage
FROM node:18.12-alpine3.15 as builder
FROM node:20.11-alpine3.19 as builder

WORKDIR /inventory-management-system-build

Expand Down
108 changes: 94 additions & 14 deletions cypress/e2e/catalogue/catalogueCategory.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,67 @@ describe('Catalogue Category', () => {
cy.findBrowserMockedRequests({
method: 'POST',
url: '/v1/catalogue-categories',
}).should((patchRequests) => {
expect(patchRequests.length).equal(1);
const request = patchRequests[0];
expect(JSON.stringify(request.body)).equal(
}).should(async (postRequests) => {
expect(postRequests.length).equal(1);
const request = postRequests[0];
expect(JSON.stringify(await request.json())).equal(
'{"name":"test","is_leaf":false}'
);
});
});

it('opens actions menu and then closes', () => {
cy.findByRole('button', {
name: 'actions Motion catalogue category button',
}).click();

cy.findByRole('menuitem', {
name: 'edit Motion catalogue category button',
}).should('be.visible');
cy.findByRole('menuitem', {
name: 'save as Motion catalogue category button',
}).should('be.visible');
cy.findByRole('menuitem', {
name: 'delete Motion catalogue category button',
})
.should('be.visible')
.click();

cy.findByText('Cancel').click();

cy.findByRole('button', {
name: 'actions Motion catalogue category button',
}).should('be.visible');
});

it('"save as" a catalogue category', () => {
cy.findByRole('button', {
name: 'actions Motion catalogue category button',
}).click();
cy.findByText('Save as').click();

cy.startSnoopingBrowserMockedRequest();

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

cy.findBrowserMockedRequests({
method: 'POST',
url: '/v1/catalogue-categories',
}).should(async (postRequests) => {
expect(postRequests.length).equal(1);
const request = postRequests[0];
expect(JSON.stringify(await request.json())).equal(
'{"name":"Motion_copy_1","is_leaf":false}'
);
});
});

it('displays error message when user tries to delete a catalogue category that has children elements', () => {
cy.findByRole('button', {
name: 'actions Motion catalogue category button',
}).click();

cy.findByRole('menuitem', {
name: 'delete Motion catalogue category button',
}).click();

Expand All @@ -127,6 +177,10 @@ describe('Catalogue Category', () => {

it('delete a catalogue category', () => {
cy.findByRole('button', {
name: 'actions Beam Characterization catalogue category button',
}).click();

cy.findByRole('menuitem', {
name: 'delete Beam Characterization catalogue category button',
}).click();

Expand Down Expand Up @@ -177,10 +231,10 @@ describe('Catalogue Category', () => {
cy.findBrowserMockedRequests({
method: 'POST',
url: '/v1/catalogue-categories',
}).should((patchRequests) => {
expect(patchRequests.length).equal(1);
const request = patchRequests[0];
expect(JSON.stringify(request.body)).equal(
}).should(async (postRequests) => {
expect(postRequests.length).equal(1);
const request = postRequests[0];
expect(JSON.stringify(await request.json())).equal(
'{"name":"test","is_leaf":true,"catalogue_item_properties":[{"name":"Updated Field 1","type":"boolean","mandatory":false},{"name":"Updated Field 2","type":"number","unit":"","mandatory":false}]}'
);
});
Expand Down Expand Up @@ -220,6 +274,10 @@ describe('Catalogue Category', () => {
it('edits a catalogue category (non leaf node)', () => {
cy.visit('/catalogue/1');
cy.findByRole('button', {
name: 'actions Amp Meters catalogue category button',
}).click();

cy.findByRole('menuitem', {
name: 'edit Amp Meters catalogue category button',
}).click();
cy.findByLabelText('Name *').type('1');
Expand All @@ -231,16 +289,22 @@ describe('Catalogue Category', () => {
cy.findBrowserMockedRequests({
method: 'PATCH',
url: '/v1/catalogue-categories/:id',
}).should((patchRequests) => {
}).should(async (patchRequests) => {
expect(patchRequests.length).equal(1);
const request = patchRequests[0];
expect(JSON.stringify(request.body)).equal('{"name":"Amp Meters1"}');
expect(JSON.stringify(await request.json())).equal(
'{"name":"Amp Meters1"}'
);
expect(request.url.toString()).to.contain('1');
});
});

it('displays error message if none of the fields have changed', () => {
cy.findByRole('button', {
name: 'actions Beam Characterization catalogue category button',
}).click();

cy.findByRole('menuitem', {
name: 'edit Beam Characterization catalogue category button',
}).click();

Expand All @@ -257,6 +321,10 @@ describe('Catalogue Category', () => {
it('displays error message if it received an unknown error from the api', () => {
cy.visit('/catalogue/1');
cy.findByRole('button', {
name: 'actions Cameras catalogue category button',
}).click();

cy.findByRole('menuitem', {
name: 'edit Cameras catalogue category button',
}).click();
cy.findByLabelText('Name *').clear();
Expand All @@ -275,6 +343,10 @@ describe('Catalogue Category', () => {
it('edits a catalogue category with catalogue properties', () => {
cy.visit('/catalogue/1');
cy.findByRole('button', {
name: 'actions Voltage Meters catalogue category button',
}).click();

cy.findByRole('menuitem', {
name: 'edit Voltage Meters catalogue category button',
}).click();

Expand All @@ -288,10 +360,10 @@ describe('Catalogue Category', () => {
cy.findBrowserMockedRequests({
method: 'PATCH',
url: '/v1/catalogue-categories/:id',
}).should((patchRequests) => {
}).should(async (patchRequests) => {
expect(patchRequests.length).equal(1);
const request = patchRequests[0];
expect(JSON.stringify(request.body)).equal(
expect(JSON.stringify(await request.json())).equal(
'{"catalogue_item_properties":[{"name":"Updated Field","type":"number","unit":"volts","mandatory":true},{"name":"Accuracy","type":"string","mandatory":true}]}'
);
expect(request.url.toString()).to.contain('1');
Expand All @@ -301,6 +373,10 @@ describe('Catalogue Category', () => {
it('displays error message when duplicate names for properties are entered', () => {
cy.visit('/catalogue/1');
cy.findByRole('button', {
name: 'actions Voltage Meters catalogue category button',
}).click();

cy.findByRole('menuitem', {
name: 'edit Voltage Meters catalogue category button',
}).click();

Expand All @@ -322,6 +398,10 @@ describe('Catalogue Category', () => {
it('edits a catalogue category from a leaf node to a non-leaf node ', () => {
cy.visit('/catalogue/1');
cy.findByRole('button', {
name: 'actions Voltage Meters catalogue category button',
}).click();

cy.findByRole('menuitem', {
name: 'edit Voltage Meters catalogue category button',
}).click();
cy.findByLabelText('Catalogue Categories').click();
Expand All @@ -334,10 +414,10 @@ describe('Catalogue Category', () => {
cy.findBrowserMockedRequests({
method: 'PATCH',
url: '/v1/catalogue-categories/:id',
}).should((patchRequests) => {
}).should(async (patchRequests) => {
expect(patchRequests.length).equal(1);
const request = patchRequests[0];
expect(JSON.stringify(request.body)).equal(
expect(JSON.stringify(await request.json())).equal(
'{"name":"Voltage Meters1","is_leaf":false}'
);
expect(request.url.toString()).to.contain('1');
Expand Down
69 changes: 42 additions & 27 deletions cypress/e2e/catalogue/catalogueItems.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ describe('Catalogue Items', () => {
cy.findBrowserMockedRequests({
method: 'POST',
url: '/v1/catalogue-items',
}).should((patchRequests) => {
expect(patchRequests.length).equal(1);
const request = patchRequests[0];
expect(JSON.stringify(request.body)).equal(
}).should(async (postRequests) => {
expect(postRequests.length).equal(1);
const request = postRequests[0];
expect(JSON.stringify(await request.json())).equal(
'{"catalogue_category_id":"4","name":"test","cost_gbp":5000,"cost_to_rework_gbp":400,"days_to_replace":14,"days_to_rework":5,"description":"test Description","item_model_number":"MXtest","is_obsolete":false,"obsolete_reason":null,"obsolete_replacement_catalogue_item_id":null,"drawing_link":"https://example.com","drawing_number":"MX43242","manufacturer_id":"1","properties":[{"name":"Resolution","value":18},{"name":"Frame Rate","value":60},{"name":"Sensor Type","value":"IO"},{"name":"Sensor brand","value":"pixel"},{"name":"Broken","value":true},{"name":"Older than five years","value":false}]}'
);
});
Expand All @@ -56,10 +56,10 @@ describe('Catalogue Items', () => {
cy.findBrowserMockedRequests({
method: 'POST',
url: '/v1/catalogue-items',
}).should((patchRequests) => {
expect(patchRequests.length).equal(1);
const request = patchRequests[0];
expect(JSON.stringify(request.body)).equal(
}).should(async (postRequests) => {
expect(postRequests.length).equal(1);
const request = postRequests[0];
expect(JSON.stringify(await request.json())).equal(
'{"catalogue_category_id":"5","name":"Energy Meters 27_copy_1","cost_gbp":600,"cost_to_rework_gbp":89,"days_to_replace":7,"days_to_rework":60,"description":"Precision energy meters for accurate measurements. 27","item_model_number":null,"is_obsolete":false,"obsolete_reason":null,"obsolete_replacement_catalogue_item_id":null,"drawing_link":null,"drawing_number":null,"manufacturer_id":"3","properties":[{"name":"Measurement Range","value":2000}]}'
);
});
Expand All @@ -86,10 +86,10 @@ describe('Catalogue Items', () => {
cy.findBrowserMockedRequests({
method: 'POST',
url: '/v1/catalogue-items',
}).should((patchRequests) => {
expect(patchRequests.length).equal(1);
const request = patchRequests[0];
expect(JSON.stringify(request.body)).equal(
}).should(async (postRequests) => {
expect(postRequests.length).equal(1);
const request = postRequests[0];
expect(JSON.stringify(await request.json())).equal(
'{"catalogue_category_id":"4","name":"test","cost_gbp":5000,"cost_to_rework_gbp":null,"days_to_replace":14,"days_to_rework":null,"description":null,"item_model_number":null,"is_obsolete":false,"obsolete_reason":null,"obsolete_replacement_catalogue_item_id":null,"drawing_link":null,"drawing_number":null,"manufacturer_id":"1","properties":[{"name":"Resolution","value":18},{"name":"Sensor Type","value":"IO"},{"name":"Broken","value":true}]}'
);
});
Expand Down Expand Up @@ -221,7 +221,7 @@ describe('Catalogue Items', () => {
'exist'
);

cy.findByRole('link', { name: 'Back to Cameras table view' }).click();
cy.findByRole('link', { name: 'cameras' }).click();

cy.findByText('Cameras 1').should('exist');
cy.findByText('Cameras 2').should('exist');
Expand Down Expand Up @@ -281,13 +281,13 @@ describe('Catalogue Items', () => {
});

it('displays the expired landing page message and navigates back to the catalogue home', () => {
cy.visit('/catalogue/items/1fds');
cy.visit('/catalogue/item/1fds');

cy.findByText(
`This item doesn't exist. Please click the Home button to navigate to the catalogue home`
`This catalogue item doesn't exist. Please click the Home button on the top left of you screen to navigate to the catalogue home`
).should('exist');

cy.findByRole('link', { name: 'Home' }).click();
cy.findByRole('button', { name: 'navigate to catalogue home' }).click();

cy.findByText('Motion').should('exist');
});
Expand All @@ -303,7 +303,7 @@ describe('Catalogue Items', () => {
.should('be.visible')
.within(() => {
cy.contains(
'Catalogue item has children elements and cannot be deleted, please delete the children elements first'
'Catalogue item has child elements and cannot be deleted, please delete the children elements first'
);
});
cy.findByRole('button', { name: 'Continue' }).should('be.disabled');
Expand Down Expand Up @@ -356,9 +356,7 @@ describe('Catalogue Items', () => {
cy.findByRole('dialog')
.should('be.visible')
.within(() => {
cy.contains(
'Catalogue item has children elements and cannot be edited, please delete the children elements first'
);
cy.contains('Catalogue item has child elements and cannot be edited');
});
cy.findByRole('button', { name: 'Save' }).should('be.disabled');
});
Expand Down Expand Up @@ -388,11 +386,11 @@ describe('Catalogue Items', () => {
cy.findBrowserMockedRequests({
method: 'PATCH',
url: '/v1/catalogue-items/:id',
}).should((patchRequests) => {
}).should(async (patchRequests) => {
expect(patchRequests.length).equal(1);
const request = patchRequests[0];
expect(JSON.stringify(request.body)).equal(
'{"name":"test","description":null,"cost_gbp":6000,"cost_to_rework_gbp":894,"days_to_replace":71,"days_to_rework":605,"drawing_number":"MX43242","drawing_link":"https://example.com","item_model_number":"MXtest","manufacturer_id":"2"}'
expect(JSON.stringify(await request.json())).equal(
'{"name":"test","description":null,"cost_gbp":6000,"cost_to_rework_gbp":894,"days_to_replace":71,"days_to_rework":605,"drawing_number":"MX43242","drawing_link":"https://example.com","item_model_number":"MXtest","manufacturer_id":"1"}'
);
});
});
Expand All @@ -411,10 +409,10 @@ describe('Catalogue Items', () => {
cy.findBrowserMockedRequests({
method: 'PATCH',
url: '/v1/catalogue-items/:id',
}).should((patchRequests) => {
}).should(async (patchRequests) => {
expect(patchRequests.length).equal(1);
const request = patchRequests[0];
expect(JSON.stringify(request.body)).equal(
expect(JSON.stringify(await request.json())).equal(
'{"properties":[{"name":"Measurement Range","value":20000}]}'
);
});
Expand Down Expand Up @@ -551,12 +549,29 @@ describe('Catalogue Items', () => {
cy.findAllByText('Manufacturer Name').should('exist');
});

it('can navigate to an items replacement', () => {
it('can navigate to a catalogue items replacement', () => {
cy.visit('/catalogue/5');

cy.findAllByRole('link', { name: 'Click here' }).eq(1).click();

cy.url().should('contain', 'catalogue/item/6');
});

it('can navigate to an items page from the table view', () => {
cy.visit('/catalogue/5');

cy.findAllByRole('link', { name: 'Click here' }).eq(0).click();

cy.url().should('contain', 'catalogue/items/6');
cy.url().should('contain', 'catalogue/item/89/items');
});

it('can navigate to an items page from the landing page', () => {
cy.visit('/catalogue/5');
cy.findByText('Energy Meters 26').click();

cy.findAllByRole('link', { name: 'Items' }).eq(0).click();

cy.url().should('contain', 'catalogue/item/89/items');
});

it('can move multiple catalogue items', () => {
Expand Down
Loading

0 comments on commit e016f2e

Please sign in to comment.