Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move unit tests adjacent to the source of the system under testing #95023

Closed
8 of 9 tasks
JunTaoLuo opened this issue Oct 15, 2024 · 3 comments
Closed
8 of 9 tasks

Move unit tests adjacent to the source of the system under testing #95023

JunTaoLuo opened this issue Oct 15, 2024 · 3 comments
Assignees
Labels
appointments VA Online Scheduling tool product tag frontend tech-debt testing

Comments

@JunTaoLuo
Copy link
Contributor

JunTaoLuo commented Oct 15, 2024

As part of the effort to improve our unit tests, we've decided to move unit tests to the same directory as the source file of the system under testing.

For example:

src\applications\vaos\
- components\subdirectoryA
  \- SubcomponentA.jsx
   - SubcomponentA.unit.spec.js
 - Component1.jsx
 - Component1.unit.spec
- test\
 \- testUtility.js 

Primarily, this provides the benefit of making it easier to find the associated test file for each component and to identify which source files is missing associated tests.

Note that naming of the unit tests should:

  • start with the same file name as the source file, until the file extension
  • end with .unit.spec.js as specified here.

We'll likely do this in smaller steps, note that some of these tests will have been removed as part of the remove obsolete components work.

  • 1.
./src/applications/vaos/tests/appointment-list/components/AppointmentsPage.unit.spec.js
./src/applications/vaos/tests/appointment-list/components/BackendAppointmentServiceAlert.unit.spec.js
./src/applications/vaos/tests/appointment-list/components/ConfirmedAppointmentDetailsPage/index.unit.spec.js
./src/applications/vaos/tests/appointment-list/components/PastAppointmentsListV2.unit.spec.js
./src/applications/vaos/tests/appointment-list/components/RequestedAppointmentDetailsPage.unit.spec.js
./src/applications/vaos/tests/appointment-list/components/RequestedAppointmentListGroup.unit.spec.js
./src/applications/vaos/tests/appointment-list/components/RequestedAppointmentsList.unit.spec.js
./src/applications/vaos/tests/appointment-list/components/UpcomingAppointmentsList.unit.spec.js
./src/applications/vaos/tests/appointment-list/index.unit.spec.js
./src/applications/vaos/tests/components/AddToCalendar.unit.spec.js
./src/applications/vaos/tests/components/Breadcrumbs.unit.spec.js
./src/applications/vaos/tests/components/EnrolledRoute.unit.spec.js
./src/applications/vaos/tests/components/ErrorBoundary.unit.spec.js
./src/applications/vaos/tests/components/FacilityAddress.unit.spec.js
./src/applications/vaos/tests/components/NeedHelp.unit.spec.js
./src/applications/vaos/tests/components/NewTabAnchor.unit.spec.js
./src/applications/vaos/tests/components/TextareaWidget.unit.spec.js
./src/applications/vaos/tests/components/VAOSApp/index.unit.spec.js
  • 2.

./src/applications/vaos/tests/new-appointment/components/ClinicChoicePage.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/ClosestCityStatePage.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/CommunityCareLanguagePage.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/CommunityCareProviderSelectionPage/ProviderSortVariant.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/CommunityCareProviderSelectionPage/index.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/ConfirmationPage/ConfirmationDirectScheduleInfoV2.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/ContactInfoPage.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/DateTimeRequestPage/index.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/DateTimeSelectPage/index.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/PreferredDatePage.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/ReasonForAppointmentPage.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/ReviewPage/ContactDetailSection.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/ReviewPage/index.cc-request.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/ReviewPage/index.direct.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/ReviewPage/index.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/ReviewPage/index.va-request.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/ScheduleCernerPage.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/TypeOfAudiologyCare.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/TypeOfEyeCarePage.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/TypeOfFacilityPage.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/TypeOfSleepCarePage.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/TypeOfVisitPage.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/VAFacilityPage/index.eligibility.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/VAFacilityPage/index.unit.spec.js
./src/applications/vaos/tests/new-appointment/newAppointmentFlow.unit.spec.js
./src/applications/vaos/tests/new-appointment/redux/actions.unit.spec.js
./src/applications/vaos/tests/new-appointment/redux/helpers/formSubmitTransformers.unit.spec.js
./src/applications/vaos/tests/new-appointment/redux/helpers/formSubmitTransformers.v2.unit.spec.js
./src/applications/vaos/appointment-list/components/PastAppointmentsList/tests/PastAppointmentsDateDropdown.unit.spec.js
./src/applications/vaos/services/appointment/tests/transformers.unit.spec.js
  • 3.
