Skip to content

Commit

Permalink
refactor: only include "required by modules" suffix for checks that a…
Browse files Browse the repository at this point in the history
…re module-specific

As soon as a module includes a field or type, it includes all of its
specialities. Checks like whether the type match are independent of the
module selection. For this reason, it is noisy and confusing to include
the list of modules in the messages.
  • Loading branch information
Yogu committed Sep 13, 2024
1 parent eab13d0 commit 9636341
Show file tree
Hide file tree
Showing 29 changed files with 107 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Type "Test" needs to be decorated with @businessObject (required by module "module1").',
'Type "Test" needs to be decorated with @businessObject.',
);
});

Expand Down
11 changes: 4 additions & 7 deletions spec/model/compatibility-check/check-calc-mutations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "Test.test" should be decorated with @calcMutations(operators: [ADD]) (required by module "module1").',
'Field "Test.test" should be decorated with @calcMutations(operators: [ADD]).',
);
});

Expand All @@ -41,7 +41,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "Test.test" should be decorated with @calcMutations(operators: [ADD, MULTIPLY]) (required by module "module1").',
'Field "Test.test" should be decorated with @calcMutations(operators: [ADD, MULTIPLY]).',
);
});

Expand All @@ -58,10 +58,7 @@ describe('checkModel', () => {
}
`,
);
expectSingleCompatibilityIssue(
result,
'Operator MULTIPLY is missing (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Operator MULTIPLY is missing.');
});

it('rejects three missing operators', () => {
Expand All @@ -79,7 +76,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Operators ADD, SUBTRACT and DIVIDE are missing (required by module "module1").',
'Operators ADD, SUBTRACT and DIVIDE are missing.',
);
});

Expand Down
13 changes: 5 additions & 8 deletions spec/model/compatibility-check/check-collect-field.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "Test.items2" should not be a collect field (required by module "module1").',
'Field "Test.items2" should not be a collect field.',
);
});

Expand Down Expand Up @@ -61,7 +61,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "Test.items2" should be decorated with @collect(path: "items") (required by module "module1").',
'Field "Test.items2" should be decorated with @collect(path: "items").',
);
});

Expand Down Expand Up @@ -90,7 +90,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "Test.sum" should be decorated with @collect(path: "items.value", aggregate: SUM) (required by module "module1").',
'Field "Test.sum" should be decorated with @collect(path: "items.value", aggregate: SUM).',
);
});

Expand Down Expand Up @@ -119,10 +119,7 @@ describe('checkModel', () => {
}
`,
);
expectSingleCompatibilityIssue(
result,
'Path should be "items.value1" (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Path should be "items.value1".');
});

it('rejects a wrong aggregate argument', () => {
Expand Down Expand Up @@ -150,7 +147,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Collect field should specify aggregate: COUNT_NULL (required by module "module1").',
'Collect field should specify aggregate: COUNT_NULL.',
);
});

Expand Down
29 changes: 7 additions & 22 deletions spec/model/compatibility-check/check-default-value.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "Test.field" should not have a default value (required by module "module1").',
'Field "Test.field" should not have a default value.',
);
});

Expand All @@ -51,7 +51,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "Test.field" should be decorated with @defaultValue(value: "hello") (required by module "module1").',
'Field "Test.field" should be decorated with @defaultValue(value: "hello").',
);
});

Expand All @@ -73,10 +73,7 @@ describe('checkModel', () => {
allowWarningsAndInfosInProjectToCheck: true,
},
);
expectSingleCompatibilityIssue(
result,
'Default value should be "correct" (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Default value should be "correct".');
});

it('rejects a wrong @defaultValue with an Int type', () => {
Expand All @@ -97,10 +94,7 @@ describe('checkModel', () => {
allowWarningsAndInfosInProjectToCheck: true,
},
);
expectSingleCompatibilityIssue(
result,
'Default value should be 42 (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Default value should be 42.');
});

it('rejects a wrong @defaultValue with a Float type', () => {
Expand All @@ -121,10 +115,7 @@ describe('checkModel', () => {
allowWarningsAndInfosInProjectToCheck: true,
},
);
expectSingleCompatibilityIssue(
result,
'Default value should be 6.28 (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Default value should be 6.28.');
});

it('rejects a wrong @defaultValue with an [Int] type', () => {
Expand All @@ -145,10 +136,7 @@ describe('checkModel', () => {
allowWarningsAndInfosInProjectToCheck: true,
},
);
expectSingleCompatibilityIssue(
result,
'Default value should be [1, 2, 3] (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Default value should be [1, 2, 3].');
});

it('rejects a wrong @defaultValue with a value object type', () => {
Expand Down Expand Up @@ -179,10 +167,7 @@ describe('checkModel', () => {
allowWarningsAndInfosInProjectToCheck: true,
},
);
expectSingleCompatibilityIssue(
result,
'Default value should be {a: true, b: false} (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Default value should be {a: true, b: false}.');
});

