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

複数選択:キャラクターを変更できるように #1546

Merged
merged 9 commits into from
Sep 19, 2023
Prev Previous commit
Next Next commit
Add: テストを追加
sevenc-nanashi committed Sep 12, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 1753addaeff922acb2fe4de8b5ff9c7ae32dd549
10 changes: 10 additions & 0 deletions tests/e2e/browser/複数選択/common.ts
sevenc-nanashi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Page } from "@playwright/test";

export async function addAudioCells(page: Page, count: number) {
for (let i = 0; i < count; i++) {
await page.getByRole("button", { name: "テキストを追加" }).click();
await page.waitForTimeout(100);
}
}

export const ctrlLike = process.platform === "darwin" ? "Meta" : "Control";
62 changes: 62 additions & 0 deletions tests/e2e/browser/複数選択/操作.spec.ts
sevenc-nanashi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { test, expect, Page } from "@playwright/test";
import { toggleSetting, navigateToMain } from "../../navigators";
import { addAudioCells } from "./common";

/*
* 全てのAudioCellのキャラクター+スタイル名を取得する。
* キャラクター+スタイル名はalt属性から取得する。
*
* @returns キャラクター名の配列
*/
async function getSelectedCharacters(page: Page): Promise<string[]> {
sevenc-nanashi marked this conversation as resolved.
Show resolved Hide resolved
const characterNames = await page.evaluate(() => {
const audioCells = [...document.querySelectorAll(".audio-cell")];
const characterNames: string[] = [];
for (const audioCell of audioCells) {
const character = audioCell.querySelector(".icon-container > img");
if (character) {
const alt = character.getAttribute("alt");
if (!alt) {
throw new Error("alt属性がありません");
}

characterNames.push(alt);
}
}
return characterNames;
});
return characterNames;
}

test.beforeEach(async ({ page }) => {
const BASE_URL = "http://localhost:5173/#/home";
await page.setViewportSize({ width: 800, height: 600 });
await page.goto(BASE_URL);

await navigateToMain(page);
await page.waitForTimeout(100);
await toggleSetting(page, "複数選択");

await addAudioCells(page, 3);
});

test("複数選択:キャラクター選択", async ({ page }) => {
await page.locator(".audio-cell:nth-child(2)").click();
await page.keyboard.down("Shift");
await page.keyboard.press("ArrowDown");
await page.keyboard.press("ArrowDown");
await page.keyboard.up("Shift");
await page.waitForTimeout(100);

await page.locator(".audio-cell:nth-child(2) .character-button").click();
await page.waitForTimeout(100);

await page.locator(".character-item-container .q-item:nth-child(2)").click();
await page.waitForTimeout(100);

const characterNames = await getSelectedCharacters(page);

expect(characterNames[0]).not.toEqual(characterNames[1]);
expect(characterNames[1]).toEqual(characterNames[2]);
expect(characterNames[1]).toEqual(characterNames[3]);
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect, Page } from "@playwright/test";
import { toggleSetting, navigateToMain } from "../navigators";
import { toggleSetting, navigateToMain } from "../../navigators";
import { ctrlLike, addAudioCells } from "./common";

test.beforeEach(async ({ page }) => {
const BASE_URL = "http://localhost:5173/#/home";
@@ -13,8 +14,6 @@ test.beforeEach(async ({ page }) => {
await addAudioCells(page, 3);
});

const ctrlLike = process.platform === "darwin" ? "Meta" : "Control";

type SelectedStatus = {
active: number;
selected: number[];
@@ -46,13 +45,6 @@ async function getSelectedStatus(page: Page): Promise<SelectedStatus> {
return selectedAudioKeys;
}

async function addAudioCells(page: Page, count: number) {
for (let i = 0; i < count; i++) {
await page.getByRole("button", { name: "テキストを追加" }).click();
await page.waitForTimeout(100);
}
}

test("複数選択:マウス周り", async ({ page }) => {
let selectedStatus: SelectedStatus;