Add unit tests for RB.PageView, and fix JS test runs on RB4.

Review Request #10734 — Created Oct. 2, 2019 and submitted

Review Board

This introduces unit tests for RB.PageView. As this class becomes more
crucial to the rendering of pages, we need to ensure its behavior
continues to work as expected. The new unit tests ensure that by
covering all the current aspects of the page, including state
calculation, rendering, event handling, and drawer setup. These are
tested in all the various modes (mobile/desktop, full-page content,
and sidebar modes).

Given that RB.PageView (and RB.HeaderView, one of the utility views
it uses) modify the actual page structure itself (which interferes with
the page running the tests), they needed to be updated to allow callers
to pass in specific page elements to use. These will have no effect on a
typical page render, but allow unit tests to sandbox the page
modifications that the views want to make.

The views have also been updated to clean up any global event registration
they perform.

This also fixes up the JavaScript unit test page to properly load the
stylesheet for the page, which regressed during cleanup of the base
template in commit 123665fa1695670cd7ec3d5fe9ab26cb8057bce1.

All unit tests pass.

  1. Ship It!
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.0.x (b5bb2b7)