Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

TPv2 Testing improvements#6513

Merged
shamrickus merged 50 commits intoapache:masterfrom
ocket8888:tpv2/testing-improvements
Feb 9, 2022
Merged

TPv2 Testing improvements#6513
shamrickus merged 50 commits intoapache:masterfrom
ocket8888:tpv2/testing-improvements

Conversation

@ocket8888
Copy link
Copy Markdown
Contributor

@ocket8888 ocket8888 commented Jan 14, 2022

Primarily this PR improves unit testing coverage by a ton, from

  • 34.93% Statements 612/1752
  • 21.12% Branches 109/516
  • 27.18% Functions 112/412
  • 33.51% Lines 562/1677

to

  • 90.8% Statements 1126/1240
  • 82.74% Branches 307/371
  • 92.03% Functions 231/251
  • 90.43% Lines 1078/1192

Part of how it does this is by separating out the API services into their own module, with a testing module that provides mock services. Prior to this, a running Traffic Ops instance would have been required to run the unit tests written for this PR - this is no longer the case, and should never again be the case in the future.

It's also true that, because of this, the API services are not under test (not that they were before these changes), and are not included in the coverage statistics. At some point, any logic beyond sending HTTP requests probably ought to be extracted from those files to both further enhance test coverage as well as give a more accurate coverage report.

This also fixes an issue where coverage could not be generated due to using a legacy plugin for which support has been dropped, updates Angular to version 13.2.0, and reduces npm audit-found vulnerabilities from 40 vulnerabilities (2 low, 35 moderate, 3 high) to literally 0.

I've also added four NPM scripts - doc, which generates documentation for the project using compodoc (optional dependency), doc:serve which serves the documentation over HTTP on localhost, coverage which runs the unit tests and outputs coverage information, and coverage:ci which runs the unit tests without watching for changes and in a headless browser and outputs coverage information.

Finally, during the writing of tests a few bugs were uncovered and subsequently fixed.


Which Traffic Control components are affected by this PR?

None

What is the best way to verify this PR?

Make sure all the new tests pass, check out the code coverage to verify it if you want (running the tests with coverage output will fail on master for the reasons I specified above, so you'd need to install the correct karma plugin and update configuration accordingly to get it to work).

PR submission checklist

  • This PR has tests
  • This PR has documentation (typedoc generation script)
  • This PR has a CHANGELOG.md entry
  • This PR DOES NOT FIX A SERIOUS SECURITY VULNERABILITY

@ocket8888 ocket8888 added low impact affects only a small portion of a CDN, and cannot itself break one tests related to tests and/or testing infrastructure tech debt rework due to choosing easy/limited solution improvement The functionality exists but it could be improved in some way. experimental a feature/component not directly supported by ATC labels Jan 14, 2022
(cherry picked from commit 699ff7232593a74d90c0856f4224e0197087efd4)
(cherry picked from commit b3f8fa87bcbf96431e60637215405376e6680e26)
(Replaced by Angular Material MatDialog)

(cherry picked from commit 593a04ce36334ae9e60c6e6580dd4532476279bf)
(cherry picked from commit 73891df8e6368d1d5801d93b5d7ef7a537aaa890)
and also putting newlines between import groups and alphabetization
within groups

finally, importing from "../../**/*" is no longer allowed.
Also the tests revealed a shortcoming of the directive where it failed
to properly implement the behavior of the browser-native
`HTMLObjectElement.setCustomValidity` where passing an empty string
marked the customError part of its validity state as non-erroneous.
Also made the header's `logout` method asynchronous for ease of use.
This also helped me fix a bug - the component was unable to successfully
update any server's or servers' status(es) because it was passing a
Status ID instead of a Name.

Also made the submit handler async because that's much easier to deal
with.
I also simplified a couple of methods by making them asynchronous
Also updated the actual component to use an async method to handle
form submission, for ease-of-use.
This also uncovered a bug in rendering HTTP_ONLY protocol strings, which
is now fixed.
@ocket8888 ocket8888 force-pushed the tpv2/testing-improvements branch from c126779 to 4e7a015 Compare January 28, 2022 15:38
I enabled that rule just for myself going through the
project so that I could update things as I went along
but because the rule isn't Angular-aware, it's
emitting warnings for types used for dependency
injection, which breaks compilation if 'fixed' (e.g.
with 'ng lint --fix').
Has better support for Angular concepts. Also, is now an optional
dependency rather than a development dependency.
@ocket8888 ocket8888 force-pushed the tpv2/testing-improvements branch from 9f311ff to ff4d856 Compare January 28, 2022 17:28
@ocket8888 ocket8888 requested a review from shamrickus January 28, 2022 17:45
@shamrickus shamrickus self-assigned this Feb 2, 2022
Copy link
Copy Markdown
Member

@shamrickus shamrickus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shamrickus shamrickus merged commit 932de18 into apache:master Feb 9, 2022
@ocket8888 ocket8888 deleted the tpv2/testing-improvements branch February 9, 2022 20:42
@zrhoffman zrhoffman mentioned this pull request Feb 10, 2022
4 tasks
@zrhoffman zrhoffman added the Traffic Portal v2 Related to the experimental Traffic Portal version 2 label Jun 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

experimental a feature/component not directly supported by ATC improvement The functionality exists but it could be improved in some way. low impact affects only a small portion of a CDN, and cannot itself break one tech debt rework due to choosing easy/limited solution tests related to tests and/or testing infrastructure Traffic Portal v2 Related to the experimental Traffic Portal version 2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants