-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add: ソング関連のe2eテストを追加 * remove: consoleLogを削除 * refactor: ソングページに遷移する処理を関数で切り出し * リファクタリング * change: ファイル名を変更 * fix: navigateToSongがきちんと動くように修正 * fix: 入力処理が行われていなかったので修正 * Update tests/e2e/browser/song/song.test.ts Co-authored-by: Yuto Ashida <[email protected]> * 調整してみた * refactor: 関数のスコープが長いためテストケースの外へ移動 --------- Co-authored-by: Yuto Ashida <[email protected]> Co-authored-by: Hiroshiba <[email protected]>
- Loading branch information
1 parent
3e90be4
commit 6a51865
Showing
3 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
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 sequencer = page.getByLabel("シーケンサ"); | ||
|
||
await sequencer.click({ position: { x: 107, y: 171 } }); // ノートを追加 | ||
const beforePosition = await getCurrentPlayhead(page); // 再生ヘッドの初期位置 | ||
await page.getByText("play_arrow").click(); // 再生ボタンを押す | ||
await page.waitForTimeout(3000); | ||
await page.getByText("stop").click(); // 停止ボタンを押す | ||
const afterPosition = await getCurrentPlayhead(page); // 再生ヘッドの再生後の位置 | ||
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); | ||
}); |