Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sidebar-closing tests in Guest less brittle #5608

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/annotator/test/guest-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,10 @@ describe('Guest', () => {
fakeSidebarFrame?.remove();
});

function sidebarClosed() {
return sidebarRPC().call.calledWith('closeSidebar');
}

context('clicks/taps on the document', () => {
const simulateClick = (element = rootElement, clientX = 0) =>
element.dispatchEvent(
Expand All @@ -632,18 +636,18 @@ describe('Guest', () => {

it('hides sidebar', () => {
simulateClick();
assert.calledWith(sidebarRPC().call, 'closeSidebar');
assert.isTrue(sidebarClosed());
});

it('does not hide sidebar if target is a highlight', () => {
simulateClick(fakeHighlight);
assert.notCalled(sidebarRPC().call);
assert.isFalse(sidebarClosed());
});

it('does not hide sidebar if side-by-side mode is active', () => {
fakeIntegration.sideBySideActive.returns(true);
simulateClick();
assert.notCalled(sidebarRPC().call);
assert.isFalse(sidebarClosed());
});

it('does not hide sidebar if event is within the bounds of the sidebar', () => {
Expand All @@ -653,7 +657,7 @@ describe('Guest', () => {
// Simulate click on the left edge of the sidebar.
simulateClick(rootElement, window.innerWidth - 295);

assert.notCalled(sidebarRPC().call);
assert.isFalse(sidebarClosed());
});
});

Expand Down