From 3899d18920cc484e3d10b8b521c55f5c7ba4efb7 Mon Sep 17 00:00:00 2001 From: wewewe-ok Date: Sat, 10 Feb 2024 19:51:16 +0900 Subject: [PATCH 01/10] =?UTF-8?q?add:=20=E3=82=BD=E3=83=B3=E3=82=B0?= =?UTF-8?q?=E9=96=A2=E9=80=A3=E3=81=AEe2e=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/e2e/browser/song/sing.test.ts | 68 +++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tests/e2e/browser/song/sing.test.ts diff --git a/tests/e2e/browser/song/sing.test.ts b/tests/e2e/browser/song/sing.test.ts new file mode 100644 index 0000000000..7b5d7c98e8 --- /dev/null +++ b/tests/e2e/browser/song/sing.test.ts @@ -0,0 +1,68 @@ +import { test, expect } from "@playwright/test"; + +import { gotoHome, navigateToMain } from "../../navigators"; + +test.beforeEach(gotoHome); + +test("再生ボタンを押して再生できる", async ({ page }) => { + // TODO: ページ内のオーディオを検出するテストを追加する + await navigateToMain(page); + await expect(page.getByText("ソング")).toBeVisible(); + await page.getByText("ソング").click(); + + // 再生ボタンを押して再生 + const getCurrentPlayhead = async () => + await page.locator(".sequencer-playhead").boundingBox(); + + await page.locator(".sequencer-body").click({ position: { x: 107, y: 171 } }); + const beforePosition = await getCurrentPlayhead(); // 再生ヘッドの初期位置 + await page.getByText("play_arrow").click(); // 再生ボタンを押す + await page.waitForTimeout(3000); + await page.getByText("stop").click(); // 停止ボタンを押す + const afterPosition = await getCurrentPlayhead(); // 再生ヘッドの再生後の位置 + await expect(afterPosition?.x).not.toEqual(beforePosition?.x); + await expect(afterPosition?.y).toEqual(beforePosition?.y); +}); + +test("ノートを追加・削除できる", async ({ page }) => { + await navigateToMain(page); + await expect(page.getByText("ソング")).toBeVisible(); + await page.getByText("ソング").click(); + + const getCurrentNoteCount = async () => await page.locator(".note").count(); + + // ノートの追加 + await expect(await getCurrentNoteCount()).toBe(0); + await page.locator(".sequencer-body").click({ position: { x: 107, y: 171 } }); + await expect(await getCurrentNoteCount()).toBe(1); + await page.locator(".sequencer-body").click({ position: { x: 200, y: 171 } }); + await expect(await getCurrentNoteCount()).toBe(2); + + // ノートの削除 + await expect(await getCurrentNoteCount()).toBe(2); + await page.locator(".sequencer-body").click({ position: { x: 107, y: 171 } }); + await page.keyboard.press("Delete"); + await expect(await getCurrentNoteCount()).toBe(1); + await page.locator(".sequencer-body").click({ position: { x: 200, y: 171 } }); + await page.keyboard.press("Delete"); + await expect(await getCurrentNoteCount()).toBe(0); +}); + +test("ダブルクリックでノートを編集できる", async ({ page }) => { + await navigateToMain(page); + await expect(page.getByText("ソング")).toBeVisible(); + await page.getByText("ソング").click(); + + const getCurrentNoteLyric = async () => + await page.locator(".note-lyric").textContent(); + + await page.locator(".sequencer-body").click({ position: { x: 107, y: 171 } }); + const beforeLyric = await getCurrentNoteLyric(); + await page + .locator(".sequencer-body") + .click({ position: { x: 107, y: 171 }, clickCount: 2 }); + await page.keyboard.press("Enter"); + const afterLyric = await getCurrentNoteLyric(); + console.log(beforeLyric, afterLyric); + await expect(afterLyric).not.toEqual(beforeLyric); +}); From 57e633a05782f72685a4dfe0d38f559aafc04ed1 Mon Sep 17 00:00:00 2001 From: wewewe-ok Date: Sat, 17 Feb 2024 10:20:23 +0900 Subject: [PATCH 02/10] =?UTF-8?q?remove:=20consoleLog=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/e2e/browser/song/sing.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/browser/song/sing.test.ts b/tests/e2e/browser/song/sing.test.ts index 7b5d7c98e8..58aefb848f 100644 --- a/tests/e2e/browser/song/sing.test.ts +++ b/tests/e2e/browser/song/sing.test.ts @@ -63,6 +63,5 @@ test("ダブルクリックでノートを編集できる", async ({ page }) => .click({ position: { x: 107, y: 171 }, clickCount: 2 }); await page.keyboard.press("Enter"); const afterLyric = await getCurrentNoteLyric(); - console.log(beforeLyric, afterLyric); await expect(afterLyric).not.toEqual(beforeLyric); }); From 2a1964f0fc87794c5adb091e55b56c931a465a94 Mon Sep 17 00:00:00 2001 From: wewewe-ok Date: Sat, 17 Feb 2024 10:25:49 +0900 Subject: [PATCH 03/10] =?UTF-8?q?refactor:=20=E3=82=BD=E3=83=B3=E3=82=B0?= =?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AB=E9=81=B7=E7=A7=BB=E3=81=99?= =?UTF-8?q?=E3=82=8B=E5=87=A6=E7=90=86=E3=82=92=E9=96=A2=E6=95=B0=E3=81=A7?= =?UTF-8?q?=E5=88=87=E3=82=8A=E5=87=BA=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/e2e/browser/song/sing.test.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/e2e/browser/song/sing.test.ts b/tests/e2e/browser/song/sing.test.ts index 58aefb848f..f805c26be0 100644 --- a/tests/e2e/browser/song/sing.test.ts +++ b/tests/e2e/browser/song/sing.test.ts @@ -1,14 +1,20 @@ -import { test, expect } from "@playwright/test"; +import { test, expect, Page } from "@playwright/test"; import { gotoHome, navigateToMain } from "../../navigators"; test.beforeEach(gotoHome); +function navigateToSong(page: Page) { + return async () => { + await navigateToMain(page); + await expect(page.getByText("ソング")).toBeVisible(); + await page.getByText("ソング").click(); + }; +} + test("再生ボタンを押して再生できる", async ({ page }) => { + await navigateToSong(page); // TODO: ページ内のオーディオを検出するテストを追加する - await navigateToMain(page); - await expect(page.getByText("ソング")).toBeVisible(); - await page.getByText("ソング").click(); // 再生ボタンを押して再生 const getCurrentPlayhead = async () => @@ -25,9 +31,7 @@ test("再生ボタンを押して再生できる", async ({ page }) => { }); test("ノートを追加・削除できる", async ({ page }) => { - await navigateToMain(page); - await expect(page.getByText("ソング")).toBeVisible(); - await page.getByText("ソング").click(); + await navigateToSong(page); const getCurrentNoteCount = async () => await page.locator(".note").count(); @@ -49,9 +53,7 @@ test("ノートを追加・削除できる", async ({ page }) => { }); test("ダブルクリックでノートを編集できる", async ({ page }) => { - await navigateToMain(page); - await expect(page.getByText("ソング")).toBeVisible(); - await page.getByText("ソング").click(); + await navigateToSong(page); const getCurrentNoteLyric = async () => await page.locator(".note-lyric").textContent(); From a46484ae95e863fdc97e54999cf7b8d2e62c2ab0 Mon Sep 17 00:00:00 2001 From: wewewe-ok Date: Sat, 17 Feb 2024 10:28:13 +0900 Subject: [PATCH 04/10] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/e2e/browser/song/sing.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/e2e/browser/song/sing.test.ts b/tests/e2e/browser/song/sing.test.ts index f805c26be0..49a3914fcf 100644 --- a/tests/e2e/browser/song/sing.test.ts +++ b/tests/e2e/browser/song/sing.test.ts @@ -16,10 +16,10 @@ test("再生ボタンを押して再生できる", async ({ page }) => { await navigateToSong(page); // TODO: ページ内のオーディオを検出するテストを追加する - // 再生ボタンを押して再生 const getCurrentPlayhead = async () => await page.locator(".sequencer-playhead").boundingBox(); + // 再生ボタンを押して再生 await page.locator(".sequencer-body").click({ position: { x: 107, y: 171 } }); const beforePosition = await getCurrentPlayhead(); // 再生ヘッドの初期位置 await page.getByText("play_arrow").click(); // 再生ボタンを押す @@ -60,9 +60,11 @@ test("ダブルクリックでノートを編集できる", async ({ page }) => await page.locator(".sequencer-body").click({ position: { x: 107, y: 171 } }); const beforeLyric = await getCurrentNoteLyric(); + await page .locator(".sequencer-body") - .click({ position: { x: 107, y: 171 }, clickCount: 2 }); + .click({ position: { x: 107, y: 171 }, clickCount: 2 }); // ダブルクリック + await page.keyboard.press("Enter"); const afterLyric = await getCurrentNoteLyric(); await expect(afterLyric).not.toEqual(beforeLyric); From 1c2672df2657051dfc1ae344dd4fe80aac55d356 Mon Sep 17 00:00:00 2001 From: wewewe-ok Date: Sat, 17 Feb 2024 10:36:14 +0900 Subject: [PATCH 05/10] =?UTF-8?q?change:=20=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E5=90=8D=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/e2e/browser/song/{sing.test.ts => song.test.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/e2e/browser/song/{sing.test.ts => song.test.ts} (100%) diff --git a/tests/e2e/browser/song/sing.test.ts b/tests/e2e/browser/song/song.test.ts similarity index 100% rename from tests/e2e/browser/song/sing.test.ts rename to tests/e2e/browser/song/song.test.ts From 8e945e071f83168dd2fbcda1e55b6ffe75847d28 Mon Sep 17 00:00:00 2001 From: wewewe-ok Date: Sat, 17 Feb 2024 11:00:53 +0900 Subject: [PATCH 06/10] =?UTF-8?q?fix:=20navigateToSong=E3=81=8C=E3=81=8D?= =?UTF-8?q?=E3=81=A1=E3=82=93=E3=81=A8=E5=8B=95=E3=81=8F=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/e2e/browser/song/song.test.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/e2e/browser/song/song.test.ts b/tests/e2e/browser/song/song.test.ts index 49a3914fcf..f7699c3934 100644 --- a/tests/e2e/browser/song/song.test.ts +++ b/tests/e2e/browser/song/song.test.ts @@ -4,12 +4,10 @@ import { gotoHome, navigateToMain } from "../../navigators"; test.beforeEach(gotoHome); -function navigateToSong(page: Page) { - return async () => { - await navigateToMain(page); - await expect(page.getByText("ソング")).toBeVisible(); - await page.getByText("ソング").click(); - }; +async function navigateToSong(page: Page) { + await navigateToMain(page); + await expect(page.getByText("ソング")).toBeVisible(); + await page.getByText("ソング").click(); } test("再生ボタンを押して再生できる", async ({ page }) => { From 02b6e5972ceaa0e054e8cdd28d793e125022d76b Mon Sep 17 00:00:00 2001 From: wewewe-ok Date: Sat, 17 Feb 2024 11:13:08 +0900 Subject: [PATCH 07/10] =?UTF-8?q?fix:=20=E5=85=A5=E5=8A=9B=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=81=8C=E8=A1=8C=E3=82=8F=E3=82=8C=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/e2e/browser/song/song.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/browser/song/song.test.ts b/tests/e2e/browser/song/song.test.ts index f7699c3934..242f9d9589 100644 --- a/tests/e2e/browser/song/song.test.ts +++ b/tests/e2e/browser/song/song.test.ts @@ -63,6 +63,7 @@ test("ダブルクリックでノートを編集できる", async ({ page }) => .locator(".sequencer-body") .click({ position: { x: 107, y: 171 }, clickCount: 2 }); // ダブルクリック + await page.locator(".note-lyric-input").fill("あ"); await page.keyboard.press("Enter"); const afterLyric = await getCurrentNoteLyric(); await expect(afterLyric).not.toEqual(beforeLyric); From 92ed5948b3e31b97a1d5b6a87b57303c2b76f85f Mon Sep 17 00:00:00 2001 From: Kai Date: Sun, 18 Feb 2024 12:56:12 +0900 Subject: [PATCH 08/10] Update tests/e2e/browser/song/song.test.ts Co-authored-by: Yuto Ashida --- tests/e2e/browser/song/song.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/browser/song/song.test.ts b/tests/e2e/browser/song/song.test.ts index 242f9d9589..0b7a61d17b 100644 --- a/tests/e2e/browser/song/song.test.ts +++ b/tests/e2e/browser/song/song.test.ts @@ -18,7 +18,7 @@ test("再生ボタンを押して再生できる", async ({ page }) => { await page.locator(".sequencer-playhead").boundingBox(); // 再生ボタンを押して再生 - await page.locator(".sequencer-body").click({ position: { x: 107, y: 171 } }); + await page.locator(".sequencer-body").click({ position: { x: 107, y: 171 } }); // ノートを追加 const beforePosition = await getCurrentPlayhead(); // 再生ヘッドの初期位置 await page.getByText("play_arrow").click(); // 再生ボタンを押す await page.waitForTimeout(3000); From fb4641c20a100ac4b55225d939fe4638918cbbe4 Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Thu, 22 Feb 2024 01:39:03 +0900 Subject: [PATCH 09/10] =?UTF-8?q?=E8=AA=BF=E6=95=B4=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=81=BF=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Sing/ScoreSequencer.vue | 2 + src/components/Sing/SequencerNote.vue | 6 +- tests/e2e/browser/song/song.test.ts | 70 ---------------- ...3\202\275\343\203\263\343\202\260.spec.ts" | 81 +++++++++++++++++++ 4 files changed, 88 insertions(+), 71 deletions(-) delete mode 100644 tests/e2e/browser/song/song.test.ts create mode 100644 "tests/e2e/browser/song/\343\202\275\343\203\263\343\202\260.spec.ts" diff --git a/src/components/Sing/ScoreSequencer.vue b/src/components/Sing/ScoreSequencer.vue index a9ce4210af..1dff51e627 100644 --- a/src/components/Sing/ScoreSequencer.vue +++ b/src/components/Sing/ScoreSequencer.vue @@ -18,6 +18,7 @@
-
+
{{ lyric }}
{ - await navigateToSong(page); - // TODO: ページ内のオーディオを検出するテストを追加する - - const getCurrentPlayhead = async () => - await page.locator(".sequencer-playhead").boundingBox(); - - // 再生ボタンを押して再生 - await page.locator(".sequencer-body").click({ position: { x: 107, y: 171 } }); // ノートを追加 - const beforePosition = await getCurrentPlayhead(); // 再生ヘッドの初期位置 - await page.getByText("play_arrow").click(); // 再生ボタンを押す - await page.waitForTimeout(3000); - await page.getByText("stop").click(); // 停止ボタンを押す - const afterPosition = await getCurrentPlayhead(); // 再生ヘッドの再生後の位置 - await expect(afterPosition?.x).not.toEqual(beforePosition?.x); - await expect(afterPosition?.y).toEqual(beforePosition?.y); -}); - -test("ノートを追加・削除できる", async ({ page }) => { - await navigateToSong(page); - - const getCurrentNoteCount = async () => await page.locator(".note").count(); - - // ノートの追加 - await expect(await getCurrentNoteCount()).toBe(0); - await page.locator(".sequencer-body").click({ position: { x: 107, y: 171 } }); - await expect(await getCurrentNoteCount()).toBe(1); - await page.locator(".sequencer-body").click({ position: { x: 200, y: 171 } }); - await expect(await getCurrentNoteCount()).toBe(2); - - // ノートの削除 - await expect(await getCurrentNoteCount()).toBe(2); - await page.locator(".sequencer-body").click({ position: { x: 107, y: 171 } }); - await page.keyboard.press("Delete"); - await expect(await getCurrentNoteCount()).toBe(1); - await page.locator(".sequencer-body").click({ position: { x: 200, y: 171 } }); - await page.keyboard.press("Delete"); - await expect(await getCurrentNoteCount()).toBe(0); -}); - -test("ダブルクリックでノートを編集できる", async ({ page }) => { - await navigateToSong(page); - - const getCurrentNoteLyric = async () => - await page.locator(".note-lyric").textContent(); - - await page.locator(".sequencer-body").click({ position: { x: 107, y: 171 } }); - const beforeLyric = await getCurrentNoteLyric(); - - await page - .locator(".sequencer-body") - .click({ position: { x: 107, y: 171 }, clickCount: 2 }); // ダブルクリック - - await page.locator(".note-lyric-input").fill("あ"); - await page.keyboard.press("Enter"); - const afterLyric = await getCurrentNoteLyric(); - await expect(afterLyric).not.toEqual(beforeLyric); -}); diff --git "a/tests/e2e/browser/song/\343\202\275\343\203\263\343\202\260.spec.ts" "b/tests/e2e/browser/song/\343\202\275\343\203\263\343\202\260.spec.ts" new file mode 100644 index 0000000000..1518056363 --- /dev/null +++ "b/tests/e2e/browser/song/\343\202\275\343\203\263\343\202\260.spec.ts" @@ -0,0 +1,81 @@ +import { test, expect, Page, Locator } from "@playwright/test"; + +import { gotoHome, navigateToMain } from "../../navigators"; + +test.beforeEach(gotoHome); + +async function navigateToSong(page: Page) { + await navigateToMain(page); + expect(page.getByText("ソング")).toBeVisible(); + await page.getByText("ソング").click(); +} + +test("再生ボタンを押して再生できる", async ({ page }) => { + await navigateToSong(page); + // TODO: ページ内のオーディオを検出するテストを追加する + + const getCurrentPlayhead = async () => { + const boundingBox = await page + .getByTestId("sequencer-playhead") + .boundingBox(); + if (boundingBox == null) throw new Error("再生バーが見つかりません"); + return boundingBox; + }; + + const sequencer = page.getByLabel("シーケンサ"); + + await sequencer.click({ position: { x: 107, y: 171 } }); // ノートを追加 + const beforePosition = await getCurrentPlayhead(); // 再生ヘッドの初期位置 + await page.getByText("play_arrow").click(); // 再生ボタンを押す + await page.waitForTimeout(3000); + await page.getByText("stop").click(); // 停止ボタンを押す + const afterPosition = await getCurrentPlayhead(); // 再生ヘッドの再生後の位置 + expect(afterPosition.x).not.toEqual(beforePosition.x); + expect(afterPosition.y).toEqual(beforePosition.y); +}); + +test("ノートを追加・削除できる", async ({ page }) => { + await navigateToSong(page); + + const sequencer = page.getByLabel("シーケンサ"); + + const getCurrentNoteCount = async () => + await sequencer.locator(".note").count(); + + // ノートの追加 + expect(await getCurrentNoteCount()).toBe(0); + await sequencer.click({ position: { x: 107, y: 171 } }); + expect(await getCurrentNoteCount()).toBe(1); + await sequencer.click({ position: { x: 200, y: 171 } }); + expect(await getCurrentNoteCount()).toBe(2); + + // ノートの削除 + expect(await getCurrentNoteCount()).toBe(2); + await sequencer.click({ position: { x: 107, y: 171 } }); + await page.keyboard.press("Delete"); + expect(await getCurrentNoteCount()).toBe(1); + await sequencer.click({ position: { x: 200, y: 171 } }); + await page.keyboard.press("Delete"); + expect(await getCurrentNoteCount()).toBe(0); +}); + +test("ダブルクリックで歌詞を編集できる", async ({ page }) => { + await navigateToSong(page); + + const sequencer = page.getByLabel("シーケンサ"); + + const getCurrentNoteLyric = async (note: Locator) => + await note.getByTestId("note-lyric").textContent(); + + await sequencer.click({ position: { x: 107, y: 171 } }); + + const note = sequencer.locator(".note"); + const beforeLyric = await getCurrentNoteLyric(note); + + await sequencer.click({ position: { x: 107, y: 171 }, clickCount: 2 }); // ダブルクリック + + await note.getByRole("textbox").fill("あ"); + await page.keyboard.press("Enter"); + const afterLyric = await getCurrentNoteLyric(note); + expect(afterLyric).not.toEqual(beforeLyric); +}); From 7b4f3ac95981724feaa2f552eda7aa1dd035ad39 Mon Sep 17 00:00:00 2001 From: wewewe-ok Date: Thu, 22 Feb 2024 16:42:06 +0900 Subject: [PATCH 10/10] =?UTF-8?q?refactor:=20=E9=96=A2=E6=95=B0=E3=81=AE?= =?UTF-8?q?=E3=82=B9=E3=82=B3=E3=83=BC=E3=83=97=E3=81=8C=E9=95=B7=E3=81=84?= =?UTF-8?q?=E3=81=9F=E3=82=81=E3=83=86=E3=82=B9=E3=83=88=E3=82=B1=E3=83=BC?= =?UTF-8?q?=E3=82=B9=E3=81=AE=E5=A4=96=E3=81=B8=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\202\275\343\203\263\343\202\260.spec.ts" | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git "a/tests/e2e/browser/song/\343\202\275\343\203\263\343\202\260.spec.ts" "b/tests/e2e/browser/song/\343\202\275\343\203\263\343\202\260.spec.ts" index 1518056363..c85a451ba0 100644 --- "a/tests/e2e/browser/song/\343\202\275\343\203\263\343\202\260.spec.ts" +++ "b/tests/e2e/browser/song/\343\202\275\343\203\263\343\202\260.spec.ts" @@ -10,26 +10,26 @@ async function navigateToSong(page: Page) { await page.getByText("ソング").click(); } +async function getCurrentPlayhead(page: Page) { + const boundingBox = await page + .getByTestId("sequencer-playhead") + .boundingBox(); + if (boundingBox == null) throw new Error("再生バーが見つかりません"); + return boundingBox; +} + test("再生ボタンを押して再生できる", async ({ page }) => { await navigateToSong(page); // TODO: ページ内のオーディオを検出するテストを追加する - const getCurrentPlayhead = async () => { - const boundingBox = await page - .getByTestId("sequencer-playhead") - .boundingBox(); - if (boundingBox == null) throw new Error("再生バーが見つかりません"); - return boundingBox; - }; - const sequencer = page.getByLabel("シーケンサ"); await sequencer.click({ position: { x: 107, y: 171 } }); // ノートを追加 - const beforePosition = await getCurrentPlayhead(); // 再生ヘッドの初期位置 + const beforePosition = await getCurrentPlayhead(page); // 再生ヘッドの初期位置 await page.getByText("play_arrow").click(); // 再生ボタンを押す await page.waitForTimeout(3000); await page.getByText("stop").click(); // 停止ボタンを押す - const afterPosition = await getCurrentPlayhead(); // 再生ヘッドの再生後の位置 + const afterPosition = await getCurrentPlayhead(page); // 再生ヘッドの再生後の位置 expect(afterPosition.x).not.toEqual(beforePosition.x); expect(afterPosition.y).toEqual(beforePosition.y); });