Skip to content

Commit

Permalink
Merge branch 'develop' into nested-routes-for-catalogue-#1218
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadkitenge committed Jan 9, 2025
2 parents e164e8f + a87d28d commit 1b35af3
Show file tree
Hide file tree
Showing 16 changed files with 1,704 additions and 1,861 deletions.
925 changes: 0 additions & 925 deletions .yarn/releases/yarn-4.5.0.cjs

This file was deleted.

934 changes: 934 additions & 0 deletions .yarn/releases/yarn-4.6.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.5.0.cjs
yarnPath: .yarn/releases/yarn-4.6.0.cjs
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');
});
});
36 changes: 14 additions & 22 deletions 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 All @@ -40,62 +40,54 @@ const modifyCatalogueCategory = (
if (!values.editCatalogueCategoryName)
cy.findByLabelText('Catalogue Items').click();

// Add any required fields
for (let i = 0; i < values.newFormFields.length; i++) {
cy.findByRole('button', {
name: 'Add catalogue category field entry',
}).click();
}

cy.findAllByLabelText('Property Name *').should(
'have.length',
values.newFormFields.length
);

for (let i = 0; i < values.newFormFields.length; i++) {
const field = values.newFormFields[i];

cy.findByText('Add Property').click();
cy.findByRole('dialog', { name: 'Add Property' }).should('exist');

if (field.name) {
cy.findAllByLabelText('Property Name *').eq(i).type(field.name);
cy.findByLabelText('Property Name *').type(field.name);
}

if (field.type) {
cy.findAllByLabelText('Select Type *').eq(i).click();
cy.findByLabelText('Select Type *').click();
cy.findByRole('option', {
name: field.type.charAt(0).toUpperCase() + field.type.slice(1),
}).click();
}

if (field.unit) {
cy.findAllByLabelText('Select Unit').eq(i).click();
cy.findByLabelText('Select Unit').click();
cy.findByRole('option', { name: field.unit }).click();
}

cy.findAllByLabelText('Select is mandatory?').eq(i).click();
cy.findByLabelText('Select is mandatory?').click();
cy.findByRole('option', {
name: field.mandatory ? 'Yes' : 'No',
}).click();

if (field.allowed_values) {
cy.findAllByLabelText('Select Allowed values *').eq(i).click();
cy.findByLabelText('Select Allowed values *').click();
cy.findByRole('option', {
name: field.allowed_values.type === 'list' ? 'List' : 'Any',
}).click();

if (field.allowed_values.type === 'list') {
for (let j = 0; j < field.allowed_values.values.length; j++) {
cy.findAllByRole('button', {
cy.findByRole('button', {
name: `Add list item`,
})
.eq(i)
.click();
}).click();

cy.findAllByLabelText('List item')
.eq(j)
.type(field.allowed_values.values[j]);
}
}
}

cy.findByRole('button', { name: 'Save' }).click();
cy.findByRole('dialog', { name: 'Add Property' }).should('not.exist');
}
}

