opened
seanh
username_0
Depends on https://github.com/hypothesis/h/pull/5045

These tests are kind of duplicative of the existing [tests for `separate_replies`](https://github.com/hypothesis/h/blob/49fd4cb4e415ac79e8144715bb2f677f3926f678/tests/h/search/core_test.py#L124). The `separate_replies` tests also test that replies are filtered out of `annotation_ids` but annotations are left in. But those are tests for the `separate_replies` argument, which is partly implemented by `TopLevelAnnotationsFilter`, partly by `RepliesMatcher`, and partly by code in `Search` itself. The fact that `TopLevelAnnotationsFilter` and `RepliesMatcher` are used to implement `separate_replies` is an internal implementation detail (`separate_replies` could be refactored to no longer use `TopLevelAnnotationsFilter` and its tests would still pass).

The tests in this PR are tests for `TopLevelAnnotationsFilter` when used directly (without `separate_replies`) as is [done by activity pages](https://github.com/hypothesis/h/blob/362143c17d7cd090255d9d36d6fecfbbb750218e/h/activity/query.py#L171).

Also, `TopLevelAnnotationsFilter` has to have a `TestTopLevelAnnotationsFilter` where you would expect one to be, otherwise it would look like there were no tests for it. Meanwhile, the filtering out of replies (while leaving annotations in) kind of has to be tested by the `separate_replies` tests otherwise `separate_replies` isn't fully tested. (Because of the way the code is written you can't really write a "Test that it uses `TopLevelAnnotationsFilter`" test for `separate_replies` that uses a mock `TopLevelAnnotationsFilter`, you would have to mock out `Builder` or something.)
Add tests for TopLevelAnnotationsFilter
issue