Unbundle core classes from the tests JavaScript bundle.

Review Request #13337 — Created Oct. 12, 2023 and submitted — Latest diff uploaded

Information

Review Board
release-6.x

Reviewers

Many of our new TypeScript-based JavaScript unit tests were doing
relative imports for the modules they want to test. This caused the
tests to test against a copy of the core classes normally exported to
the RB namespace, which meant:

  1. We weren't testing the actual exposed classes, which could cause
    state issues or duplicate initialization.

  2. We were ballooning the size of our tests JavaScript bundle and the
    memory/load time for the page.

  3. We weren't in a position to catch whether we properly exported a
    class to RB when converting TypeScript code.

Fortunately, issues #1 and #3 haven't been a problem so far, but it's
too easy for something to go wrong there. We want to be testing the same
code and state that the Review Board pages would be loading themselves.

This change updates all the imports in the unit tests to import from the
exported bundles.

All JavaScript unit tests pass.

Verified that the resulting bundle file only had unit test code in it.

Diff Revision 2 (Latest)

orig
1
2

Commits

First Last Summary ID Author
Unbundle core classes from the tests JavaScript bundle.
Many of our new TypeScript-based JavaScript unit tests were doing relative imports for the modules they want to test. This caused the tests to test against a copy of the core classes normally exported to the `RB` namespace, which meant: 1. We weren't testing the actual exposed classes, which could cause state issues or duplicate initialization. 2. We were ballooning the size of our tests JavaScript bundle and the memory/load time for the page. 3. We weren't in a position to catch whether we properly exported a class to `RB` when converting TypeScript code. Fortunately, issues #1 and #3 haven't been a problem so far, but it's too easy for something to go wrong there. We want to be testing the same code and state that the Review Board pages would be loading themselves. This change updates all the imports in the unit tests to import from the exported bundles.
ef27472e59f3f9f3698e25477eb8520d78d87aae Christian Hammond

Files

reviewboard/static/rb/js/common/models/tests/commChannelModelTests.ts
reviewboard/static/rb/js/common/models/tests/extraDataModelTests.ts
reviewboard/static/rb/js/common/resources/collections/tests/resourceCollectionTests.ts
reviewboard/static/rb/js/common/resources/models/tests/baseResourceModelTests.ts
reviewboard/static/rb/js/common/resources/models/tests/draftReviewModelTests.ts
reviewboard/static/rb/js/common/resources/models/tests/fileAttachmentModelTests.ts
reviewboard/static/rb/js/common/resources/models/tests/reviewModelTests.ts
reviewboard/static/rb/js/common/resources/models/tests/reviewReplyModelTests.ts
reviewboard/static/rb/js/common/views/tests/pageViewTests.ts
reviewboard/static/rb/js/reviews/models/tests/commentEditorModelTests.ts
reviewboard/static/rb/js/reviews/models/tests/diffViewerPageModelTests.ts
reviewboard/static/rb/js/reviews/models/tests/reviewRequestEditorModelTests.ts
reviewboard/static/rb/js/reviews/models/tests/reviewablePageModelTests.ts
reviewboard/static/rb/js/reviews/views/tests/commentDialogViewTests.ts
reviewboard/static/rb/js/reviews/views/tests/diffViewerPageViewTests.ts
reviewboard/static/rb/js/reviews/views/tests/fileAttachmentThumbnailViewTests.ts
reviewboard/static/rb/js/reviews/views/tests/reviewDialogViewTests.ts
reviewboard/static/rb/js/reviews/views/tests/reviewRequestEditorViewTests.ts
reviewboard/static/rb/js/reviews/views/tests/reviewRequestFieldViewsTests.ts
reviewboard/static/rb/js/reviews/views/tests/reviewablePageViewTests.ts
reviewboard/static/rb/js/ui/models/tests/contentViewportTests.ts
reviewboard/static/rb/js/ui/views/tests/dateInlineEditorViewTests.ts
reviewboard/static/rb/js/ui/views/tests/dateTimeInlineEditorViewTests.ts
reviewboard/static/rb/js/ui/views/tests/inlineEditorViewTests.ts
reviewboard/static/rb/js/ui/views/tests/textEditorViewTests.ts
reviewboard/static/rb/js/common/models/tests/commChannelModelTests.ts
reviewboard/static/rb/js/common/models/tests/extraDataModelTests.ts
reviewboard/static/rb/js/common/resources/collections/tests/resourceCollectionTests.ts
reviewboard/static/rb/js/common/resources/models/tests/baseResourceModelTests.ts
reviewboard/static/rb/js/common/resources/models/tests/draftReviewModelTests.ts
reviewboard/static/rb/js/common/resources/models/tests/fileAttachmentModelTests.ts
reviewboard/static/rb/js/common/resources/models/tests/reviewModelTests.ts
reviewboard/static/rb/js/common/resources/models/tests/reviewReplyModelTests.ts
reviewboard/static/rb/js/common/views/tests/pageViewTests.ts
reviewboard/static/rb/js/reviews/models/tests/commentEditorModelTests.ts
reviewboard/static/rb/js/reviews/models/tests/diffViewerPageModelTests.ts
reviewboard/static/rb/js/reviews/models/tests/reviewRequestEditorModelTests.ts
reviewboard/static/rb/js/reviews/models/tests/reviewablePageModelTests.ts
reviewboard/static/rb/js/reviews/views/tests/commentDialogViewTests.ts
reviewboard/static/rb/js/reviews/views/tests/diffViewerPageViewTests.ts
reviewboard/static/rb/js/reviews/views/tests/fileAttachmentThumbnailViewTests.ts
reviewboard/static/rb/js/reviews/views/tests/reviewDialogViewTests.ts
reviewboard/static/rb/js/reviews/views/tests/reviewRequestEditorViewTests.ts
reviewboard/static/rb/js/reviews/views/tests/reviewRequestFieldViewsTests.ts
reviewboard/static/rb/js/reviews/views/tests/reviewablePageViewTests.ts
reviewboard/static/rb/js/ui/models/tests/contentViewportTests.ts
reviewboard/static/rb/js/ui/views/tests/dateInlineEditorViewTests.ts
reviewboard/static/rb/js/ui/views/tests/dateTimeInlineEditorViewTests.ts
reviewboard/static/rb/js/ui/views/tests/inlineEditorViewTests.ts
reviewboard/static/rb/js/ui/views/tests/textEditorViewTests.ts
Loading...