[Editor] Add a test for copy & paste a signature editor
This patch fixes an issue when pasting: an exception was thrown when pasting. And while writing the test and comparing the paths in the svg, I found a difference which is fixed thanks to call to the right constructor (to take into account the inheritance) in inkdraw.js
This commit is contained in:
parent
6713c239e3
commit
814d2bbe6d
@ -552,7 +552,7 @@ class InkDrawOutline extends Outline {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const outlines = new InkDrawOutline();
|
const outlines = new this.prototype.constructor();
|
||||||
outlines.build(
|
outlines.build(
|
||||||
newLines,
|
newLines,
|
||||||
pageWidth,
|
pageWidth,
|
||||||
|
|||||||
@ -391,7 +391,7 @@ class SignatureEditor extends DrawingEditor {
|
|||||||
static async deserialize(data, parent, uiManager) {
|
static async deserialize(data, parent, uiManager) {
|
||||||
const editor = await super.deserialize(data, parent, uiManager);
|
const editor = await super.deserialize(data, parent, uiManager);
|
||||||
editor.#isExtracted = data.areContours;
|
editor.#isExtracted = data.areContours;
|
||||||
editor.description = data.accessibilityData?.alt || "";
|
editor.#description = data.accessibilityData?.alt || "";
|
||||||
editor.#signatureUUID = data.uuid;
|
editor.#signatureUUID = data.uuid;
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,9 +16,11 @@
|
|||||||
import {
|
import {
|
||||||
awaitPromise,
|
awaitPromise,
|
||||||
closePages,
|
closePages,
|
||||||
|
copy,
|
||||||
getEditorSelector,
|
getEditorSelector,
|
||||||
getRect,
|
getRect,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
|
paste,
|
||||||
switchToEditor,
|
switchToEditor,
|
||||||
waitForPointerUp,
|
waitForPointerUp,
|
||||||
waitForTimeout,
|
waitForTimeout,
|
||||||
@ -330,6 +332,60 @@ describe("Signature Editor", () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("must check copy and paste", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await switchToSignature(page);
|
||||||
|
await page.click("#editorSignatureAddSignature");
|
||||||
|
|
||||||
|
await page.waitForSelector("#addSignatureDialog", {
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
await page.type("#addSignatureTypeInput", "Hello");
|
||||||
|
await page.waitForSelector(`${addButtonSelector}:not(:disabled)`);
|
||||||
|
await page.click("#addSignatureAddButton");
|
||||||
|
|
||||||
|
const editorSelector = getEditorSelector(0);
|
||||||
|
await page.waitForSelector(editorSelector, { visible: true });
|
||||||
|
await page.waitForSelector(
|
||||||
|
`.canvasWrapper > svg use[href="#path_p1_0"]`,
|
||||||
|
{ visible: true }
|
||||||
|
);
|
||||||
|
const originalPath = await page.$eval("#path_p1_0", el =>
|
||||||
|
el.getAttribute("d")
|
||||||
|
);
|
||||||
|
const originalDescription = await page.$eval(
|
||||||
|
`${editorSelector} .altText.editDescription`,
|
||||||
|
el => el.title
|
||||||
|
);
|
||||||
|
|
||||||
|
await copy(page);
|
||||||
|
await paste(page);
|
||||||
|
|
||||||
|
const pastedEditorSelector = getEditorSelector(1);
|
||||||
|
await page.waitForSelector(pastedEditorSelector, { visible: true });
|
||||||
|
await page.waitForSelector(
|
||||||
|
`.canvasWrapper > svg use[href="#path_p1_1"]`,
|
||||||
|
{ visible: true }
|
||||||
|
);
|
||||||
|
const pastedPath = await page.$eval("#path_p1_1", el =>
|
||||||
|
el.getAttribute("d")
|
||||||
|
);
|
||||||
|
const pastedDescription = await page.$eval(
|
||||||
|
`${pastedEditorSelector} .altText.editDescription`,
|
||||||
|
el => el.title
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(pastedPath)
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.toEqual(originalPath);
|
||||||
|
expect(pastedDescription)
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.toEqual(originalDescription);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Bug 1948741", () => {
|
describe("Bug 1948741", () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user