|
14 | 14 | */ |
15 | 15 |
|
16 | 16 | import { |
| 17 | + awaitPromise, |
17 | 18 | closePages, |
| 19 | + createPromise, |
18 | 20 | dragAndDrop, |
19 | 21 | getEditorSelector, |
20 | 22 | getRect, |
@@ -301,6 +303,71 @@ describe("Comment", () => { |
301 | 303 | }); |
302 | 304 | }); |
303 | 305 |
|
| 306 | + describe("Focused element after editing", () => { |
| 307 | + let pages; |
| 308 | + |
| 309 | + beforeEach(async () => { |
| 310 | + pages = await loadAndWait( |
| 311 | + "tracemonkey.pdf", |
| 312 | + ".annotationEditorLayer", |
| 313 | + "page-width", |
| 314 | + null, |
| 315 | + { enableComment: true } |
| 316 | + ); |
| 317 | + }); |
| 318 | + |
| 319 | + afterEach(async () => { |
| 320 | + await closePages(pages); |
| 321 | + }); |
| 322 | + |
| 323 | + it("must check that the focus is moved on the comment button", async () => { |
| 324 | + await Promise.all( |
| 325 | + pages.map(async ([browserName, page]) => { |
| 326 | + await switchToHighlight(page); |
| 327 | + |
| 328 | + const rect = await getSpanRectFromText(page, 1, "Languages"); |
| 329 | + const x = rect.x + rect.width / 2; |
| 330 | + const y = rect.y + rect.height / 2; |
| 331 | + await page.mouse.click(x, y, { count: 2, delay: 100 }); |
| 332 | + await page.waitForSelector(getEditorSelector(0)); |
| 333 | + |
| 334 | + const commentButtonSelector = `${getEditorSelector(0)} button.comment`; |
| 335 | + await waitAndClick(page, commentButtonSelector); |
| 336 | + |
| 337 | + await page.waitForSelector("#commentManagerCancelButton", { |
| 338 | + visible: true, |
| 339 | + }); |
| 340 | + const handle = await createPromise(page, resolve => { |
| 341 | + document |
| 342 | + .querySelector("button.comment") |
| 343 | + .addEventListener("focus", resolve, { once: true }); |
| 344 | + }); |
| 345 | + await page.click("#commentManagerCancelButton"); |
| 346 | + await awaitPromise(handle); |
| 347 | + |
| 348 | + await waitAndClick(page, commentButtonSelector); |
| 349 | + |
| 350 | + const textInputSelector = "#commentManagerTextInput"; |
| 351 | + await page.waitForSelector(textInputSelector, { |
| 352 | + visible: true, |
| 353 | + }); |
| 354 | + await page.type(textInputSelector, "Hello world!"); |
| 355 | + |
| 356 | + await page.click("#commentManagerSaveButton"); |
| 357 | + await page.waitForSelector("button.annotationCommentButton", { |
| 358 | + visible: true, |
| 359 | + }); |
| 360 | + |
| 361 | + await page.waitForFunction( |
| 362 | + sel => document.activeElement === document.querySelector(sel), |
| 363 | + {}, |
| 364 | + "button.annotationCommentButton" |
| 365 | + ); |
| 366 | + }) |
| 367 | + ); |
| 368 | + }); |
| 369 | + }); |
| 370 | + |
304 | 371 | describe("Comment sidebar", () => { |
305 | 372 | let pages; |
306 | 373 |
|
|
0 commit comments