Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ソング関連のe2eテストを追加 #1849

Merged
merged 10 commits into from
Feb 22, 2024
70 changes: 70 additions & 0 deletions tests/e2e/browser/song/song.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { test, expect, Page } from "@playwright/test";

import { gotoHome, navigateToMain } from "../../navigators";

test.beforeEach(gotoHome);

async function navigateToSong(page: Page) {
await navigateToMain(page);
await expect(page.getByText("ソング")).toBeVisible();
await page.getByText("ソング").click();
}

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 } });
weweweok marked this conversation as resolved.
Show resolved Hide resolved
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);
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
});

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 } });
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
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("あ");
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
await page.keyboard.press("Enter");
const afterLyric = await getCurrentNoteLyric();
await expect(afterLyric).not.toEqual(beforeLyric);
});
Loading