• Robert Knight's avatar
    Make Sidebar collaborate with rather than inherit from Guest · b52f00e0
    Robert Knight authored
    Change the relationship between the `Guest` and `Sidebar` classes from
    one of inheritance to one where `Sidebar` receives a reference to the
    `Guest` instance and calls methods on it or subscribes to events from
    it. The `Guest` also no longer "owns" references to the bucket bar /
    toolbar objects that logically belong to the sidebar. Instead it emits
    events which the sidebar responds to.
    
    This change makes the interface of the `Guest` used by the `Sidebar`
    more explicit and ensures a better boundary between the two. This also
    makes it easier for the `Sidebar` tests to be concerned only with the
    interface of the `Guest` and not its implementation details. In future
    this change will also make it possible to have a frame which does not
    contain a sidebar but is not annotateable. We had a need for this
    historically when integrating with epub viewers, although it was never
    implemented.
    
    Updating the tests for `PdfSidebar` was complicated by the fact that the
    `PdfSidebar` tests are not pure unit tests. They instantiate the
    `Sidebar` base class and so depend on many implementation details of it.
    To make this change and others easier, the `PdfSidebar` tests have been
    changed to mock the `Sidebar` base class. The steps involved in this are
    non-obvious so I extracted the logic into a utility function.
    
     - Change `Sidebar` to no longer inherit `Guest` but accept it as a
       constructor argument
     - Remove direct references to the `BucketBar` and `ToolbarController`
       instances from the `Guest` class and instead emit events from the
       `Guest` which the `Sidebar` responds to.
     - Add a `mockBaseClass` testing helper in `src/test-util/mock-base.js`
       and change the `PdfSidebar` tests to use it, so that they are less
       coupled to `Sidebar` implementation details.
    b52f00e0
Name
Last commit
Last update
.github Loading commit data...
bin Loading commit data...
dev-server Loading commit data...
docs Loading commit data...
embedding-examples Loading commit data...
frontend-shared Loading commit data...
images Loading commit data...
scripts Loading commit data...
src Loading commit data...
.babelrc Loading commit data...
.dockerignore Loading commit data...
.eslintignore Loading commit data...
.eslintrc Loading commit data...
.gitignore Loading commit data...
.npmignore Loading commit data...
.npmrc Loading commit data...
.prettierignore Loading commit data...
.python-version Loading commit data...
CODE_OF_CONDUCT Loading commit data...
Dockerfile Loading commit data...
Jenkinsfile Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
codecov.yml Loading commit data...
gulpfile.js Loading commit data...
package.json Loading commit data...
requirements-dev.in Loading commit data...
tox.ini Loading commit data...
yarn.lock Loading commit data...