YACS-RCOS / yacs-admin

Admin panel for YACS
MIT License
3 stars 5 forks source link

Bug: text input truncated in detail component tests #162

Open kburk1997 opened 6 years ago

kburk1997 commented 6 years ago

I discovered this bug while implementing tests for the course detail page. Any input over 30 characters in input fields is truncated when read as an attribute. This bug is addressed in the issue-120 branch in the course detail tests, but may still exist in the other detail tests.

How to reproduce this bug:

In any detail component spec, edit any text field in the object to be over 30 characters long. The test should fail as it will be comparing truncated input to the full data.

Known fix:

The test spec itself should look something like this:

expect([arbitraryElem].getAttribute('ng-reflect-model'))
  .toMatch(component.[object].[attribute]);

Note: [arbitraryElem], [object], and [attribute] are all arbitrary.

The test still passes as intended when the input is under 30 characters. In cases like course descriptions and even some course names, we will run into input that is over 30 characters. To get the test to pass regardless of input length, change the test to:

expect([arbitraryElem].getAttribute('ng-reflect-model'))
  .toMatch(component.[object].[attribute],substr(0,30));

This fix is already implemented in the course-detail component, but needs to be implemented in school-detail, department-detail, and in the future section-detail.