Skip to content

Commit

Permalink
Allow white spaces at start and end of number and write e2e tests to …
Browse files Browse the repository at this point in the history
…see if error message is shown
  • Loading branch information
RandomTannenbaum authored and nevio18324 committed Jan 23, 2025
1 parent 71d5cf3 commit f2d53cd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
22 changes: 22 additions & 0 deletions frontend/cypress/e2e/check-in.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ describe('okr check-in', () => {
cy.contains('- A new action on the action-plan');
});

it('should show an error message when new check-in value is not numeric', () => {
overviewPage
.addKeyResult()
.fillKeyResultTitle('This key-result will have errors')
.withMetricValues(Unit.NUMBER, '21', '51')
.submit();

const detailPage = keyResultDetailPage
.visit('Very important keyresult')
.createCheckIn()
.fillMetricCheckInValue('asdf');
cy.contains('Neuer Wert muss eine Zahl sein.');

detailPage.fillMetricCheckInValue('21. 2');
cy.contains('Neuer Wert muss eine Zahl sein.');

detailPage.fillMetricCheckInValue('123');
cy.contains('Neuer Wert muss eine Zahl sein.')
.should('not.exist');
});


it('should create check-in metric and assert correct owner', () => {
overviewPage
.addKeyResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,14 @@ describe('CheckInFormComponent', () => {
true],
[-100.3,
true],
['123',
[' 123 ',
true],
['-123.4',
[' -123.4 ',
true],
['12 .3',
false],
['1 2',
false],
['',
false],
['asdf',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class CheckInFormMetricComponent implements OnInit {

ngOnInit() {
this.dialogForm.controls['value'].setValidators([Validators.required,
Validators.pattern('^-?\\d+\\.?\\d*$')]);
Validators.pattern('^\\s*-?\\d+\\.?\\d*\\s*$')]);
}

generateUnitLabel(): string {
Expand Down

0 comments on commit f2d53cd

Please sign in to comment.