./src/applications/vaos/tests/covid-19-vaccine/components/ClinicChoicePage.unit.spec.js
./src/applications/vaos/tests/covid-19-vaccine/components/ConfirmationPage.unit.spec.js
./src/applications/vaos/tests/covid-19-vaccine/components/ConfirmationPageV2.unit.spec.js
./src/applications/vaos/tests/covid-19-vaccine/components/ContactFacilitiesPage.unit.spec.js
./src/applications/vaos/tests/covid-19-vaccine/components/ContactInfoPage.unit.spec.js
./src/applications/vaos/tests/covid-19-vaccine/components/NewBookingPage.unit.spec.js
./src/applications/vaos/tests/covid-19-vaccine/components/PlanAheadPage.unit.spec.js
./src/applications/vaos/tests/covid-19-vaccine/components/ReceivedDoseScreenerPage.unit.spec.js
./src/applications/vaos/tests/covid-19-vaccine/components/ReviewPage.unit.spec.js
./src/applications/vaos/tests/covid-19-vaccine/components/SecondDosePage.unit.spec.js
./src/applications/vaos/tests/covid-19-vaccine/components/SelectDate1Page.unit.spec.js
./src/applications/vaos/tests/covid-19-vaccine/components/VAFacilityPage/index.unit.spec.js
./src/applications/vaos/tests/referral-appointments/ChooseDateAndTime.unit.spec.js
./src/applications/vaos/tests/referral-appointments/components/ReferralReview.unit.spec.js
./src/applications/vaos/tests/services/appointment/index.unit.spec.js
./src/applications/vaos/tests/services/healthcare-service/index.unit.spec.js
./src/applications/vaos/tests/services/location/index.unit.spec.js
./src/applications/vaos/tests/services/mocks/index.unit.spec.js
./src/applications/vaos/tests/services/slot/index.unit.spec.js
./src/applications/vaos/tests/services/utils.unit.spec.js
./src/applications/vaos/tests/services/vaos/index.unit.spec.js
./src/applications/vaos/tests/utils/appointment.unit.spec.js
./src/applications/vaos/tests/utils/error.unit.spec.js
./src/applications/vaos/tests/utils/formatters.unit.spec.js
./src/applications/vaos/tests/utils/timezone.unit.spec.js
  • 4.
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/AtlasLocation.unit.spec.js
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/CCInstructions.unit.spec.js
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/CancelLink.unit.spec.js
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/DetailsVA.unit.spec.js
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/DetailsVA.util.unit.spec.js
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/NoOnlineCancelAlert.unit.spec.js
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/PrintButton.unit.spec.js
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/PrintLink.unit.spec.js
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/ProviderName.unit.spec.js
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/StatusAlert.unit.spec.js
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/TypeHeader.unit.spec.js
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/VAInstructions.unit.spec.js
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/VideoInstructionsLink.unit.spec.js
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/VideoLink.unit.spec.js
./src/applications/vaos/appointment-list/components/ConfirmedAppointmentDetailsPage/tests/VideoVisitInstructions.unit.spec.js
./src/applications/vaos/appointment-list/components/PastAppointmentsList/tests/PastAppointmentsDateDropdown.unit.spec.js
./src/applications/vaos/appointment-list/components/tests/AppointmentColumn.unit.spec.js
./src/applications/vaos/appointment-list/components/tests/AppointmentRow.unit.spec.js
./src/applications/vaos/appointment-list/components/tests/NoAppointments.unit.spec.js
./src/applications/vaos/appointment-list/hooks/tests/use-handle-click.unit.spec.js
./src/applications/vaos/appointment-list/hooks/tests/use-handle-key-down.unit.spec.js
./src/applications/vaos/appointment-list/redux/tests/selectors.unit.spec.js
./src/applications/vaos/appointment-list/tests/index.unit.spec.js
  • 5.
./src/applications/vaos/components/tests/AfterVisitSummary.unit.spec.js
./src/applications/vaos/components/tests/AppointmentCard.unit.spec.js
./src/applications/vaos/components/tests/AppointmentCardIcon.unit.spec.js
./src/applications/vaos/components/tests/CCLayout.unit.spec.js
./src/applications/vaos/components/tests/CCRequestLayout.unit.spec.js
./src/applications/vaos/components/tests/ClaimExamLayout.unit.spec.js
./src/applications/vaos/components/tests/InPersonLayout.unit.spec.js
./src/applications/vaos/components/tests/PhoneLayout.unit.spec.js
./src/applications/vaos/components/tests/VARequestLayout.unit.spec.js
./src/applications/vaos/components/tests/VideoInstructions.unit.spec.js
./src/applications/vaos/components/tests/VideoLayout.unit.spec.js
./src/applications/vaos/components/tests/VideoLayoutAtlas.unit.spec.js
./src/applications/vaos/components/tests/VideoLayoutVA.unit.spec.js
./src/applications/vaos/components/tests/VideoLink.unit.spec.js
./src/applications/vaos/services/appointment/tests/transformers.unit.spec.js
./src/applications/vaos/tests/new-appointment/components/TypeOfCarePage.unit.spec.js

Definition of Done

  • All unit existing tests are moved to match the specifications in the description above
  • All unit tests are recognized by the test runner and pass (locally and on CI)
  • Coverage metrics remain constant before and after the change
@JunTaoLuo JunTaoLuo added appointments VA Online Scheduling tool product tag frontend needs-grooming Use this to designate any issues that need grooming from the team testing labels Oct 15, 2024
@JunTaoLuo
Copy link
Contributor Author

JunTaoLuo commented Oct 15, 2024

One open question is where should the test utilities (e.g. mocks, helpers) be located? If it is placed in the same directory as the source and unit test files, it becomes a little more difficult to differentiate between source files and test utilities. We need to test this out to ensure the coverage tool recognizes test utilities correctly.

Update: we decided to keep test utilities in the top level test directory.

cc @simiadebowale @vbahinwillit

@Bren22va
Copy link
Contributor

@JunTaoLuo
Copy link
Contributor Author

JunTaoLuo commented Nov 6, 2024

All tests are passing locally and on the CI. The coverage remained the same as well:

Image

The only remaining item is to move one last test which will be completed in #95332.

Since this is a test only change, there's no further validation needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
appointments VA Online Scheduling tool product tag frontend tech-debt testing
Projects
None yet
Development

No branches or pull requests

3 participants