Merge pull request #15623 from calixteman/editor_int_test
Fix editor tests on Windows
This commit is contained in:
commit
9a33a0fba9
@ -18,8 +18,25 @@ const {
|
|||||||
getEditorSelector,
|
getEditorSelector,
|
||||||
getSelectedEditors,
|
getSelectedEditors,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
|
waitForEvent,
|
||||||
} = require("./test_utils.js");
|
} = require("./test_utils.js");
|
||||||
|
|
||||||
|
const copyPaste = async page => {
|
||||||
|
let promise = waitForEvent(page, "copy");
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await page.keyboard.press("c");
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
await promise;
|
||||||
|
|
||||||
|
await page.waitForTimeout(10);
|
||||||
|
|
||||||
|
promise = waitForEvent(page, "paste");
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await page.keyboard.press("v");
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
await promise;
|
||||||
|
};
|
||||||
|
|
||||||
describe("Editor", () => {
|
describe("Editor", () => {
|
||||||
describe("FreeText", () => {
|
describe("FreeText", () => {
|
||||||
let pages;
|
let pages;
|
||||||
@ -32,10 +49,22 @@ describe("Editor", () => {
|
|||||||
await closePages(pages);
|
await closePages(pages);
|
||||||
});
|
});
|
||||||
|
|
||||||
const countStorageEntries = async page =>
|
const waitForStorageEntries = async (page, nEntries) => {
|
||||||
page.evaluate(
|
await page.waitForFunction(
|
||||||
() => window.PDFViewerApplication.pdfDocument.annotationStorage.size
|
n =>
|
||||||
|
window.PDFViewerApplication.pdfDocument.annotationStorage.size === n,
|
||||||
|
{},
|
||||||
|
nEntries
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const waitForSelected = async (page, selector) => {
|
||||||
|
await page.waitForFunction(
|
||||||
|
sel => document.querySelector(sel).classList.contains("selectedEditor"),
|
||||||
|
{},
|
||||||
|
selector
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
it("must write a string in a FreeText editor", async () => {
|
it("must write a string in a FreeText editor", async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
@ -69,9 +98,8 @@ describe("Editor", () => {
|
|||||||
editorRect.y + 2 * editorRect.height
|
editorRect.y + 2 * editorRect.height
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(await countStorageEntries(page))
|
await waitForSelected(page, getEditorSelector(0));
|
||||||
.withContext(`In ${browserName}`)
|
await waitForStorageEntries(page, 1);
|
||||||
.toEqual(1);
|
|
||||||
|
|
||||||
const content = await page.$eval(getEditorSelector(0), el =>
|
const content = await page.$eval(getEditorSelector(0), el =>
|
||||||
el.innerText.trimEnd()
|
el.innerText.trimEnd()
|
||||||
@ -82,63 +110,41 @@ describe("Editor", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("must copy/paste", async () => {
|
it("must copy/paste", async () => {
|
||||||
await Promise.all(
|
// Run sequentially to avoid clipboard issues.
|
||||||
pages.map(async ([browserName, page]) => {
|
for (const [browserName, page] of pages) {
|
||||||
const editorRect = await page.$eval(getEditorSelector(0), el => {
|
const editorRect = await page.$eval(getEditorSelector(0), el => {
|
||||||
const { x, y, width, height } = el.getBoundingClientRect();
|
const { x, y, width, height } = el.getBoundingClientRect();
|
||||||
return { x, y, width, height };
|
return { x, y, width, height };
|
||||||
});
|
});
|
||||||
|
|
||||||
// Select the editor created previously.
|
// Select the editor created previously.
|
||||||
await page.mouse.click(
|
await page.mouse.click(
|
||||||
editorRect.x + editorRect.width / 2,
|
editorRect.x + editorRect.width / 2,
|
||||||
editorRect.y + editorRect.height / 2
|
editorRect.y + editorRect.height / 2
|
||||||
);
|
);
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await waitForSelected(page, getEditorSelector(0));
|
||||||
await page.keyboard.press("c");
|
await copyPaste(page);
|
||||||
await page.keyboard.up("Control");
|
await waitForStorageEntries(page, 2);
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
const content = await page.$eval(getEditorSelector(0), el =>
|
||||||
await page.keyboard.press("v");
|
el.innerText.trimEnd()
|
||||||
await page.keyboard.up("Control");
|
);
|
||||||
|
|
||||||
expect(await countStorageEntries(page))
|
let pastedContent = await page.$eval(getEditorSelector(1), el =>
|
||||||
.withContext(`In ${browserName}`)
|
el.innerText.trimEnd()
|
||||||
.toEqual(2);
|
);
|
||||||
|
|
||||||
const content = await page.$eval(getEditorSelector(0), el =>
|
expect(pastedContent).withContext(`In ${browserName}`).toEqual(content);
|
||||||
el.innerText.trimEnd()
|
|
||||||
);
|
|
||||||
|
|
||||||
let pastedContent = await page.$eval(getEditorSelector(1), el =>
|
await copyPaste(page);
|
||||||
el.innerText.trimEnd()
|
await waitForStorageEntries(page, 3);
|
||||||
);
|
|
||||||
|
|
||||||
expect(pastedContent)
|
pastedContent = await page.$eval(getEditorSelector(2), el =>
|
||||||
.withContext(`In ${browserName}`)
|
el.innerText.trimEnd()
|
||||||
.toEqual(content);
|
);
|
||||||
|
expect(pastedContent).withContext(`In ${browserName}`).toEqual(content);
|
||||||
await page.keyboard.down("Control");
|
}
|
||||||
await page.keyboard.press("c");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
|
||||||
await page.keyboard.press("v");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
|
|
||||||
expect(await countStorageEntries(page))
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toEqual(3);
|
|
||||||
|
|
||||||
pastedContent = await page.$eval(getEditorSelector(2), el =>
|
|
||||||
el.innerText.trimEnd()
|
|
||||||
);
|
|
||||||
expect(pastedContent)
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toEqual(content);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("must clear all", async () => {
|
it("must clear all", async () => {
|
||||||
@ -160,88 +166,85 @@ describe("Editor", () => {
|
|||||||
expect(hasEditor).withContext(`In ${browserName}`).toEqual(false);
|
expect(hasEditor).withContext(`In ${browserName}`).toEqual(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(await countStorageEntries(page))
|
await waitForStorageEntries(page, 0);
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toEqual(0);
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("must check that a paste has been undone", async () => {
|
it("must check that a paste has been undone", async () => {
|
||||||
await Promise.all(
|
// Run sequentially to avoid clipboard issues.
|
||||||
pages.map(async ([browserName, page]) => {
|
for (const [browserName, page] of pages) {
|
||||||
const rect = await page.$eval(".annotationEditorLayer", el => {
|
const rect = await page.$eval(".annotationEditorLayer", el => {
|
||||||
const { x, y } = el.getBoundingClientRect();
|
const { x, y } = el.getBoundingClientRect();
|
||||||
return { x, y };
|
return { x, y };
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = "Hello PDF.js World !!";
|
const data = "Hello PDF.js World !!";
|
||||||
await page.mouse.click(rect.x + 100, rect.y + 100);
|
await page.mouse.click(rect.x + 100, rect.y + 100);
|
||||||
await page.type(`${getEditorSelector(3)} .internal`, data);
|
await page.type(`${getEditorSelector(3)} .internal`, data);
|
||||||
|
|
||||||
const editorRect = await page.$eval(getEditorSelector(3), el => {
|
const editorRect = await page.$eval(getEditorSelector(3), el => {
|
||||||
const { x, y, width, height } = el.getBoundingClientRect();
|
const { x, y, width, height } = el.getBoundingClientRect();
|
||||||
return { x, y, width, height };
|
return { x, y, width, height };
|
||||||
});
|
});
|
||||||
|
|
||||||
// Commit.
|
// Commit.
|
||||||
await page.mouse.click(
|
await page.mouse.click(
|
||||||
editorRect.x,
|
editorRect.x,
|
||||||
editorRect.y + 2 * editorRect.height
|
editorRect.y + 2 * editorRect.height
|
||||||
);
|
);
|
||||||
// And select it again.
|
// And select it again.
|
||||||
await page.mouse.click(
|
await page.mouse.click(
|
||||||
editorRect.x + editorRect.width / 2,
|
editorRect.x + editorRect.width / 2,
|
||||||
editorRect.y + editorRect.height / 2
|
editorRect.y + editorRect.height / 2
|
||||||
);
|
);
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await waitForSelected(page, getEditorSelector(3));
|
||||||
await page.keyboard.press("c");
|
await copyPaste(page);
|
||||||
await page.keyboard.up("Control");
|
|
||||||
|
|
||||||
|
let hasEditor = await page.evaluate(sel => {
|
||||||
|
return !!document.querySelector(sel);
|
||||||
|
}, getEditorSelector(4));
|
||||||
|
|
||||||
|
expect(hasEditor).withContext(`In ${browserName}`).toEqual(true);
|
||||||
|
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await page.keyboard.press("z");
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
await page.waitForTimeout(10);
|
||||||
|
|
||||||
|
hasEditor = await page.evaluate(sel => {
|
||||||
|
return !!document.querySelector(sel);
|
||||||
|
}, getEditorSelector(4));
|
||||||
|
|
||||||
|
expect(hasEditor).withContext(`In ${browserName}`).toEqual(false);
|
||||||
|
|
||||||
|
for (let i = 0; i < 2; i++) {
|
||||||
|
const promise = waitForEvent(page, "paste");
|
||||||
await page.keyboard.down("Control");
|
await page.keyboard.down("Control");
|
||||||
await page.keyboard.press("v");
|
await page.keyboard.press("v");
|
||||||
await page.keyboard.up("Control");
|
await page.keyboard.up("Control");
|
||||||
|
await promise;
|
||||||
|
await page.waitForTimeout(10);
|
||||||
|
}
|
||||||
|
|
||||||
let hasEditor = await page.evaluate(sel => {
|
let length = await page.evaluate(sel => {
|
||||||
return !!document.querySelector(sel);
|
return document.querySelectorAll(sel).length;
|
||||||
}, getEditorSelector(4));
|
}, `${getEditorSelector(5)}, ${getEditorSelector(6)}`);
|
||||||
|
expect(length).withContext(`In ${browserName}`).toEqual(2);
|
||||||
expect(hasEditor).withContext(`In ${browserName}`).toEqual(true);
|
|
||||||
|
|
||||||
|
for (let i = 0; i < 2; i++) {
|
||||||
await page.keyboard.down("Control");
|
await page.keyboard.down("Control");
|
||||||
await page.keyboard.press("z");
|
await page.keyboard.press("z");
|
||||||
await page.keyboard.up("Control");
|
await page.keyboard.up("Control");
|
||||||
|
await page.waitForTimeout(10);
|
||||||
|
}
|
||||||
|
|
||||||
hasEditor = await page.evaluate(sel => {
|
length = await page.evaluate(sel => {
|
||||||
return !!document.querySelector(sel);
|
return document.querySelectorAll(sel).length;
|
||||||
}, getEditorSelector(4));
|
}, `${getEditorSelector(5)}, ${getEditorSelector(6)}`);
|
||||||
|
expect(length).withContext(`In ${browserName}`).toEqual(0);
|
||||||
expect(hasEditor).withContext(`In ${browserName}`).toEqual(false);
|
}
|
||||||
|
|
||||||
for (let i = 0; i < 2; i++) {
|
|
||||||
await page.keyboard.down("Control");
|
|
||||||
await page.keyboard.press("v");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
}
|
|
||||||
|
|
||||||
let length = await page.evaluate(sel => {
|
|
||||||
return document.querySelectorAll(sel).length;
|
|
||||||
}, `${getEditorSelector(5)}, ${getEditorSelector(6)}`);
|
|
||||||
expect(length).withContext(`In ${browserName}`).toEqual(2);
|
|
||||||
|
|
||||||
for (let i = 0; i < 2; i++) {
|
|
||||||
await page.keyboard.down("Control");
|
|
||||||
await page.keyboard.press("z");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
}
|
|
||||||
|
|
||||||
length = await page.evaluate(sel => {
|
|
||||||
return document.querySelectorAll(sel).length;
|
|
||||||
}, `${getEditorSelector(5)}, ${getEditorSelector(6)}`);
|
|
||||||
expect(length).withContext(`In ${browserName}`).toEqual(0);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("must check that aria-owns is correct", async () => {
|
it("must check that aria-owns is correct", async () => {
|
||||||
@ -332,6 +335,8 @@ describe("Editor", () => {
|
|||||||
editorRect.y + editorRect.height / 2
|
editorRect.y + editorRect.height / 2
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await waitForSelected(page, getEditorSelector(8));
|
||||||
|
|
||||||
expect(await getSelectedEditors(page))
|
expect(await getSelectedEditors(page))
|
||||||
.withContext(`In ${browserName}`)
|
.withContext(`In ${browserName}`)
|
||||||
.toEqual([8]);
|
.toEqual([8]);
|
||||||
@ -367,151 +372,144 @@ describe("Editor", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("must select/unselect several editors and check copy, paste and delete operations", async () => {
|
it("must select/unselect several editors and check copy, paste and delete operations", async () => {
|
||||||
await Promise.all(
|
// Run sequentially to avoid clipboard issues.
|
||||||
pages.map(async ([browserName, page]) => {
|
for (const [browserName, page] of pages) {
|
||||||
await page.click("#editorFreeText");
|
await page.click("#editorFreeText");
|
||||||
|
|
||||||
const rect = await page.$eval(".annotationEditorLayer", el => {
|
const rect = await page.$eval(".annotationEditorLayer", el => {
|
||||||
// With Chrome something is wrong when serializing a DomRect,
|
// With Chrome something is wrong when serializing a DomRect,
|
||||||
// hence we extract the values and just return them.
|
// hence we extract the values and just return them.
|
||||||
const { x, y } = el.getBoundingClientRect();
|
const { x, y } = el.getBoundingClientRect();
|
||||||
return { x, y };
|
return { x, y };
|
||||||
|
});
|
||||||
|
|
||||||
|
const editorCenters = [];
|
||||||
|
for (let i = 0; i < 4; i++) {
|
||||||
|
const data = `FreeText ${i}`;
|
||||||
|
await page.mouse.click(
|
||||||
|
rect.x + (i + 1) * 100,
|
||||||
|
rect.y + (i + 1) * 100
|
||||||
|
);
|
||||||
|
await page.type(`${getEditorSelector(i)} .internal`, data);
|
||||||
|
|
||||||
|
const editorRect = await page.$eval(getEditorSelector(i), el => {
|
||||||
|
const { x, y, width, height } = el.getBoundingClientRect();
|
||||||
|
return {
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
editorCenters.push({
|
||||||
|
x: editorRect.x + editorRect.width / 2,
|
||||||
|
y: editorRect.y + editorRect.height / 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
const editorCenters = [];
|
// Commit.
|
||||||
for (let i = 0; i < 4; i++) {
|
await page.mouse.click(
|
||||||
const data = `FreeText ${i}`;
|
editorRect.x,
|
||||||
await page.mouse.click(
|
editorRect.y + 2 * editorRect.height
|
||||||
rect.x + (i + 1) * 100,
|
);
|
||||||
rect.y + (i + 1) * 100
|
}
|
||||||
);
|
|
||||||
await page.type(`${getEditorSelector(i)} .internal`, data);
|
|
||||||
|
|
||||||
const editorRect = await page.$eval(getEditorSelector(i), el => {
|
await page.keyboard.down("Control");
|
||||||
const { x, y, width, height } = el.getBoundingClientRect();
|
await page.keyboard.press("a");
|
||||||
return {
|
await page.keyboard.up("Control");
|
||||||
x,
|
|
||||||
y,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
editorCenters.push({
|
|
||||||
x: editorRect.x + editorRect.width / 2,
|
|
||||||
y: editorRect.y + editorRect.height / 2,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Commit.
|
expect(await getSelectedEditors(page))
|
||||||
await page.mouse.click(
|
.withContext(`In ${browserName}`)
|
||||||
editorRect.x,
|
.toEqual([0, 1, 2, 3]);
|
||||||
editorRect.y + 2 * editorRect.height
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await page.keyboard.down("Control");
|
||||||
await page.keyboard.press("a");
|
await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
|
||||||
await page.keyboard.up("Control");
|
|
||||||
|
|
||||||
expect(await getSelectedEditors(page))
|
expect(await getSelectedEditors(page))
|
||||||
.withContext(`In ${browserName}`)
|
.withContext(`In ${browserName}`)
|
||||||
.toEqual([0, 1, 2, 3]);
|
.toEqual([0, 2, 3]);
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await page.mouse.click(editorCenters[2].x, editorCenters[2].y);
|
||||||
await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
|
|
||||||
|
|
||||||
expect(await getSelectedEditors(page))
|
expect(await getSelectedEditors(page))
|
||||||
.withContext(`In ${browserName}`)
|
.withContext(`In ${browserName}`)
|
||||||
.toEqual([0, 2, 3]);
|
.toEqual([0, 3]);
|
||||||
|
|
||||||
await page.mouse.click(editorCenters[2].x, editorCenters[2].y);
|
await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
|
||||||
expect(await getSelectedEditors(page))
|
expect(await getSelectedEditors(page))
|
||||||
.withContext(`In ${browserName}`)
|
.withContext(`In ${browserName}`)
|
||||||
.toEqual([0, 3]);
|
.toEqual([0, 1, 3]);
|
||||||
|
|
||||||
await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
|
await copyPaste(page);
|
||||||
await page.keyboard.up("Control");
|
|
||||||
|
|
||||||
expect(await getSelectedEditors(page))
|
// 0,1,3 are unselected and new pasted editors are selected.
|
||||||
.withContext(`In ${browserName}`)
|
expect(await getSelectedEditors(page))
|
||||||
.toEqual([0, 1, 3]);
|
.withContext(`In ${browserName}`)
|
||||||
|
.toEqual([4, 5, 6]);
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
// No ctrl here, hence all are unselected and 2 is selected.
|
||||||
await page.keyboard.press("c");
|
await page.mouse.click(editorCenters[2].x, editorCenters[2].y);
|
||||||
await page.keyboard.up("Control");
|
expect(await getSelectedEditors(page))
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.toEqual([2]);
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
|
||||||
await page.keyboard.press("v");
|
expect(await getSelectedEditors(page))
|
||||||
await page.keyboard.up("Control");
|
.withContext(`In ${browserName}`)
|
||||||
|
.toEqual([1]);
|
||||||
|
|
||||||
// 0,1,3 are unselected and new pasted editors are selected.
|
await page.keyboard.down("Control");
|
||||||
expect(await getSelectedEditors(page))
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toEqual([4, 5, 6]);
|
|
||||||
|
|
||||||
// No ctrl here, hence all are unselected and 2 is selected.
|
await page.mouse.click(editorCenters[3].x, editorCenters[3].y);
|
||||||
await page.mouse.click(editorCenters[2].x, editorCenters[2].y);
|
expect(await getSelectedEditors(page))
|
||||||
expect(await getSelectedEditors(page))
|
.withContext(`In ${browserName}`)
|
||||||
.withContext(`In ${browserName}`)
|
.toEqual([1, 3]);
|
||||||
.toEqual([2]);
|
|
||||||
|
|
||||||
await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
|
await page.keyboard.up("Control");
|
||||||
expect(await getSelectedEditors(page))
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toEqual([1]);
|
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
// Delete 1 and 3.
|
||||||
|
await page.keyboard.press("Backspace");
|
||||||
|
|
||||||
await page.mouse.click(editorCenters[3].x, editorCenters[3].y);
|
await page.keyboard.down("Control");
|
||||||
expect(await getSelectedEditors(page))
|
await page.keyboard.press("a");
|
||||||
.withContext(`In ${browserName}`)
|
await page.keyboard.up("Control");
|
||||||
.toEqual([1, 3]);
|
|
||||||
|
|
||||||
await page.keyboard.up("Control");
|
expect(await getSelectedEditors(page))
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.toEqual([0, 2, 4, 5, 6]);
|
||||||
|
|
||||||
// Delete 1 and 3.
|
// Create an empty editor.
|
||||||
await page.keyboard.press("Backspace");
|
await page.mouse.click(rect.x + 700, rect.y + 100);
|
||||||
|
expect(await getSelectedEditors(page))
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.toEqual([7]);
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
// Set the focus to 2 and check that only 2 is selected.
|
||||||
await page.keyboard.press("a");
|
await page.mouse.click(editorCenters[2].x, editorCenters[2].y);
|
||||||
await page.keyboard.up("Control");
|
expect(await getSelectedEditors(page))
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.toEqual([2]);
|
||||||
|
|
||||||
expect(await getSelectedEditors(page))
|
// Create an empty editor.
|
||||||
.withContext(`In ${browserName}`)
|
await page.mouse.click(rect.x + 700, rect.y + 100);
|
||||||
.toEqual([0, 2, 4, 5, 6]);
|
expect(await getSelectedEditors(page))
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.toEqual([8]);
|
||||||
|
// Dismiss it.
|
||||||
|
await page.keyboard.press("Escape");
|
||||||
|
|
||||||
// Create an empty editor.
|
// Select all.
|
||||||
await page.mouse.click(rect.x + 700, rect.y + 100);
|
await page.keyboard.down("Control");
|
||||||
expect(await getSelectedEditors(page))
|
await page.keyboard.press("a");
|
||||||
.withContext(`In ${browserName}`)
|
await page.keyboard.up("Control");
|
||||||
.toEqual([7]);
|
|
||||||
|
|
||||||
// Set the focus to 2 and check that only 2 is selected.
|
// Check that all the editors are correctly selected (and the focus
|
||||||
await page.mouse.click(editorCenters[2].x, editorCenters[2].y);
|
// didn't move to the body when the empty editor was removed).
|
||||||
expect(await getSelectedEditors(page))
|
expect(await getSelectedEditors(page))
|
||||||
.withContext(`In ${browserName}`)
|
.withContext(`In ${browserName}`)
|
||||||
.toEqual([2]);
|
.toEqual([0, 2, 4, 5, 6]);
|
||||||
|
}
|
||||||
// Create an empty editor.
|
|
||||||
await page.mouse.click(rect.x + 700, rect.y + 100);
|
|
||||||
expect(await getSelectedEditors(page))
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toEqual([8]);
|
|
||||||
// Dismiss it.
|
|
||||||
await page.keyboard.press("Escape");
|
|
||||||
|
|
||||||
// Select all.
|
|
||||||
await page.keyboard.down("Control");
|
|
||||||
await page.keyboard.press("a");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
|
|
||||||
// Check that all the editors are correctly selected (and the focus
|
|
||||||
// didn't move to the body when the empty editor was removed).
|
|
||||||
expect(await getSelectedEditors(page))
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toEqual([0, 2, 4, 5, 6]);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -24,6 +24,9 @@ const {
|
|||||||
|
|
||||||
describe("Interaction", () => {
|
describe("Interaction", () => {
|
||||||
async function actAndWaitForInput(page, selector, action, clear = true) {
|
async function actAndWaitForInput(page, selector, action, clear = true) {
|
||||||
|
await page.waitForSelector(selector, {
|
||||||
|
timeout: 0,
|
||||||
|
});
|
||||||
if (clear) {
|
if (clear) {
|
||||||
await clearInput(page, selector);
|
await clearInput(page, selector);
|
||||||
}
|
}
|
||||||
@ -1430,13 +1433,18 @@ describe("Interaction", () => {
|
|||||||
[45, 180],
|
[45, 180],
|
||||||
[46, 270],
|
[46, 270],
|
||||||
]) {
|
]) {
|
||||||
const rotation = await page.$eval(
|
await page.waitForFunction(
|
||||||
|
(sel, b, a) => {
|
||||||
|
const el = document.querySelector(sel);
|
||||||
|
const rotation =
|
||||||
|
parseInt(el.getAttribute("data-main-rotation")) || 0;
|
||||||
|
return rotation === (360 + ((360 - (b + a)) % 360)) % 360;
|
||||||
|
},
|
||||||
|
{},
|
||||||
`[data-annotation-id='${ref}R']`,
|
`[data-annotation-id='${ref}R']`,
|
||||||
el => parseInt(el.getAttribute("data-main-rotation") || 0)
|
base,
|
||||||
|
angle
|
||||||
);
|
);
|
||||||
expect(rotation)
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toEqual((360 + ((360 - (base + angle)) % 360)) % 360);
|
|
||||||
}
|
}
|
||||||
base += 90;
|
base += 90;
|
||||||
await page.click(getSelector("48R"));
|
await page.click(getSelector("48R"));
|
||||||
|
@ -87,3 +87,16 @@ function getSelectedEditors(page) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getSelectedEditors = getSelectedEditors;
|
exports.getSelectedEditors = getSelectedEditors;
|
||||||
|
|
||||||
|
async function waitForEvent(page, eventName, timeout = 30000) {
|
||||||
|
await Promise.race([
|
||||||
|
// add event listener and wait for event to fire before returning
|
||||||
|
page.evaluate(name => {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
document.addEventListener(name, resolve, { once: true });
|
||||||
|
});
|
||||||
|
}, eventName),
|
||||||
|
page.waitForTimeout(timeout),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
exports.waitForEvent = waitForEvent;
|
||||||
|
Loading…
Reference in New Issue
Block a user