Skip to content

Commit

Permalink
Merge branch 'develop' into add-and-view-a-spares-definition-#1161
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdimanteto committed Jan 15, 2025
2 parents aa3e8bc + e5f156f commit 16f9001
Show file tree
Hide file tree
Showing 68 changed files with 4,699 additions and 2,375 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
uses: codecov/test-results-action@4e79e65778be1cecd5df25e14af1eafb6df80ea9 # v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

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

- name: Upload Cypress screenshots
if: failure()
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: Inventory management system Screenshots
path: cypress/screenshots
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:

- name: Upload Cypress screenshots
if: failure()
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: Inventory management system (with api) Screenshots
path: cypress/screenshots
Expand Down Expand Up @@ -202,7 +202,7 @@ jobs:
images: ${{ secrets.HARBOR_URL }}/ims

- name: Build and push Docker image to Harbor
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0
with:
context: .
file: ./Dockerfile.prod
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
latest=false
- name: Build and push Docker image to Harbor
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0
with:
context: .
file: ./Dockerfile.prod
Expand Down
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:22.12.0-alpine3.20@sha256:96cc8323e25c8cc6ddcb8b965e135cfd57846e8003ec0d7bcec16c5fd5f6d39f
FROM node:22.13.0-alpine3.20@sha256:db8dcb90326a0116375414e9a7c068a6b87a4422b7da37b5c6cd026f7c7835d3

# 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:22.12.0-alpine3.20@sha256:96cc8323e25c8cc6ddcb8b965e135cfd57846e8003ec0d7bcec16c5fd5f6d39f as builder
FROM node:22.13.0-alpine3.20@sha256:db8dcb90326a0116375414e9a7c068a6b87a4422b7da37b5c6cd026f7c7835d3 as builder

WORKDIR /inventory-management-system-build

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/with_api/app.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('App', () => {
cy.visit('/catalogue');
cy.wait('@getCatalogueCategoryDataRoot', { timeout: 10000 });
cy.findByText(
'There are no catalogue categories. Please add a category using the plus icon in the top left of your screen'
'There are no catalogue categories. Please add a category using the button in the top left of your screen.'
).should('exist');
});
});
2 changes: 1 addition & 1 deletion cypress/e2e/with_api/catalogueCategories/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const modifyCatalogueCategory = (
cy.findByLabelText('Catalogue Items').click();
}
} else {
cy.findByRole('button', { name: 'add catalogue category' }).click();
cy.findByRole('button', { name: 'Add Catalogue Category' }).click();
}