Expand Down
145 changes: 37 additions & 108 deletions cypress/e2e/with_mock_data/catalogueCategories.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,26 +248,26 @@ describe('Catalogue Category', () => {
cy.startSnoopingBrowserMockedRequest();

cy.findByRole('button', {
name: 'Add catalogue category field entry',
name: 'Add Property',
}).click();
cy.findByLabelText('Property Name *').type('Updated Field 1');
cy.findByLabelText('Select Type *').click();
cy.findByText('Boolean').click();

cy.findByRole('button', {
name: 'Add catalogue category field entry',
}).click();

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

cy.findByText('Please enter a property name.').should('exist');
cy.findByRole('button', {
name: 'Add Property',
}).click();

cy.findAllByLabelText('Property Name *').last().type('Updated Field 2');
cy.findAllByLabelText('Select Type *').last().click();
cy.findByText('Number').click();
cy.findAllByLabelText('Select Unit').last().click();
cy.findByRole('option', { name: 'millimeters' }).click();

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

cy.findByRole('button', { name: 'Save' }).click();
cy.findByRole('dialog').should('not.exist');

Expand Down Expand Up @@ -304,19 +304,17 @@ describe('Catalogue Category', () => {
cy.startSnoopingBrowserMockedRequest();

cy.findByRole('button', {
name: 'Add catalogue category field entry',
name: 'Add Property',
}).click();
cy.findByLabelText('Property Name *').type('Updated Field 1');
cy.findByLabelText('Select Type *').click();
cy.findByText('Boolean').click();

cy.findByRole('button', {
name: 'Add catalogue category field entry',
}).click();

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

cy.findByText('Please enter a property name.').should('exist');
cy.findByRole('button', {
name: 'Add Property',
}).click();

cy.findAllByLabelText('Property Name *').last().type('Updated Field 2');
cy.findAllByLabelText('Select Type *').last().click();
Expand All @@ -325,6 +323,8 @@ describe('Catalogue Category', () => {
cy.findByRole('option', { name: 'List' }).click();
cy.findByRole('button', { name: 'Add list item' }).click();
cy.findAllByLabelText('List item').eq(0).type('10');

cy.findByRole('button', { name: 'Save' }).click();
cy.findByRole('button', { name: 'Save' }).click();
cy.findByRole('dialog').should('not.exist');

Expand Down Expand Up @@ -352,7 +352,7 @@ describe('Catalogue Category', () => {
});
});

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

Expand All @@ -361,47 +361,28 @@ describe('Catalogue Category', () => {
cy.startSnoopingBrowserMockedRequest();

cy.findByRole('button', {
name: 'Add catalogue category field entry',
name: 'Add Property',
}).click();
cy.findByLabelText('Property Name *').type('Updated Field 1');
cy.findByLabelText('Select Type *').click();
cy.findByText('Text').click();
cy.findByRole('option', { name: 'Text' }).click();
cy.findAllByLabelText('Select Allowed values *').last().click();
cy.findByRole('option', { name: 'List' }).click();
cy.findByRole('button', { name: 'Add list item' }).click();
cy.findByRole('button', { name: 'Add list item' }).click();

cy.findByRole('button', {
name: 'Add catalogue category field entry',
}).click();

cy.findAllByLabelText('Property Name *').last().type('Updated Field 2');
cy.findAllByLabelText('Select Type *').last().click();
cy.findByRole('option', { name: 'Text' }).click();
cy.findAllByLabelText('Select Allowed values *').last().click();
cy.findByRole('option', { name: 'List' }).click();
cy.findAllByRole('button', { name: 'Add list item' }).eq(1).click();
cy.findAllByRole('button', { name: 'Add list item' }).eq(1).click();
cy.findAllByLabelText('List item').eq(2).type('10');
cy.findAllByLabelText('List item').eq(3).type('10');

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

cy.findAllByText('Please enter a value.').should('have.length', 2);
cy.findAllByText('Duplicate value.').should('have.length', 2);

// Clearing the errors

cy.findAllByLabelText('List item').eq(3).clear();
cy.findAllByLabelText('List item').eq(3).type('11');
cy.findAllByText('Duplicate value').should('have.length', 0);

cy.findAllByLabelText('List item').eq(0).type('10');
cy.findAllByLabelText('List item').eq(1).type('11');
cy.findAllByText('Please enter a value').should('have.length', 0);
cy.findAllByText('Please enter a value.').should('have.length', 0);
});

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

Expand All @@ -410,53 +391,38 @@ describe('Catalogue Category', () => {
cy.startSnoopingBrowserMockedRequest();

cy.findByRole('button', {
name: 'Add catalogue category field entry',
name: 'Add Property',
}).click();
cy.findByLabelText('Property Name *').type('Updated Field 1');
cy.findByLabelText('Property Name *').type('Updated Field 2');
cy.findByLabelText('Select Type *').click();
cy.findByText('Number').click();
cy.findAllByLabelText('Select Allowed values *').last().click();
cy.findByRole('option', { name: 'Text' }).click();
cy.findByLabelText('Select Allowed values *').click();
cy.findByRole('option', { name: 'List' }).click();
cy.findByRole('button', { name: 'Add list item' }).click();
cy.findByRole('button', { name: 'Add list item' }).click();
cy.findAllByLabelText('List item').eq(0).type('dsadd');
cy.findAllByLabelText('List item').eq(1).type('10');

cy.findByRole('button', {
name: 'Add catalogue category field entry',
}).click();

cy.findAllByLabelText('Property Name *').eq(1).type('Updated Field 2');
cy.findAllByLabelText('Select Type *').eq(1).click();
cy.findByRole('option', { name: 'Number' }).click();
cy.findAllByLabelText('Select Allowed values *').eq(1).click();
cy.findByRole('option', { name: 'List' }).click();
cy.findAllByRole('button', { name: 'Add list item' }).eq(1).click();
cy.findAllByRole('button', { name: 'Add list item' }).eq(1).click();
cy.findAllByLabelText('List item').eq(2).type('dsadd');
cy.findAllByLabelText('List item').eq(3).type('10');
cy.findAllByLabelText('List item').first().type('10');
cy.findAllByLabelText('List item').last().type('10');

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

cy.findAllByText('Please enter a valid number.').should('have.length', 2);
cy.findAllByText('Duplicate value.').should('have.length', 2);

// Clearing the errors

cy.findAllByLabelText('Delete list item').eq(0).click();
cy.findAllByLabelText('Delete list item').eq(1).click();
cy.findAllByText('Please enter a valid number.').should('have.length', 0);
cy.findAllByLabelText('List item').last().clear();
cy.findAllByLabelText('List item').last().type('11');
cy.findAllByText('Duplicate value').should('have.length', 0);
});

it('displays the allowed values list error states (number)', () => {
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.findByLabelText('Name *').type('test');

cy.findByLabelText('Catalogue Items').click();

cy.startSnoopingBrowserMockedRequest();

cy.findByRole('button', {
name: 'Add catalogue category field entry',
name: 'Add Property',
}).click();
cy.findByLabelText('Property Name *').type('Updated Field 1');
cy.findByLabelText('Select Type *').click();
Expand All @@ -465,56 +431,17 @@ describe('Catalogue Category', () => {
cy.findByRole('option', { name: 'List' }).click();
cy.findByRole('button', { name: 'Add list item' }).click();
cy.findByRole('button', { name: 'Add list item' }).click();

cy.findByRole('button', {
name: 'Add catalogue category field entry',
}).click();

cy.findAllByLabelText('Property Name *').eq(1).type('Updated Field 2');
cy.findAllByLabelText('Select Type *').eq(1).click();
cy.findByRole('option', { name: 'Number' }).click();
cy.findAllByLabelText('Select Allowed values *').eq(1).click();
cy.findByRole('option', { name: 'List' }).click();
cy.findAllByRole('button', { name: 'Add list item' }).eq(1).click();
cy.findAllByRole('button', { name: 'Add list item' }).eq(1).click();
cy.findAllByLabelText('List item').eq(2).type('10');
cy.findAllByLabelText('List item').eq(3).type('10');

cy.findByRole('button', {
name: 'Add catalogue category field entry',
}).click();

cy.findAllByLabelText('Property Name *').last().type('Updated Field 3');
cy.findAllByLabelText('Select Type *').last().click();
cy.findByRole('option', { name: 'Number' }).click();
cy.findAllByLabelText('Select Allowed values *').last().click();
cy.findByRole('option', { name: 'List' }).click();
cy.findAllByRole('button', { name: 'Add list item' }).eq(2).click();
cy.findAllByRole('button', { name: 'Add list item' }).eq(2).click();
cy.findAllByLabelText('List item').eq(4).type('10b');
cy.findAllByLabelText('List item').eq(5).type('10c');
cy.findAllByLabelText('List item').eq(0).type('dsadd');
cy.findAllByLabelText('List item').eq(1).type('10');

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

cy.findAllByText('Please enter a value.').should('have.length', 2);
cy.findAllByText('Duplicate value.').should('have.length', 2);
cy.findAllByText('Please enter a valid number.').should('have.length', 2);
cy.findAllByText('Please enter a valid number.').should('have.length', 1);

// Clearing the errors

cy.findAllByLabelText('List item').eq(4).clear();
cy.findAllByLabelText('List item').eq(4).type('11');
cy.findAllByLabelText('List item').eq(5).clear();
cy.findAllByLabelText('List item').eq(5).type('12');
cy.findAllByLabelText('Delete list item').eq(0).click();
cy.findAllByText('Please enter a valid number.').should('have.length', 0);

cy.findAllByLabelText('List item').eq(3).clear();
cy.findAllByLabelText('List item').eq(3).type('11');
cy.findAllByText('Duplicate value.').should('have.length', 0);

cy.findAllByLabelText('List item').eq(0).first().type('10');
cy.findAllByLabelText('List item').eq(1).first().type('11');
cy.findAllByText('Please enter a value.').should('have.length', 0);
});

it('displays error message when duplicate names for properties are entered', () => {
Expand All @@ -526,15 +453,17 @@ describe('Catalogue Category', () => {
cy.startSnoopingBrowserMockedRequest();

cy.findByRole('button', {
name: 'Add catalogue category field entry',
name: 'Add Property',
}).click();

cy.findByLabelText('Property Name *').type('Duplicate');
cy.findByLabelText('Select Type *').click();
cy.findByText('Boolean').click();

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

cy.findByRole('button', {
name: 'Add catalogue category field entry',
name: 'Add Property',
}).click();

cy.findAllByLabelText('Property Name *').last().type('Duplicate');
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"loglevel": "^1.9.1",
"lz-string": "^1.5.0",
"material-react-table": "^2.13.0",
"msw": "2.6.9",
"msw": "2.7.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.52.0",
Expand Down Expand Up @@ -76,7 +76,7 @@
"not dead",
"not op_mini all"
],
"packageManager": "yarn@4.5.0",
"packageManager": "yarn@4.6.0",
"devDependencies": {
"@babel/eslint-parser": "7.25.9",
"@eslint/compat": "1.2.4",
Expand Down Expand Up @@ -109,7 +109,7 @@
"serve": "14.2.4",
"serve-static": "1.16.2",
"start-server-and-test": "2.0.9",
"typescript-eslint": "8.18.0",
"typescript-eslint": "8.19.0",
"vitest": "2.1.8"
},
"msw": {
Expand Down
Loading

0 comments on commit 1b35af3

Please sign in to comment.