From 29441d5f94a55d9635a8c224b4345e18787dc834 Mon Sep 17 00:00:00 2001 From: xpadev Date: Wed, 6 Dec 2023 19:02:32 +0900 Subject: [PATCH 1/3] feat: make canvas resizable --- docs/sample/test.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/sample/test.html b/docs/sample/test.html index 339d0dbf..8a7ecf6c 100755 --- a/docs/sample/test.html +++ b/docs/sample/test.html @@ -15,6 +15,10 @@ const urlParams = new URLSearchParams(window.location.search); const video = Number(urlParams.get("video") || 0); const time = Number(urlParams.get("time") || 0); + const canvasWidth = Number(urlParams.get("width") || 1920); + const canvasHeight = Number(urlParams.get("height") || 1080); + canvasElement.width = canvasWidth; + canvasElement.height = canvasHeight; const req = await fetch(`./commentdata/${video}.json`); const res = await req.json(); const nico = new NiconiComments(canvasElement, res, { From 17eb5d2c173afb93c7e567d855bf153eaf2b63cc Mon Sep 17 00:00:00 2001 From: xpadev Date: Wed, 6 Dec 2023 19:07:01 +0900 Subject: [PATCH 2/3] feat: scaled tests --- src/__tests__/test.spec.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/__tests__/test.spec.ts b/src/__tests__/test.spec.ts index 1b2a1c0b..e291d5df 100755 --- a/src/__tests__/test.spec.ts +++ b/src/__tests__/test.spec.ts @@ -35,8 +35,19 @@ test("22(ヨワイボクラハウタウ)", async ({ page }) => { }); const compare = async (page: Page, video: number, time: number) => { + await _compare(page, video, time); + await _compare(page, video, time, 1280, 720); +}; + +const _compare = async ( + page: Page, + video: number, + time: number, + width = 1920, + height = 1080, +) => { await page.goto( - `http://localhost:8080/docs/sample/test.html?time=${time}&video=${video}`, + `http://localhost:8080/docs/sample/test.html?time=${time}&video=${video}&width=${width}&height=${height}`, ); await Promise.all([ page.waitForSelector("div#loaded", { state: "attached" }), From b27bfe5699721d53450244b098bdc8132ba3719f Mon Sep 17 00:00:00 2001 From: xpadev Date: Wed, 6 Dec 2023 19:14:50 +0900 Subject: [PATCH 3/3] fix: change threshold --- src/__tests__/test.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__tests__/test.spec.ts b/src/__tests__/test.spec.ts index e291d5df..4bf1c5fc 100755 --- a/src/__tests__/test.spec.ts +++ b/src/__tests__/test.spec.ts @@ -56,6 +56,6 @@ const _compare = async ( await expect(page).toHaveScreenshot(`${video}-${time}.png`); expect(await page.screenshot({ fullPage: true })).toMatchSnapshot( `${video}-${time}.png`, - { threshold: 0.075 }, + { threshold: 0.1 }, ); };