mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-26 10:05:47 +02:00
Merge pull request #21043 from timvandermeij/integration-test-intermittents-find-count
Fix intermittent integration test failures related to checking the find count results text
This commit is contained in:
commit
ca85d73335
@ -13,7 +13,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { closePages, FSI, loadAndWait, PDI } from "./test_utils.mjs";
|
import {
|
||||||
|
closePages,
|
||||||
|
FSI,
|
||||||
|
loadAndWait,
|
||||||
|
PDI,
|
||||||
|
waitForTextToBe,
|
||||||
|
} from "./test_utils.mjs";
|
||||||
|
|
||||||
function fuzzyMatch(a, b, browserName, pixelFuzz = 3) {
|
function fuzzyMatch(a, b, browserName, pixelFuzz = 3) {
|
||||||
expect(a)
|
expect(a)
|
||||||
@ -105,12 +111,11 @@ describe("find bar", () => {
|
|||||||
await page.type("#findInput", "preferences");
|
await page.type("#findInput", "preferences");
|
||||||
await page.waitForSelector("#findInput[data-status='']");
|
await page.waitForSelector("#findInput[data-status='']");
|
||||||
await page.waitForSelector(".xfaLayer .highlight");
|
await page.waitForSelector(".xfaLayer .highlight");
|
||||||
await page.waitForFunction(
|
await waitForTextToBe(
|
||||||
() => !!document.querySelector("#findResultsCount")?.textContent
|
page,
|
||||||
|
"#findResultsCount",
|
||||||
|
`${FSI}1${PDI} of ${FSI}1${PDI} match`
|
||||||
);
|
);
|
||||||
const resultElement = await page.waitForSelector("#findResultsCount");
|
|
||||||
const resultText = await resultElement.evaluate(el => el.textContent);
|
|
||||||
expect(resultText).toEqual(`${FSI}1${PDI} of ${FSI}1${PDI} match`);
|
|
||||||
const selectedElement = await page.waitForSelector(
|
const selectedElement = await page.waitForSelector(
|
||||||
".highlight.selected"
|
".highlight.selected"
|
||||||
);
|
);
|
||||||
@ -208,14 +213,11 @@ describe("find bar", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify we are on the expected match number.
|
// Verify we are on the expected match number.
|
||||||
const resultElement =
|
await waitForTextToBe(
|
||||||
await page.waitForSelector("#findResultsCount");
|
page,
|
||||||
const resultText = await resultElement.evaluate(
|
"#findResultsCount",
|
||||||
el => el.textContent
|
`${FSI}${i + 1}${PDI} of ${FSI}5${PDI} matches`
|
||||||
);
|
);
|
||||||
expect(resultText)
|
|
||||||
.withContext(`In ${browserName}, match ${i + 1}`)
|
|
||||||
.toEqual(`${FSI}${i + 1}${PDI} of ${FSI}5${PDI} matches`);
|
|
||||||
|
|
||||||
// The selected highlight must be visible in the viewport.
|
// The selected highlight must be visible in the viewport.
|
||||||
const selected = await page.waitForSelector(
|
const selected = await page.waitForSelector(
|
||||||
|
|||||||
@ -460,20 +460,20 @@ describe("Reorganize Pages View", () => {
|
|||||||
|
|
||||||
// Wait for the first result to be selected and the search to settle.
|
// Wait for the first result to be selected and the search to settle.
|
||||||
await page.waitForSelector("#findInput[data-status='']");
|
await page.waitForSelector("#findInput[data-status='']");
|
||||||
let resultEl = await page.waitForSelector("#findResultsCount");
|
await waitForTextToBe(
|
||||||
const firstResult = await resultEl.evaluate(el => el.textContent);
|
page,
|
||||||
expect(firstResult)
|
"#findResultsCount",
|
||||||
.withContext(`In ${browserName}`)
|
`${FSI}1${PDI} of ${FSI}10${PDI} matches`
|
||||||
.toEqual(`${FSI}1${PDI} of ${FSI}10${PDI} matches`);
|
);
|
||||||
|
|
||||||
// Navigate to the next match.
|
// Navigate to the next match.
|
||||||
await page.keyboard.press("Enter");
|
await page.keyboard.press("Enter");
|
||||||
await page.waitForSelector("#findInput[data-status='']");
|
await page.waitForSelector("#findInput[data-status='']");
|
||||||
resultEl = await page.waitForSelector("#findResultsCount");
|
await waitForTextToBe(
|
||||||
const secondResult = await resultEl.evaluate(el => el.textContent);
|
page,
|
||||||
expect(secondResult)
|
"#findResultsCount",
|
||||||
.withContext(`In ${browserName}`)
|
`${FSI}2${PDI} of ${FSI}10${PDI} matches`
|
||||||
.toEqual(`${FSI}2${PDI} of ${FSI}10${PDI} matches`);
|
);
|
||||||
|
|
||||||
// Move a page: this previously blocked subsequent find navigation.
|
// Move a page: this previously blocked subsequent find navigation.
|
||||||
await movePages(page, [3], 0);
|
await movePages(page, [3], 0);
|
||||||
@ -484,11 +484,11 @@ describe("Reorganize Pages View", () => {
|
|||||||
// Navigate to the next match — must not be blocked.
|
// Navigate to the next match — must not be blocked.
|
||||||
await page.keyboard.press("Enter");
|
await page.keyboard.press("Enter");
|
||||||
await page.waitForSelector("#findInput[data-status='']");
|
await page.waitForSelector("#findInput[data-status='']");
|
||||||
resultEl = await page.waitForSelector("#findResultsCount");
|
await waitForTextToBe(
|
||||||
const resultAfterMove = await resultEl.evaluate(el => el.textContent);
|
page,
|
||||||
expect(resultAfterMove)
|
"#findResultsCount",
|
||||||
.withContext(`In ${browserName}`)
|
`${FSI}3${PDI} of ${FSI}10${PDI} matches`
|
||||||
.not.toEqual(secondResult);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user