it('accepts a correct @defaultValue with a String type', () => {
Expand Down
5 changes: 1 addition & 4 deletions spec/model/compatibility-check/check-enums.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ describe('checkModel', () => {
}
`,
);
expectSingleCompatibilityIssue(
result,
'Enum value "VALUE2" is missing (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Enum value "VALUE2" is missing.');
});

it('accepts an additional enum value', () => {
Expand Down
12 changes: 3 additions & 9 deletions spec/model/compatibility-check/check-field-type.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "Test.field" needs to be of type "String" (required by module "module1").',
'Field "Test.field" needs to be of type "String".',
);
expectQuickFix(
result,
Expand All @@ -63,10 +63,7 @@ describe('checkModel', () => {
}
`,
);
expectSingleCompatibilityIssue(
result,
'Field "Test.field" needs to be a list (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Field "Test.field" needs to be a list.');
expectQuickFix(
result,
'Change type to "[String]"',
Expand All @@ -89,10 +86,7 @@ describe('checkModel', () => {
}
`,
);
expectSingleCompatibilityIssue(
result,
'Field "Test.field" should not be a list (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Field "Test.field" should not be a list.');
expectQuickFix(
result,
'Change type to "String"',
Expand Down
17 changes: 7 additions & 10 deletions spec/model/compatibility-check/check-flex-search-on-field.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ describe('checkModel', () => {
}
`,
);
expectSingleCompatibilityIssue(
result,
'Field "field" should enable @flexSearch (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Field "field" should enable @flexSearch.');
});

it('accepts @flexSearch is present', () => {
Expand Down Expand Up @@ -73,7 +70,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "field" should enable @flexSearch(includeInSearch: true) (required by module "module1").',
'Field "field" should enable @flexSearch(includeInSearch: true).',
);
});

Expand All @@ -92,7 +89,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "field" should enable @flexSearch(includeInSearch: true) (required by module "module1").',
'Field "field" should enable @flexSearch(includeInSearch: true).',
);
});

Expand Down Expand Up @@ -145,7 +142,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "field" should enable @flexSearchFulltext (required by module "module1").',
'Field "field" should enable @flexSearchFulltext.',
);
});

Expand All @@ -164,7 +161,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "field" should enable @flexSearchFulltext (required by module "module1").',
'Field "field" should enable @flexSearchFulltext.',
);
});

Expand Down Expand Up @@ -215,7 +212,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "field" should enable @flexSearch(includeInSearch: true) (required by module "module1").',
'Field "field" should enable @flexSearch(includeInSearch: true).',
);
});

Expand All @@ -234,7 +231,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "field" should enable @flexSearch(includeInSearch: true) (required by module "module1").',
'Field "field" should enable @flexSearch(includeInSearch: true).',
);
});

Expand Down
16 changes: 5 additions & 11 deletions spec/model/compatibility-check/check-flex-search-on-type.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ describe('checkModel', () => {
}
`,
);
expectSingleCompatibilityIssue(
result,
'Type "Test" needs to be enable flexSearch (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Type "Test" needs to be enable flexSearch.');
});

it('rejects if flexSearch is set to false', () => {
Expand All @@ -39,10 +36,7 @@ describe('checkModel', () => {
}
`,
);
expectSingleCompatibilityIssue(
result,
'Type "Test" needs to be enable flexSearch (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Type "Test" needs to be enable flexSearch.');
});

it('accepts if flexSearch is set to true even if not needed', () => {
Expand Down Expand Up @@ -81,7 +75,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Type "Test" should specify flexSearchOrder: [{field: "field", direction: ASC}] (required by module "module1").',
'Type "Test" should specify flexSearchOrder: [{field: "field", direction: ASC}].',
);
});

Expand All @@ -104,7 +98,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Type "Test" should not specify a custom flexSearchOrder (required by module "module1").',
'Type "Test" should not specify a custom flexSearchOrder.',
);
});

Expand Down Expand Up @@ -132,7 +126,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Type "Test" should specify flexSearchOrder: [{field: "field", direction: DESC}] (required by module "module1").',
'Type "Test" should specify flexSearchOrder: [{field: "field", direction: DESC}].',
);
});
});
Expand Down
9 changes: 3 additions & 6 deletions spec/model/compatibility-check/check-key-field.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "Test.field" needs to be decorated with @key (required by module "module1").',
'Field "Test.field" needs to be decorated with @key.',
);
});
it('accepts if the field is properly decorated with @key', () => {
Expand Down Expand Up @@ -55,10 +55,7 @@ describe('checkModel', () => {
}
`,
);
expectSingleCompatibilityIssue(
result,
'Field "id: ID @key" needs to be specified (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Field "id: ID @key" needs to be specified.');
});

it('rejects if the id field needs to be decorated with @key', () => {
Expand All @@ -79,7 +76,7 @@ describe('checkModel', () => {
);
expectSingleCompatibilityIssue(
result,
'Field "Test.id" needs to be decorated with @key (required by module "module1").',
'Field "Test.id" needs to be decorated with @key.',
);
});

Expand Down
5 changes: 1 addition & 4 deletions spec/model/compatibility-check/check-model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ type Test @rootEntity {
}
`,
);
expectSingleCompatibilityIssue(
result,
'Type "Test" needs to be a root entity type (required by module "module1").',
);
expectSingleCompatibilityIssue(result, 'Type "Test" needs to be a root entity type.');
});
});
});
Loading

0 comments on commit 9636341

Please sign in to comment.