Sync cursor position to PDF when double-clicking on a heading in the file outline (#7314)
GitOrigin-RevId: ef98f5d20e99bfc03c91cbf4027d277e738ab176
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user