Skip to content

Commit bfdd8ad

Browse files
committed
Update rules to match production #1646
1 parent 3a0f2de commit bfdd8ad

File tree

10 files changed

+130
-57
lines changed

10 files changed

+130
-57
lines changed

cypress/e2e/with_api/items/items.cy.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { addCatalogueCategories } from '../catalogueCategories/functions';
22
import { addCatalogueItem } from '../catalogueItems/functions';
33
import { addManufacturer } from '../manufacturers/functions';
4-
import { addSystems } from '../systems/functions';
4+
import { addSystems, modifySystem } from '../systems/functions';
55
import { addUnits } from '../units/functions';
66
import {
77
addItem,
@@ -10,6 +10,7 @@ import {
1010
duplicateItem,
1111
editItem,
1212
editProperty,
13+
modifyItem,
1314
} from './functions';
1415

1516
describe('items', () => {
@@ -30,6 +31,10 @@ describe('items', () => {
3031
addUnits(['mm', 'nm'], true);
3132
cy.visit('/systems');
3233
addSystems(true);
34+
modifySystem(
35+
{ name: 'Scrapped', importance: 'high', type: 'Scrapped' },
36+
true
37+
);
3338
cy.visit('/catalogue');
3439
addCatalogueCategories(true);
3540
addCatalogueItem(true);
@@ -55,7 +60,11 @@ describe('items', () => {
5560
cy.findByText('Total Items: 2').should('exist');
5661
cy.findByRole('progressbar').should('not.exist');
5762
cy.findAllByText('MX4332424').should('have.length', 2);
58-
deleteItem('MX4332424', 1);
63+
modifyItem({
64+
editIndex: 0,
65+
system: 'Scrapped',
66+
});
67+
deleteItem('No serial number', 0);
5968
cy.findByRole('progressbar').should('not.exist');
6069
cy.findAllByText('MX4332424').should('have.length', 1);
6170
});

cypress/e2e/with_mock_data/items.cy.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,15 +1828,15 @@ describe('Items', () => {
18281828
it('displays edit dialog in admin view when user is admin', () => {
18291829
cy.setCurrentUserToAdmin();
18301830
cy.visit('/catalogue/9/items/11/items');
1831-
cy.findAllByLabelText('Row Actions').first().click();
1831+
cy.findAllByLabelText('Row Actions').last().click();
18321832
cy.findByText('Edit as Admin').click();
18331833

18341834
cy.findByRole('progressbar').should('not.exist');
18351835
cy.findByText('Edit Item as Admin').should('exist');
18361836

18371837
// Scrapped is 'not allowed' by rules so admin user should be able to bypass this and override usasge status
18381838
cy.findByRole('button', { name: 'navigate to systems home' }).click();
1839-
cy.findAllByText('Scrapped').first().click();
1839+
cy.findAllByText('Giant laser').first().click();
18401840

18411841
cy.findByText(
18421842
'WARNING: No rule exists for moving this item between these system types'
@@ -1861,8 +1861,7 @@ describe('Items', () => {
18611861
expect(patchRequests.length).eq(1);
18621862
expect(JSON.stringify(await patchRequests[0].json())).equal(
18631863
JSON.stringify({
1864-
usage_status_id: '2',
1865-
system_id: '657f8c3b2a1b4e5d8f9b3c4e8',
1864+
system_id: '65328f34a40ff5301575a4e3',
18661865
})
18671866
);
18681867
});
@@ -1886,6 +1885,9 @@ describe('Items', () => {
18861885
cy.findByText('Duplicate').click();
18871886

18881887
cy.startSnoopingBrowserMockedRequest();
1888+
cy.findByText(
1889+
'WARNING: No rule exists for creating a new item within this system type'
1890+
).should('exist');
18891891

18901892
cy.findByRole('button', { name: 'Next' }).click();
18911893

@@ -1941,10 +1943,10 @@ describe('Items', () => {
19411943

19421944
it('deletes an item', () => {
19431945
cy.visit('/catalogue/9/items/11/items');
1944-
cy.findAllByLabelText('Row Actions').first().click();
1946+
cy.findAllByLabelText('Row Actions').last().click();
19451947
cy.findByText('Delete').click();
19461948

1947-
cy.findByText('Serial Number: dfzqkOJbqifO').should('exist');
1949+
cy.findByText('Serial Number: WrgqAVk3qUQK').should('exist');
19481950

19491951
cy.startSnoopingBrowserMockedRequest();
19501952

@@ -1956,7 +1958,7 @@ describe('Items', () => {
19561958
}).should((deleteRequests) => {
19571959
expect(deleteRequests.length).equal(1);
19581960
const request = deleteRequests[0];
1959-
expect(request.url.toString()).to.contain('RuUxShkg');
1961+
expect(request.url.toString()).to.contain('qWAdynAI');
19601962
});
19611963
});
19621964

@@ -1978,7 +1980,7 @@ describe('Items', () => {
19781980
cy.findByRole('button', { name: 'Continue' }).click();
19791981

19801982
cy.findByText(
1981-
'Please move item to a system with Type: Storage before trying to delete.'
1983+
'Please move item to a system with Type: Scrapped before trying to delete.'
19821984
).should('exist');
19831985
});
19841986

cypress/e2e/with_mock_data/rules.cy.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('Rules page', () => {
3838

3939
cy.findByRole('button', { name: 'Show Deletion Rules' }).click();
4040

41-
cy.findAllByText('Storage').should('have.length', 2);
41+
cy.findAllByText('Storage').should('have.length', 1);
4242

4343
cy.findByRole('button', { name: 'Show Deletion Rules' }).should(
4444
'be.disabled'
@@ -63,7 +63,7 @@ describe('Rules page', () => {
6363

6464
cy.findByRole('progressbar').should('not.exist');
6565

66-
cy.findAllByText('Storage').should('have.length', 4);
66+
cy.findAllByText('Storage').should('have.length', 5);
6767

6868
cy.findByRole('button', { name: 'Show Moving Rules' }).should(
6969
'be.disabled'
@@ -79,14 +79,15 @@ describe('Rules page', () => {
7979
cy.findByText('Moving Rules Filter Applied').should('not.exist');
8080
});
8181

82-
8382
it('opens information dialog from icon button', () => {
8483
cy.findByLabelText('Open information dialog').click();
8584
cy.findByText('Rules Information').should('exist');
86-
cy.get('button:contains("Example:")').should('have.length', 3)
85+
cy.get('button:contains("Example:")').should('have.length', 3);
8786

88-
cy.findByText('Example: Storage → Operational → \'In Use\'').click();
89-
cy.findByText('Items can be moved from the system type \'Storage\' to \'Operational\'. This rule sets the items usage status to \'In Use\'.').should('exist');
87+
cy.findByText("Example: Storage → Operational → 'In Use'").click();
88+
cy.findByText(
89+
"Items can be moved from the system type 'Storage' to 'Operational'. This rule sets the items usage status to 'In Use'."
90+
).should('exist');
9091

9192
cy.findByRole('button', { name: 'Close' }).click();
9293
cy.findByText('Rules Information').should('not.exist');

cypress/e2e/with_mock_data/systems.cy.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,11 @@ describe('Systems', () => {
928928
created_time: '2024-01-01T12:00:00.000+00:00',
929929
modified_time: '2024-01-02T13:10:10.000+00:00',
930930
type_id: '2',
931-
type: { id: '2', value: 'Operational', description: 'Operational system type' },
931+
type: {
932+
id: '2',
933+
value: 'Operational',
934+
description: 'Operational system type',
935+
},
932936
})
933937
);
934938
expect(JSON.stringify(await postRequests[1].json())).equal(
@@ -944,7 +948,11 @@ describe('Systems', () => {
944948
created_time: '2024-01-01T12:00:00.000+00:00',
945949
modified_time: '2024-01-02T13:10:10.000+00:00',
946950
type_id: '2',
947-
type: { id: '2', value: 'Operational', description: 'Operational system type' },
951+
type: {
952+
id: '2',
953+
value: 'Operational',
954+
description: 'Operational system type',
955+
},
948956
})
949957
);
950958
});
@@ -1218,13 +1226,13 @@ describe('Systems', () => {
12181226
});
12191227

12201228
it('deletes an item', () => {
1221-
cy.visit('/systems/657f8c3b2a1b4e5d8f9b3c4e5');
1229+
cy.visit('/systems/657f8c3b2a1b4e5d8f9b3c4e8');
12221230

12231231
cy.findByRole('button', { name: 'Expand' }).click();
12241232
cy.findByLabelText('Row Actions').first().click();
12251233
cy.findByText('Delete').click();
12261234

1227-
cy.findByText('Serial Number: dfzqkOJbqifO').should('exist');
1235+
cy.findByText('Serial Number: WrgqAVk3qUQK').should('exist');
12281236

12291237
cy.startSnoopingBrowserMockedRequest();
12301238

@@ -1236,7 +1244,7 @@ describe('Systems', () => {
12361244
}).should((deleteRequests) => {
12371245
expect(deleteRequests.length).equal(1);
12381246
const request = deleteRequests[0];
1239-
expect(request.url.toString()).to.contain('RuUxShkg');
1247+
expect(request.url.toString()).to.contain('qWAdynAI');
12401248
});
12411249
});
12421250
});

src/items/__snapshots__/itemsTable.component.test.tsx.snap

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3557,12 +3557,12 @@ exports[`Items Table > renders the dense table correctly 1`] = `
35573557
</span>
35583558
</div>
35593559
<input
3560-
aria-describedby=":r3ec:-helper-text"
3560+
aria-describedby=":r3em:-helper-text"
35613561
aria-invalid="false"
35623562
aria-label="Filter by Serial Number"
35633563
autocomplete="off"
35643564
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedStart MuiInputBase-inputAdornedEnd css-110vr2a-MuiInputBase-input-MuiInput-input"
3565-
id=":r3ec:"
3565+
id=":r3em:"
35663566
placeholder="Filter by Serial Number"
35673567
title="Filter by Serial Number"
35683568
type="text"
@@ -3600,7 +3600,7 @@ exports[`Items Table > renders the dense table correctly 1`] = `
36003600
</div>
36013601
<p
36023602
class="MuiFormHelperText-root MuiFormHelperText-sizeMedium css-v98l45-MuiFormHelperText-root"
3603-
id=":r3ec:-helper-text"
3603+
id=":r3em:-helper-text"
36043604
>
36053605
<label>
36063606
Filter Mode: Fuzzy
@@ -3714,11 +3714,11 @@ exports[`Items Table > renders the dense table correctly 1`] = `
37143714
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-adornedEnd css-6h9cc6-MuiInputBase-root-MuiInput-root"
37153715
>
37163716
<input
3717-
aria-describedby=":r3el:-helper-text"
3717+
aria-describedby=":r3ev:-helper-text"
37183718
aria-invalid="false"
37193719
autocomplete="off"
37203720
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1yrc8ca-MuiInputBase-input-MuiInput-input"
3721-
id=":r3el:"
3721+
id=":r3ev:"
37223722
inputmode="text"
37233723
placeholder="Min"
37243724
type="text"
@@ -3749,7 +3749,7 @@ exports[`Items Table > renders the dense table correctly 1`] = `
37493749
</div>
37503750
<p
37513751
class="MuiFormHelperText-root MuiFormHelperText-sizeMedium css-18y2hez-MuiFormHelperText-root"
3752-
id=":r3el:-helper-text"
3752+
id=":r3ev:-helper-text"
37533753
>
37543754
<label>
37553755
Filter Mode: Between Inclusive
@@ -3766,7 +3766,7 @@ exports[`Items Table > renders the dense table correctly 1`] = `
37663766
aria-invalid="false"
37673767
autocomplete="off"
37683768
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1yrc8ca-MuiInputBase-input-MuiInput-input"
3769-
id=":r3eo:"
3769+
id=":r3f2:"
37703770
inputmode="text"
37713771
placeholder="Max"
37723772
type="text"
@@ -3904,11 +3904,11 @@ exports[`Items Table > renders the dense table correctly 1`] = `
39043904
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-adornedEnd css-6h9cc6-MuiInputBase-root-MuiInput-root"
39053905
>
39063906
<input
3907-
aria-describedby=":r3ev:-helper-text"
3907+
aria-describedby=":r3f9:-helper-text"
39083908
aria-invalid="false"
39093909
autocomplete="off"
39103910
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1yrc8ca-MuiInputBase-input-MuiInput-input"
3911-
id=":r3ev:"
3911+
id=":r3f9:"
39123912
inputmode="text"
39133913
placeholder="Min"
39143914
type="text"
@@ -3939,7 +3939,7 @@ exports[`Items Table > renders the dense table correctly 1`] = `
39393939
</div>
39403940
<p
39413941
class="MuiFormHelperText-root MuiFormHelperText-sizeMedium css-18y2hez-MuiFormHelperText-root"
3942-
id=":r3ev:-helper-text"
3942+
id=":r3f9:-helper-text"
39433943
>
39443944
<label>
39453945
Filter Mode: Between Inclusive
@@ -3956,7 +3956,7 @@ exports[`Items Table > renders the dense table correctly 1`] = `
39563956
aria-invalid="false"
39573957
autocomplete="off"
39583958
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1yrc8ca-MuiInputBase-input-MuiInput-input"
3959-
id=":r3f2:"
3959+
id=":r3fc:"
39603960
inputmode="text"
39613961
placeholder="Max"
39623962
type="text"
@@ -4094,11 +4094,11 @@ exports[`Items Table > renders the dense table correctly 1`] = `
40944094
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-adornedEnd css-6h9cc6-MuiInputBase-root-MuiInput-root"
40954095
>
40964096
<input
4097-
aria-describedby=":r3f9:-helper-text"
4097+
aria-describedby=":r3fj:-helper-text"
40984098
aria-invalid="false"
40994099
autocomplete="off"
41004100
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1yrc8ca-MuiInputBase-input-MuiInput-input"
4101-
id=":r3f9:"
4101+
id=":r3fj:"
41024102
inputmode="text"
41034103
placeholder="Min"
41044104
type="text"
@@ -4129,7 +4129,7 @@ exports[`Items Table > renders the dense table correctly 1`] = `
41294129
</div>
41304130
<p
41314131
class="MuiFormHelperText-root MuiFormHelperText-sizeMedium css-18y2hez-MuiFormHelperText-root"
4132-
id=":r3f9:-helper-text"
4132+
id=":r3fj:-helper-text"
41334133
>
41344134
<label>
41354135
Filter Mode: Between Inclusive
@@ -4146,7 +4146,7 @@ exports[`Items Table > renders the dense table correctly 1`] = `
41464146
aria-invalid="false"
41474147
autocomplete="off"
41484148
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1yrc8ca-MuiInputBase-input-MuiInput-input"
4149-
id=":r3fc:"
4149+
id=":r3fm:"
41504150
inputmode="text"
41514151
placeholder="Max"
41524152
type="text"
@@ -4284,11 +4284,11 @@ exports[`Items Table > renders the dense table correctly 1`] = `
42844284
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-adornedEnd css-6h9cc6-MuiInputBase-root-MuiInput-root"
42854285
>
42864286
<input
4287-
aria-describedby=":r3fj:-helper-text"
4287+
aria-describedby=":r3ft:-helper-text"
42884288
aria-invalid="false"
42894289
autocomplete="off"
42904290
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1yrc8ca-MuiInputBase-input-MuiInput-input"
4291-
id=":r3fj:"
4291+
id=":r3ft:"
42924292
inputmode="text"
42934293
placeholder="Min"
42944294
type="text"
@@ -4319,7 +4319,7 @@ exports[`Items Table > renders the dense table correctly 1`] = `
43194319
</div>
43204320
<p
43214321
class="MuiFormHelperText-root MuiFormHelperText-sizeMedium css-18y2hez-MuiFormHelperText-root"
4322-
id=":r3fj:-helper-text"
4322+
id=":r3ft:-helper-text"
43234323
>
43244324
<label>
43254325
Filter Mode: Between Inclusive
@@ -4336,7 +4336,7 @@ exports[`Items Table > renders the dense table correctly 1`] = `
43364336
aria-invalid="false"
43374337
autocomplete="off"
43384338
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1yrc8ca-MuiInputBase-input-MuiInput-input"
4339-
id=":r3fm:"
4339+
id=":r3g0:"
43404340
inputmode="text"
43414341
placeholder="Max"
43424342
type="text"
@@ -4474,9 +4474,9 @@ exports[`Items Table > renders the dense table correctly 1`] = `
44744474
aria-expanded="false"
44754475
aria-haspopup="listbox"
44764476
aria-label="Filter by Is Defective"
4477-
aria-labelledby=":r3ft:"
4477+
aria-labelledby=":r3g7:"
44784478
class="MuiSelect-select MuiSelect-standard MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-10y8whu-MuiSelect-select-MuiInputBase-input-MuiInput-input"
4479-
id=":r3ft:"
4479+
id=":r3g7:"
44804480
role="combobox"
44814481
tabindex="0"
44824482
>
@@ -5127,7 +5127,7 @@ exports[`Items Table > renders the dense table correctly 1`] = `
51275127
>
51285128
<label
51295129
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-animated MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-animated css-10j3yc8-MuiFormLabel-root-MuiInputLabel-root"
5130-
for="mrt-rows-per-page-:r3e5:"
5130+
for="mrt-rows-per-page-:r3ef:"
51315131
>
51325132
Rows per page
51335133
</label>
@@ -5148,7 +5148,7 @@ exports[`Items Table > renders the dense table correctly 1`] = `
51485148
aria-hidden="true"
51495149
aria-invalid="false"
51505150
class="MuiSelect-nativeInput css-j0riat-MuiSelect-nativeInput"
5151-
id="mrt-rows-per-page-:r3e5:"
5151+
id="mrt-rows-per-page-:r3ef:"
51525152
tabindex="-1"
51535153
value="5"
51545154
/>

0 commit comments

Comments
 (0)