Skip to content

Commit

Permalink
DTSCCI-000 unit test for extended caseType (#5103)
Browse files Browse the repository at this point in the history
* DTSCCI-000 unit test for extended caseType

* DTSCCI-000 unit test for extended caseType

* DTSCCI-000 unit test for extended caseType

* DTSCCI-000 unit test for extended caseType

* DTSCCI-000 unit test for extended caseType

* DTSCCI-000 unit test for extended caseType

* DTSCCI-000 unit test for extended caseType

* DTSCCI-000 unit test for extended caseType

* DTSCCI-000 unit test for extended caseType
  • Loading branch information
gmikerlemos authored Nov 25, 2024
1 parent d0c76bb commit d13aea7
Show file tree
Hide file tree
Showing 22 changed files with 58 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
]
},
{
"CaseTypeID": "CIVIL",
"CaseTypeID": "CIVIL${CCD_DEF_VERSION}",
"CaseEventID": "CONFIRM_LISTING_COMPLETED",
"AccessControl": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
]
},
{
"CaseTypeID": "CIVIL",
"CaseTypeID": "CIVIL${CCD_DEF_VERSION}",
"CaseFieldID": "confirmListingTickBox",
"AccessControl": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@
]
},
{
"CaseTypeID": "CIVIL",
"CaseTypeID": "CIVIL${CCD_DEF_VERSION}",
"CaseFieldID": "gaAddlDocClaimant",
"AccessControl": [
{
Expand All @@ -569,7 +569,7 @@
]
},
{
"CaseTypeID": "CIVIL",
"CaseTypeID": "CIVIL${CCD_DEF_VERSION}",
"CaseFieldID": "gaAddlDocRespondentSol",
"AccessControl": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"ShowEventNotes": "N"
},
{
"CaseTypeID": "CIVIL",
"CaseTypeID": "CIVIL${CCD_DEF_VERSION}",
"ID": "CONFIRM_LISTING_COMPLETED",
"Name": "Confirm Listing",
"Description": "Confirm Listing",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"CaseTypeID": "CIVIL",
"CaseTypeID": "CIVIL${CCD_DEF_VERSION}",
"CaseEventID": "CONFIRM_LISTING_COMPLETED",
"CaseFieldID": "confirmListingTickBox",
"PageDisplayOrder": 1,
Expand Down
2 changes: 1 addition & 1 deletion ccd-definition/CaseField/CaseField-MINTI-nonprod.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
"Searchable": "N"
},
{
"CaseTypeID": "CIVIL",
"CaseTypeID": "CIVIL${CCD_DEF_VERSION}",
"ID": "confirmListingTickBox",
"Label": " ",
"FieldType": "MultiSelectList",
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/unit/definitions/AuthorisationCaseEvent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const dataProvider = require('../utils/dataProvider');

function assertFieldDefinitionIsValid(row) {
expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL');
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
expect(row.CaseEventID).to.be.a('string').and.satisfy(isNotLongerThan(MEDIUM_STRING));
expect(row.AccessControl).to.not.be.null;
Expand Down
15 changes: 14 additions & 1 deletion e2e/tests/unit/definitions/AuthorisationCaseField.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,29 @@ const dataProvider = require('../utils/dataProvider');

const assertFieldExists = createAssertExists('Field');

function assertFieldDefinitionIsValid(row) {
expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
}

dataProvider.exclusions.forEach((value, key) => {
describe('AuthorisationCaseField'.concat(': ', key, ' config'), () => {
context('should :', () => {
let authorisationCaseFieldConfig = [];
let caseFieldConfig = [];
let errors = [];
let uniqResult = [];

before(() => {
authorisationCaseFieldConfig = dataProvider.getConfig('../../../../ccd-definition/AuthorisationCaseField', key);
caseFieldConfig = dataProvider.getConfig('../../../../ccd-definition/CaseField', key);
uniqResult = uniqWith(authorisationCaseFieldConfig, isFieldDuplicated('CaseFieldID'));
});



it('contain a unique case field ID, case type ID and role (no duplicates)', () => {
const uniqResult = uniqWith(authorisationCaseFieldConfig, isFieldDuplicated('CaseFieldID'));
try {
expect(uniqResult).to.eql(authorisationCaseFieldConfig);
} catch (error) {
Expand All @@ -37,6 +46,10 @@ dataProvider.exclusions.forEach((value, key) => {
it('use existing fields', () => {
assertFieldExists(authorisationCaseFieldConfig, caseFieldConfig);
});

it('should have only valid definitions', () => {
uniqResult.forEach(assertFieldDefinitionIsValid);
});
});
});
});
13 changes: 12 additions & 1 deletion e2e/tests/unit/definitions/AuthorisationCaseState.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,27 @@ const dataProvider = require('../utils/dataProvider');

const assertStateExists = createAssertExists('State');

function assertFieldDefinitionIsValid(row) {
expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
}

dataProvider.exclusions.forEach((value, key) => {
describe('AuthorisationCaseState'.concat(': ', key, ' config'), () => {
context('definitions:', () => {
let authorisationCaseState = [];
let stateConfig = [];
let errors = [];
let uniqResult = [];

before(() => {
authorisationCaseState = dataProvider.getConfig('../../../../ccd-definition/AuthorisationCaseState', key);
stateConfig = dataProvider.ccdData.State;
uniqResult = uniqWith(authorisationCaseState, isFieldDuplicated('CaseStateID'));
});

it('should contain a unique case state, case type ID and role (no duplicates) for nonprod files', () => {
const uniqResult = uniqWith(authorisationCaseState, isFieldDuplicated('CaseStateID'));
try {
expect(uniqResult).to.eql(authorisationCaseState);
} catch (error) {
Expand All @@ -38,6 +45,10 @@ dataProvider.exclusions.forEach((value, key) => {
assertStateExists(authorisationCaseState, stateConfig);
});

it('should have only valid definitions', () => {
uniqResult.forEach(assertFieldDefinitionIsValid);
});

context('Solicitor has valid permissions', () => {
it('CRU permissions for all states', () => {
authorisationCaseState.forEach(authState => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/unit/definitions/AuthorisationCaseType.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const dataProvider = require('../utils/dataProvider');

function assertFieldDefinitionIsValid(row) {
expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL');
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
expect(row.UserRoles).to.not.be.null;
expect(row.AccessControl).to.not.be.null;
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/unit/definitions/CaseEvent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const dataProvider = require('../utils/dataProvider');

function assertEventDefinitionIsValid(row) {
expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL');
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
expect(row.ID).to.be.a('string').and.satisfy(isNotLongerThan(MEDIUM_STRING));
expect(row.Name).to.be.a('string').and.satisfy(isNotLongerThan(SHORT_STRING));
Expand Down
4 changes: 0 additions & 4 deletions e2e/tests/unit/definitions/CaseEventToComplexTypes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ const {
const dataProvider = require('../utils/dataProvider');

function assertFieldDefinitionIsValid(row) {
// todo type not populated
// expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
// return v.startsWith('CIVIL');
// });
const errors = [];
if (row.length > 0) {
row.forEach(elem => {
Expand Down
14 changes: 13 additions & 1 deletion e2e/tests/unit/definitions/CaseEventToFields.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ const { find, uniqWith } = require('lodash');
const { isPositiveNumber, whenPopulated, isCaseEventToFieldDuplicated } = require('../utils/utils');
const dataProvider = require('../utils/dataProvider');

function assertFieldDefinitionIsValid(row) {
expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
}

function assertHasOnlyValidEventIds(caseEventToFieldsFile, caseEventFile) {
const errors = [];
caseEventToFieldsFile.forEach(caseEventToFieldsEntry => {
Expand Down Expand Up @@ -60,11 +66,13 @@ dataProvider.exclusions.forEach((value, key) => {
let caseEventConfig = [];
let caseFieldConfig = [];
let errors = [];
let uniqResult = [];

before(() => {
caseEventToFieldConfig = dataProvider.getConfig('../../../../ccd-definition/CaseEventToFields', key);
caseEventConfig = dataProvider.getConfig('../../../../ccd-definition/CaseEvent', key);
caseFieldConfig = dataProvider.getConfig('../../../../ccd-definition/CaseField', key);
uniqResult = uniqWith(caseEventToFieldConfig, isCaseEventToFieldDuplicated('CaseFieldID'));
});
it('contain valid event IDs', () => {
assertHasOnlyValidEventIds(caseEventToFieldConfig, caseEventConfig);
Expand All @@ -75,7 +83,7 @@ dataProvider.exclusions.forEach((value, key) => {
});

it('not contain duplicate field IDs', () => {
const uniqResult = uniqWith(caseEventToFieldConfig, isCaseEventToFieldDuplicated('CaseFieldID'));

try {
expect(uniqResult).to.eql(caseEventToFieldConfig);
} catch (error) {
Expand All @@ -90,6 +98,10 @@ dataProvider.exclusions.forEach((value, key) => {
}
});

it('should have only valid definitions', () => {
uniqResult.forEach(assertFieldDefinitionIsValid);
});

it('contain valid order fields', () => {
caseEventToFieldConfig.forEach(row => {
assertPageFieldDisplayOrder(row);
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/unit/definitions/CaseField.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const dataProvider = require('../utils/dataProvider');

function assertFieldDefinitionIsValid(row) {
expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL');
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
expect(row.ID).to.be.a('string').and.satisfy(isNotLongerThan(MEDIUM_STRING));
expect(row.Label).to.be.a('string').and.satisfy(isNotEmpty());
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/unit/definitions/CaseRoles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const dataProvider = require('../utils/dataProvider');

function assertFieldDefinitionIsValid(row) {
expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL');
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
expect(row.ID).to.be.a('string').and.satisfy(isNotLongerThan(MEDIUM_STRING));
if (row.Name) {
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/unit/definitions/CaseType.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const dataProvider = require('../utils/dataProvider');

function assertFieldDefinitionIsValid(row) {
expect(row.ID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL');
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
expect(row.SecurityClassification).to.eq('Public');
expect(row.Name).to.be.a('string').and.satisfy(isNotEmpty());
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/unit/definitions/CaseTypeTab.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const dataProvider = require('../utils/dataProvider');

function assertFieldDefinitionIsValid(row) {
expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL');
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
expect(row.CaseFieldID).to.be.a('string').and.satisfy(isNotLongerThan(MEDIUM_STRING));
// todo this isn't always populated
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/unit/definitions/RoleToAccessProfiles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const dataProvider = require('../utils/dataProvider');

function assertFieldDefinitionIsValid(row) {
expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL');
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
expect(row.RoleName).to.be.a('string').and.satisfy(isNotEmpty());
expect(row.AccessProfiles).to.be.a('string').and.satisfy(isNotEmpty());
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/unit/definitions/SearchInputFields.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const dataProvider = require('../utils/dataProvider');

function assertFieldDefinitionIsValid(row) {
expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL');
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
expect(row.CaseFieldID).to.be.a('string').and.satisfy(isNotEmpty());
expect(row.Label).to.be.a('string').and.satisfy(isNotEmpty());
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/unit/definitions/SearchResultFields.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const dataProvider = require('../utils/dataProvider');

function assertFieldDefinitionIsValid(row) {
expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL');
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
expect(row.CaseFieldID).to.be.a('string').and.satisfy(isNotEmpty());
expect(row.Label).to.be.a('string').and.satisfy(isNotEmpty());
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/unit/definitions/WorkBasketInputFields.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const dataProvider = require('../utils/dataProvider');

function assertFieldDefinitionIsValid(row) {
expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL');
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
expect(row.CaseFieldID).to.be.a('string').and.satisfy(isNotEmpty());
expect(row.Label).to.be.a('string').and.satisfy(isNotEmpty());
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/unit/definitions/WorkBasketResultFields.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const dataProvider = require('../utils/dataProvider');

function assertFieldDefinitionIsValid(row) {
expect(row.CaseTypeID).to.be.a('string').and.satisfy(v => {
return v.startsWith('CIVIL');
return v.startsWith('CIVIL${CCD_DEF_VERSION}');
});
expect(row.CaseFieldID).to.be.a('string').and.satisfy(isNotEmpty());
expect(row.Label).to.be.a('string').and.satisfy(isNotEmpty());
Expand Down

0 comments on commit d13aea7

Please sign in to comment.