Fix a unit test regression for tests using RB.DraftReviewBannerView.

Review Request #10935 — Created March 3, 2020 and submitted

Information

Review Board
release-4.0.x

Reviewers

RB.DraftReviewBannerView instantiates a RB.SplitButtonView, which
wraps the new RB.MenuButtonView. This is a bit more strict than the
older RB.SplitButtonView with DOM elements actually being available on
the page. The problem is that during unit test runs, the HTML backing
RB.DraftReviewBannerView is not available, and this ultimately leads
to assertion failures in the menu button.

This is easily solved by making sure we pass in either a DOM element or
a falsy value, rather than a jQuery object with a length of 0. This
change updates the instantiation to do that.

It also adds a big comment above it to point out this fact, for future
work on the banner. Sooner or later, we're going to want to move this to
a CSS component and change the way it's structured, and this quirk will
be important to note at that time.

All unit tests pass.

Manually tested that the review request and diff viewer pages had a
functioning draft banner and Publish button.

Summary ID
Fix a unit test regression for tests using RB.DraftReviewBannerView.
`RB.DraftReviewBannerView` instantiates a `RB.SplitButtonView`, which wraps the new `RB.MenuButtonView`. This is a bit more strict than the older `RB.SplitButtonView` with DOM elements actually being available on the page. The problem is that during unit test runs, the HTML backing `RB.DraftReviewBannerView` is not available, and this ultimately leads to assertion failures in the menu button. This is easily solved by making sure we pass in either a DOM element or a falsy value, rather than a jQuery object with a length of 0. This change updates the instantiation to do that. It also adds a big comment above it to point out this fact, for future work on the banner. Sooner or later, we're going to want to move this to a CSS component and change the way it's structured, and this quirk will be important to note at that time.
fd3e580e27adb3d0ccf5e4b6d407def27f248458
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-4.0.x (9ac944c)