Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X1244 number stored items #777

Open
wants to merge 4 commits into
base: devel
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions cypress/e2e/pages/store.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ describe('Store', () => {
context('when the location is found', () => {
before(() => {
cy.visit('/store');
cy.findByLabelText('Find Location:').should('be.visible').type('STO-001F{enter}');
cy.findByLabelText('Find Location:').should('be.visible').type('STO-001{enter}');
});

it("takes you to that location's page", () => {
cy.location('pathname').should('eq', '/locations/STO-001F');
cy.findByText('Location STO-001F could not be found').should('not.exist');
cy.location('pathname').should('eq', '/locations/STO-001');
cy.findByText('Location STO-001 could not be found').should('not.exist');
});
});

Expand Down
2 changes: 2 additions & 0 deletions src/graphql/fragments/LinkedLocationFields.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ fragment LinkedLocationFields on LinkedLocation {
fixedName
customName
address
numStored
leaf
}
7 changes: 3 additions & 4 deletions src/graphql/fragments/LocationFields.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ fragment LocationFields on Location {
customName
address
direction
numStored
leaf
parent {
barcode
fixedName
Expand All @@ -18,9 +20,6 @@ fragment LocationFields on Location {
address
}
children {
barcode
fixedName
customName
address
...LinkedLocationFields
}
}
8 changes: 6 additions & 2 deletions src/lib/factories/locationFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const locationFactory = Factory.define<Location>(({ sequence, params, afterBuild
size: null,
direction: params.direction ?? null,
parent: params.parent == null ? null : (params.parent as LinkedLocation),
qualifiedNameWithFirstBarcode: params.qualifiedNameWithFirstBarcode ?? `FakeParent / ${barcode}`
qualifiedNameWithFirstBarcode: params.qualifiedNameWithFirstBarcode ?? `FakeParent / ${barcode}`,
numStored: params.numStored ?? 0,
leaf: params.leaf ?? false
};

if (params.size) {
Expand Down Expand Up @@ -55,6 +57,8 @@ export function buildLinkedLocation(location: Location): LinkedLocation {
barcode: location.barcode,
fixedName: location.fixedName,
customName: location.customName,
address: location.address
address: location.address,
numStored: location.numStored,
leaf: location.leaf ?? false
};
}
10 changes: 8 additions & 2 deletions src/mocks/handlers/locationHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ function addLocationHierarchy(barcode: string, linkedLocation: LinkedLocationFie
barcode: location.barcode,
address: location.address,
customName: location.customName,
fixedName: location.fixedName
fixedName: location.fixedName,
numStored: location.numStored,
leaf: location.leaf
});
if (location.parent) {
addLocationHierarchy(location.parent.barcode, linkedLocation);
Expand All @@ -185,6 +187,8 @@ export function locationResponse(location: Location): LocationFieldsFragment {
customName: location.customName,
address: location.address,
direction: location.direction,
numStored: location.numStored,
leaf: location.leaf,
parent: location.parent
? {
__typename: 'LinkedLocation',
Expand All @@ -211,7 +215,9 @@ export function locationResponse(location: Location): LocationFieldsFragment {
barcode: child.barcode,
fixedName: child.fixedName,
customName: child.customName,
address: child.address
address: child.address,
numStored: child.numStored,
leaf: child.leaf
};
})
};
Expand Down
5 changes: 3 additions & 2 deletions src/mocks/repositories/locationRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class LocationRepository implements Repository<Location> {

const locationRepository = new LocationRepository();

const room: Location = locationFactory.build({ customName: 'Room 1234' });
const room: Location = locationFactory.build({ customName: 'Room 1234', leaf: true });

const freezers: Location[] = [];

Expand Down Expand Up @@ -143,7 +143,8 @@ racks.forEach((rack, index) => {
locationFactory.build({
customName: `Box 1 in ${rack.customName}`,
direction: GridDirection.RightDown,
parent: buildLinkedLocation(rack)
parent: buildLinkedLocation(rack),
leaf: true
})
);
/***
Expand Down
5 changes: 5 additions & 0 deletions src/pages/Location.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,11 @@ const Location = () => {
>
{child.customName ?? child.fixedName ?? child.barcode}
</StyledLink>
{child.leaf && (
<span className="font-semibold" data-testid={'storedItemsCount'}>
{` - Number of Stored items : ${child.numStored}`}
</span>
)}
</li>
);
})}
Expand Down
2,910 changes: 1,462 additions & 1,448 deletions src/types/sdk.ts

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions tests/e2e/pages/location.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { locationResponse } from '../../../src/mocks/handlers/locationHandlers';
import { enableMapSet } from 'immer';
import React from 'react';
import '@testing-library/jest-dom';

jest.mock('../../../src/pages/location/ItemsGrid', () => {
return {
__esModule: true,
Expand Down Expand Up @@ -204,6 +205,12 @@ describe('Load location with children ', () => {
});
expect(screen.queryByText('Stored Items')).not.toBeInTheDocument();
});
it('display number of stored items', () => {
act(() => {
renderLocation('STO-005');
});
expect(screen.queryAllByTestId('storedItemsCount').length).toBeGreaterThan(0);
});
});
});

Expand Down
4 changes: 3 additions & 1 deletion tests/unit/pages/location/itemsGrid.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const mocklocationParentContextValue: LocationParentContextType = {
numRows: 2,
numColumns: 2
},
children: []
children: [],
numStored: 0,
leaf: false
},
addressToItemMap: new Map([
['A1', { barcode: 'STAN-3111' }],
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/pages/location/itemsList.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const mocklocationParentContextValue: LocationParentContextType = {
numRows: 2,
numColumns: 2
},
numStored: 0,
leaf: false,
children: []
},
addressToItemMap: new Map([
Expand Down
Loading