Sync cursor position to PDF when double-clicking on a heading in the file outline (#7314)

GitOrigin-RevId: ef98f5d20e99bfc03c91cbf4027d277e738ab176
This commit is contained in:
Alf Eaton
2022-04-11 08:03:14 +00:00
committed by Copybot
parent 5cb46643da
commit aca889a3e0
4 changed files with 30 additions and 16 deletions
@@ -1,6 +1,6 @@
import { expect } from 'chai'
import sinon from 'sinon'
import { screen, render, fireEvent } from '@testing-library/react'
import { screen, render, fireEvent, waitFor } from '@testing-library/react'
import OutlineItem from '../../../../../frontend/js/features/outline/components/outline-item'
@@ -82,7 +82,7 @@ describe('<OutlineItem />', function () {
screen.getByRole('treeitem', { name: 'Parent', current: true })
})
it('click and double-click jump to location', function () {
it('click and double-click jump to location', async function () {
const outlineItem = {
title: 'Parent',
line: 1,
@@ -91,13 +91,17 @@ describe('<OutlineItem />', function () {
const titleButton = screen.getByRole('button', { name: outlineItem.title })
fireEvent.click(titleButton)
expect(jumpToLine).to.be.calledOnce
expect(jumpToLine).to.be.calledWith(1, false)
fireEvent.click(titleButton, { detail: 1 })
await waitFor(() => {
expect(jumpToLine).to.be.calledOnce
expect(jumpToLine).to.be.calledWith(1, false)
})
jumpToLine.reset()
fireEvent.doubleClick(titleButton)
expect(jumpToLine).to.be.calledOnce
expect(jumpToLine).to.be.calledWith(1, true)
fireEvent.click(titleButton, { detail: 2 })
await waitFor(() => {
expect(jumpToLine).to.be.calledOnce
expect(jumpToLine).to.be.calledWith(1, true)
})
})
})
@@ -79,6 +79,7 @@ export function EditorProviders({
callback(get($scope, path))
return () => null
},
$on: sinon.stub(),
$applyAsync: sinon.stub(),
toggleHistory: sinon.stub(),
permissionsLevel,