if (values.name !== undefined) {
Expand Down
10 changes: 10 additions & 0 deletions cypress/e2e/with_mock_data/admin.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ describe('Admin Page', () => {
cy.findByText('Usage Statuses').should('be.visible');
});

it('display 404 page for invalid route', () => {
cy.visit('/admin-ims/not_exist');
cy.findByText(
`We're sorry, the page you requested was not found on the server. If you entered the URL manually please check your spelling and try again. Otherwise, return to the`,
{ exact: false }
).should('exist');

cy.findByRole('link', { name: 'admin home page' }).should('exist');
});

describe('UsageStatus', () => {
beforeEach(() => {
cy.visit('/admin-ims/usage-statuses');
Expand Down
35 changes: 15 additions & 20 deletions cypress/e2e/with_mock_data/catalogueCategories.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Catalogue Category', () => {
name: 'Test ' + index.toString(),
parent_id: null,
code: index.toString(),
is_leaf: true,
is_leaf: false,
created_time: '2024-01-01T12:00:00.000+00:00',
modified_time: '2024-01-02T13:10:10.000+00:00',
properties: [],
Expand Down Expand Up @@ -129,7 +129,7 @@ describe('Catalogue Category', () => {
});

it('display error message when there is no name when adding a catalogue category', () => {
cy.findByRole('button', { name: 'add catalogue category' }).click();
cy.findByRole('button', { name: 'Add Catalogue Category' }).click();
cy.findByRole('button', { name: 'Save' }).click();
cy.findByRole('dialog')
.should('be.visible')
Expand All @@ -149,7 +149,7 @@ describe('Catalogue Category', () => {
});

it('adds a catalogue category where isLeaf is false', () => {
cy.findByRole('button', { name: 'add catalogue category' }).click();
cy.findByRole('button', { name: 'Add Catalogue Category' }).click();
cy.findByLabelText('Name *').type('test');

cy.startSnoopingBrowserMockedRequest();
Expand Down Expand Up @@ -240,7 +240,7 @@ describe('Catalogue Category', () => {
});

it('adds a catalogue category where isLeaf is true', () => {
cy.findByRole('button', { name: 'add catalogue category' }).click();
cy.findByRole('button', { name: 'Add Catalogue Category' }).click();
cy.findByLabelText('Name *').type('test');

cy.findByLabelText('Catalogue Items').click();
Expand Down Expand Up @@ -296,7 +296,7 @@ describe('Catalogue Category', () => {
});

it('adds a catalogue category where isLeaf is true with a list of allowed values', () => {
cy.findByRole('button', { name: 'add catalogue category' }).click();
cy.findByRole('button', { name: 'Add Catalogue Category' }).click();
cy.findByLabelText('Name *').type('test');

cy.findByLabelText('Catalogue Items').click();
Expand Down Expand Up @@ -353,7 +353,7 @@ describe('Catalogue Category', () => {
});

it('displays the allowed values list error states missing values (Text)', () => {
cy.findByRole('button', { name: 'add catalogue category' }).click();
cy.findByRole('button', { name: 'Add Catalogue Category' }).click();
cy.findByLabelText('Name *').type('test');

cy.findByLabelText('Catalogue Items').click();
Expand Down Expand Up @@ -383,7 +383,7 @@ describe('Catalogue Category', () => {
});

it('displays the allowed values list error states duplicate values (Text)', () => {
cy.findByRole('button', { name: 'add catalogue category' }).click();
cy.findByRole('button', { name: 'Add Catalogue Category' }).click();
cy.findByLabelText('Name *').type('test');

cy.findByLabelText('Catalogue Items').click();
Expand Down Expand Up @@ -415,7 +415,7 @@ describe('Catalogue Category', () => {
});

it('displays the allowed values list error states and check if the error states are in the correct location (number)', () => {
cy.findByRole('button', { name: 'add catalogue category' }).click();
cy.findByRole('button', { name: 'Add Catalogue Category' }).click();
cy.findByLabelText('Name *').type('test');

cy.findByLabelText('Catalogue Items').click();
Expand Down Expand Up @@ -445,7 +445,7 @@ describe('Catalogue Category', () => {
});

it('displays error message when duplicate names for properties are entered', () => {
cy.findByRole('button', { name: 'add catalogue category' }).click();
cy.findByRole('button', { name: 'Add Catalogue Category' }).click();
cy.findByLabelText('Name *').type('test');

cy.findByLabelText('Catalogue Items').click();
Expand Down Expand Up @@ -816,7 +816,7 @@ describe('Catalogue Category', () => {
it('category with no data displays no results found', () => {
cy.visit('/catalogue/16');
cy.findByText(
'There are no catalogue categories. Please add a category using the plus icon in the top left of your screen'
'There are no catalogue categories. Please add a category using the button in the top left of your screen.'
).should('exist');
});

Expand All @@ -828,18 +828,13 @@ describe('Catalogue Category', () => {
});

it('expired url displays search not found message', () => {
cy.visit('/catalogue/not-exist');
cy.visit('/catalogue/not_exist');
cy.findByText(
'The category you searched for does not exist. Please navigate home by pressing the home button at the top left of your screen.'
`We're sorry, the page you requested was not found on the server. If you entered the URL manually please check your spelling and try again. Otherwise, return to the`,
{ exact: false }
).should('exist');
});

it('add button disabled when expired url is used', () => {
cy.visit('/catalogue/not-exist');

cy.findByRole('button', { name: 'add catalogue category' }).should(
'be.disabled'
);
cy.findByRole('link', { name: 'catalogue home page' }).should('exist');
});

it('when root has no data it displays no categories error message', () => {
Expand All @@ -849,7 +844,7 @@ describe('Catalogue Category', () => {
statusCode: 200,
});
cy.findByText(
'There are no catalogue categories. Please add a category using the plus icon in the top left of your screen'
'There are no catalogue categories. Please add a category using the button in the top left of your screen.'
).should('exist');
});

Expand Down
34 changes: 28 additions & 6 deletions cypress/e2e/with_mock_data/catalogueItems.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ describe('Catalogue Items', () => {
afterEach(() => {
cy.clearMocks();
});

it('should navigate back to the catalogue items table from the landing page using the breadcrumbs', () => {
cy.visit('/catalogue/5/items/89');

cy.findByRole('link', { name: 'Energy Meters' }).click();

cy.findByRole('button', { name: 'Add Catalogue Item' }).should('exist');
});
it('adds a catalogue item', () => {
cy.findByRole('button', { name: 'Add Catalogue Item' }).click();

Expand Down Expand Up @@ -510,17 +518,31 @@ describe('Catalogue Items', () => {
});

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

cy.findByText(
`This catalogue item doesn't exist. Please click the Home button on the top left of your screen to navigate to the catalogue home.`
`We're sorry, the page you requested was not found on the server. If you entered the URL manually please check your spelling and try again. Otherwise, return to the`,
{ exact: false }
).should('exist');

cy.findByRole('link', { name: 'catalogue home page' }).should('exist');

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

cy.findByText('Motion').should('exist');
});

it('displays the expired landing page message if the catalogue_category_id does not match the catalogue_item_id ', () => {
cy.visit('/catalogue/4/items/89');

cy.findByText(
`We're sorry, the page you requested was not found on the server. If you entered the URL manually please check your spelling and try again. Otherwise, return to the`,
{ exact: false }
).should('exist');

cy.findByRole('link', { name: 'catalogue home page' }).should('exist');
});

it('displays error message when user tries to delete a catalogue item that has children elements', () => {
cy.visit('/catalogue/5');
cy.findAllByLabelText('Row Actions').eq(1).click();
Expand Down Expand Up @@ -739,7 +761,7 @@ describe('Catalogue Items', () => {

it('can load and clear date filters', () => {
cy.visit(
'/catalogue/4?state=N4IgxgYiBcDaoEsAmNwEMAuaA2B7A5gK4CmAkhsQLYB0luSCAZgsUgPoYKXEgA0IANxwkY8EBgCeABx7QQSTD35DsIuQCYADOoAsAWk0BGAwGYAKps3RL1zdUuaAWiAC%2BvUJJmoAzhgBOCAB2%2BHyCwrIgrgC6LjFAA'
'/catalogue/4/items?state=N4IgxgYiBcDaoEsAmNwEMAuaA2B7A5gK4CmAkhsQLYB0luSCAZgsUgPoYKXEgA0IANxwkY8EBgCeABx7QQSTD35DsIuQCYADOoAsAWk0BGAwGYAKps3RL1zdUuaAWiAC%2BvUJJmoAzhgBOCAB2%2BHyCwrIgrgC6LjFAA'
);

cy.findByText('Cameras 25').should('exist');
Expand Down Expand Up @@ -890,15 +912,15 @@ describe('Catalogue Items', () => {

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

cy.url().should('contain', 'catalogue/item/6');
cy.url().should('contain', 'catalogue/5/items/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/item/89/items');
cy.url().should('contain', 'catalogue/5/items/89/items');
});

it('can navigate to an items page from the landing page', () => {
Expand All @@ -907,7 +929,7 @@ describe('Catalogue Items', () => {

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

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

it('opens add dialog for categories in directory and has functionality of duplicate', () => {
Expand Down
10 changes: 10 additions & 0 deletions cypress/e2e/with_mock_data/homePage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,14 @@ describe('IMS HomePage', () => {
'https://www.clf.stfc.ac.uk/Pages/EPAC-Applications.aspx'
);
});
it('displays error message for invalid homepage route', () => {
cy.visit('/ims/fdsf');

cy.findByText(
`We're sorry, the page you requested was not found on the server. If you entered the URL manually please check your spelling and try again. Otherwise, return to the`,
{ exact: false }
).should('exist');

cy.findByRole('link', { name: 'home page' }).should('exist');
});
});
42 changes: 39 additions & 3 deletions cypress/e2e/with_mock_data/items.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,47 @@ import { delay, HttpResponse } from 'msw';

describe('Items', () => {
beforeEach(() => {
cy.visit('/catalogue/item/1/items');
cy.visit('/catalogue/4/items/1/items');
});
afterEach(() => {
cy.clearMocks();
});

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

cy.findByText(
`We're sorry, the page you requested was not found on the server. If you entered the URL manually please check your spelling and try again. Otherwise, return to the`,
{ exact: false }
).should('exist');

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

cy.findByText('Motion').should('exist');
});

it('displays the expired landing page message if the catalogue_category_id does not match the catalogue_item_id ', () => {
cy.visit('/catalogue/5/items/1/items/KvT2Ox7n');

cy.findByText(
`We're sorry, the page you requested was not found on the server. If you entered the URL manually please check your spelling and try again. Otherwise, return to the`,
{ exact: false }
).should('exist');

cy.findByRole('link', { name: 'catalogue home page' }).should('exist');
});

it('displays the expired landing page message if the catalogue_item_id does not match the item_id ', () => {
cy.visit('/catalogue/4/items/89/items/G463gOIA');

cy.findByText(
`We're sorry, the page you requested was not found on the server. If you entered the URL manually please check your spelling and try again. Otherwise, return to the`,
{ exact: false }
).should('exist');

cy.findByRole('link', { name: 'catalogue home page' }).should('exist');
});
it('should be able to navigate back to the catalogue catalogue item table view', () => {
cy.findByRole('link', { name: 'Cameras' }).click();
cy.findByText('Cameras 1').should('be.visible');
Expand All @@ -21,7 +57,7 @@ describe('Items', () => {
});

it('should be able to navigate back to the catalogue home step by step', () => {
cy.visit('/catalogue/item/1/items/KvT2Ox7n');
cy.visit('/catalogue/4/items/1/items/KvT2Ox7n');

cy.findByRole('link', { name: 'Items' }).click();

Expand Down Expand Up @@ -224,7 +260,7 @@ describe('Items', () => {
});

it('adds an item with only mandatory fields (allowed list of values)', () => {
cy.visit('/catalogue/item/17/items');
cy.visit('/catalogue/12/items/17/items');
cy.findByRole('button', { name: 'Add Item' }).click();

cy.findByLabelText('Usage status *').click();
Expand Down
5 changes: 4 additions & 1 deletion cypress/e2e/with_mock_data/manufacturers.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,12 @@ describe('Manufacturer', () => {
cy.visit('/manufacturers/invalid');

cy.findByText(
`The manufacturer route you are trying to access doesn't exist. Please click the Home button to navigate back to the Manufacturer Home page.`
`We're sorry, the page you requested was not found on the server. If you entered the URL manually please check your spelling and try again. Otherwise, return to the`,
{ exact: false }
).should('exist');

cy.findByRole('link', { name: 'manufacturers home page' }).should('exist');

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

cy.findByText('Manufacturer A').should('exist');
Expand Down
Loading

0 comments on commit 16f9001

Please sign in to comment.