mirror of
https://github.com/24eme/signaturepdf.git
synced 2023-08-25 09:33:08 +02:00
Test du tampon, d'une signature alternative et d'une zone de texte
This commit is contained in:
parent
d2314878f2
commit
e4947e6a20
@ -85,6 +85,9 @@ loadingTask.promise.then(function(pdf) {
|
||||
if(event.detail > 1) {
|
||||
return;
|
||||
}
|
||||
if(!document.getElementById(label.htmlFor)) {
|
||||
return;
|
||||
}
|
||||
if(!document.getElementById(label.htmlFor).checked) {
|
||||
return;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@
|
||||
</div>
|
||||
<div class="d-grid gap-2 mb-2 list-item-add">
|
||||
<input type="radio" class="btn-check" id="radio_svg_text" data-svg="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktdGV4dGFyZWEtdCIgdmlld0JveD0iMCAwIDE2IDE2Ij48cGF0aCBkPSJNMS41IDIuNUExLjUgMS41IDAgMCAxIDMgMWgxMGExLjUgMS41IDAgMCAxIDEuNSAxLjV2My41NjNhMiAyIDAgMCAxIDAgMy44NzRWMTMuNUExLjUgMS41IDAgMCAxIDEzIDE1SDNhMS41IDEuNSAwIDAgMS0xLjUtMS41VjkuOTM3YTIgMiAwIDAgMSAwLTMuODc0VjIuNXptMSAzLjU2M2EyIDIgMCAwIDEgMCAzLjg3NFYxMy41YS41LjUgMCAwIDAgLjUuNWgxMGEuNS41IDAgMCAwIC41LS41VjkuOTM3YTIgMiAwIDAgMSAwLTMuODc0VjIuNUEuNS41IDAgMCAwIDEzIDJIM2EuNS41IDAgMCAwLS41LjV2My41NjN6TTIgN2ExIDEgMCAxIDAgMCAyIDEgMSAwIDAgMCAwLTJ6bTEyIDBhMSAxIDAgMSAwIDAgMiAxIDEgMCAwIDAgMC0yeiIvPjxwYXRoIGQ9Ik0xMS40MzQgNEg0LjU2Nkw0LjUgNS45OTRoLjM4NmMuMjEtMS4yNTIuNjEyLTEuNDQ2IDIuMTczLTEuNDk1bC4zNDMtLjAxMXY2LjM0M2MwIC41MzctLjExNi42NjUtMS4wNDkuNzQ4VjEyaDMuMjk0di0uNDIxYy0uOTM4LS4wODMtMS4wNTQtLjIxLTEuMDU0LS43NDhWNC40ODhsLjM0OC4wMWMxLjU2LjA1IDEuOTYzLjI0NCAyLjE3MyAxLjQ5NmguMzg2TDExLjQzNCA0eiIvPjwvc3ZnPgo=" name="svg_2_add" autocomplete="off" value="text">
|
||||
<label draggable="true" class="btn btn-outline-secondary text-black text-start btn-svg" for="radio_svg_text"><i class="bi bi-textarea-t"></i> Texte</label>
|
||||
<label draggable="true" id="label_svg_text" class="btn btn-outline-secondary text-black text-start btn-svg" for="radio_svg_text"><i class="bi bi-textarea-t"></i> Texte</label>
|
||||
</div>
|
||||
<div id="svg_list" class="d-grid gap-2 mt-2 mb-2 list-item-add"></div>
|
||||
|
||||
|
BIN
tests/files/signature.png
Normal file
BIN
tests/files/signature.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 878 KiB |
BIN
tests/files/tampon.png
Normal file
BIN
tests/files/tampon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -47,7 +47,7 @@ describe("Signature d'un pdf", () => {
|
||||
await page.waitForTimeout(300);
|
||||
expect(await page.evaluate(() => { return document.querySelector("#label_svg_0 img").src })).toMatch(/^data:image\/svg\+xml;base64,.+/);
|
||||
});
|
||||
it('Ajout de la signature dans le pdf', async () => {
|
||||
it('Ajout de la signature au pdf', async () => {
|
||||
originX = await page.evaluate(() => { return document.querySelector("#canvas-container-0").offsetLeft; });
|
||||
originY = await page.evaluate(() => { return document.querySelector("#canvas-container-0").offsetTop; });
|
||||
await page.mouse.click(originX + 50, originY + 50);
|
||||
@ -123,7 +123,7 @@ describe("Signature d'un pdf", () => {
|
||||
it("Création d'une paraphe", async () => {
|
||||
await page.click("#label_svg_initials_add");
|
||||
await page.waitForSelector('#input-text-signature', {visible: true});
|
||||
await page.type("#input-text-signature", "AL");
|
||||
await page.type("#input-text-signature", "FSF");
|
||||
await page.waitForSelector('button#btn_modal_ajouter:not([disabled])');
|
||||
await page.waitForTimeout(300);
|
||||
await page.click('button#btn_modal_ajouter');
|
||||
@ -139,7 +139,58 @@ describe("Signature d'un pdf", () => {
|
||||
expect(await page.evaluate(() => { return canvasEditions[0].getObjects().length; })).toBe(2);
|
||||
expect(await page.evaluate(() => { return document.querySelector('#radio_svg_1').checked; })).toBe(false);
|
||||
});
|
||||
it("Suppression de la signature et de la paraphe de la liste", async () => {
|
||||
it("Création d'un tampon", async () => {
|
||||
await page.click("#label_svg_rubber_stamber_add");
|
||||
await page.waitForSelector('#input-image-upload', {visible: true});
|
||||
await (await page.$("input#input-image-upload")).uploadFile(require('path').resolve(__dirname + '/files/tampon.png'));
|
||||
await page.waitForSelector('button#btn_modal_ajouter:not([disabled])');
|
||||
await page.waitForTimeout(300);
|
||||
await page.click('button#btn_modal_ajouter');
|
||||
await page.waitForTimeout(300);
|
||||
expect(await page.evaluate(() => { return document.querySelector("#label_svg_2 img").src })).toMatch(/^data:image\/svg\+xml;base64,.+/);
|
||||
expect(await page.evaluate(() => { return document.querySelector('#radio_svg_2').checked; })).toBe(true);
|
||||
await page.click("#label_svg_2");
|
||||
expect(await page.evaluate(() => { return document.querySelector('#radio_svg_2').checked; })).toBe(false);
|
||||
})
|
||||
it("Ajout du tampon au pdf", async () => {
|
||||
await page.click("#label_svg_2");
|
||||
await page.mouse.click(originX + 650, originY + 375);
|
||||
expect(await page.evaluate(() => { return canvasEditions[0].getObjects().length; })).toBe(3);
|
||||
expect(await page.evaluate(() => { return document.querySelector('#radio_svg_2').checked; })).toBe(false);
|
||||
});
|
||||
it("Création d'une signature à partir d'une image", async () => {
|
||||
await page.click("#btn-add-svg");
|
||||
await page.waitForSelector('#nav-import-tab', {visible: true});
|
||||
await page.click("#nav-import-tab");
|
||||
await page.waitForSelector('#input-image-upload', {visible: true});
|
||||
await (await page.$("input#input-image-upload")).uploadFile(require('path').resolve(__dirname + '/files/signature.png'));
|
||||
await page.waitForSelector('button#btn_modal_ajouter:not([disabled])');
|
||||
await page.waitForTimeout(300);
|
||||
await page.click('button#btn_modal_ajouter');
|
||||
await page.waitForTimeout(300);
|
||||
expect(await page.evaluate(() => { return document.querySelector("#label_svg_3 img").src })).toMatch(/^data:image\/svg\+xml;base64,.+/);
|
||||
expect(await page.evaluate(() => { return document.querySelector('#radio_svg_3').checked; })).toBe(true);
|
||||
await page.click("#label_svg_2");
|
||||
expect(await page.evaluate(() => { return document.querySelector('#radio_svg_3').checked; })).toBe(false);
|
||||
});
|
||||
it("Ajout de la signature au pdf", async () => {
|
||||
await page.click("#label_svg_3");
|
||||
await page.mouse.click(originX + 400, originY + 600);
|
||||
expect(await page.evaluate(() => { return canvasEditions[0].getObjects().length; })).toBe(4);
|
||||
expect(await page.evaluate(() => { return document.querySelector('#radio_svg_3').checked; })).toBe(false);
|
||||
});
|
||||
it("Ajout de texte au pdf", async () => {
|
||||
await page.click("#label_svg_text");
|
||||
await page.mouse.click(originX + 150, originY + 100);
|
||||
await page.keyboard.type('Bon pour un logiciel libre !');
|
||||
await page.mouse.click(originX + 150, originY + 50);
|
||||
expect(await page.evaluate(() => { return canvasEditions[0].getObjects().length; })).toBe(5);
|
||||
expect(await page.evaluate(() => { return canvasEditions[0].getObjects()[4].text; })).toBe('Bon pour un logiciel libre !');
|
||||
expect(await page.evaluate(() => { return document.querySelector('#radio_svg_text').checked; })).toBe(false);
|
||||
});
|
||||
it("Suppression de tous les éléments ajoutés à la liste", async () => {
|
||||
await page.click("#label_svg_0 .btn-svg-list-suppression")
|
||||
await page.click("#label_svg_0 .btn-svg-list-suppression")
|
||||
await page.click("#label_svg_0 .btn-svg-list-suppression")
|
||||
await page.click("#label_svg_0 .btn-svg-list-suppression")
|
||||
expect(await page.evaluate(() => { return document.querySelector("#label_svg_0 img") })).toBeNull();
|
||||
|
Loading…
Reference in New Issue
Block a user