Merge pull request #13023 from calixteman/fix_color_test

Fix integration test with js-colors
This commit is contained in:
Tim van der Meij 2021-02-26 23:22:23 +01:00 committed by GitHub
commit 052db45e7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -638,7 +638,7 @@ describe("Interaction", () => {
pages = await loadAndWait("js-colors.pdf", "#\\33 4R"); pages = await loadAndWait("js-colors.pdf", "#\\33 4R");
}); });
it("must changes colors", async () => { it("must change colors", async () => {
await Promise.all( await Promise.all(
pages.map(async ([browserName, page]) => { pages.map(async ([browserName, page]) => {
for (const [name, ref] of [ for (const [name, ref] of [
@ -651,29 +651,36 @@ describe("Interaction", () => {
await page.type("#\\33 4R", `${name}`, { await page.type("#\\33 4R", `${name}`, {
delay: 10, delay: 10,
}); });
await page.click("[data-annotation-id='41R']");
let color = await page.$eval(
ref,
el => getComputedStyle(el).backgroundColor
);
expect(color)
.withContext(`In ${browserName}`)
.toEqual("rgb(255, 0, 0)");
await page.click("[data-annotation-id='43R']"); for (const [id, propName, expected] of [
color = await page.$eval(ref, el => getComputedStyle(el).color); [41, "backgroundColor", "rgb(255, 0, 0)"],
expect(color) [43, "color", "rgb(0, 255, 0)"],
.withContext(`In ${browserName}`) [44, "border-top-color", "rgb(0, 0, 255)"],
.toEqual("rgb(0, 255, 0)"); ]) {
const current = await page.$eval(
await page.click("[data-annotation-id='44R']");
color = await page.$eval(
ref, ref,
el => getComputedStyle(el)["border-top-color"] (el, _propName) => getComputedStyle(el)[_propName],
propName
); );
expect(color)
.withContext(`In ${browserName}`) await page.click(`[data-annotation-id='${id}R']`);
.toEqual("rgb(0, 0, 255)"); await page.waitForFunction(
(_ref, _current, _propName) =>
getComputedStyle(document.querySelector(_ref))[_propName] !==
_current,
{},
ref,
current,
propName
);
const color = await page.$eval(
ref,
(el, _propName) => getComputedStyle(el)[_propName],
propName
);
expect(color).withContext(`In ${browserName}`).toEqual(expected);
}
} }
}) })
); );