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

Test: 設定ダイアログのスクリーンショットテスト追加 #1953

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { test, expect, Page, Locator } from "@playwright/test";

import { gotoHome, navigateToOptionDialog } from "../../navigators";
import { gotoHome, navigateToSettingDialog } from "../../navigators";
import { getNewestQuasarDialog } from "../../locators";

test.beforeEach(gotoHome);

/**
* 書き出しファイル名パターンダイアログまで移動
*/
const moveToFilenameDialog = async (page: Page, optionDialog: Locator) => {
await optionDialog.getByRole("button", { name: "編集する" }).click();
const moveToFilenameDialog = async (page: Page, settingDialog: Locator) => {
await settingDialog.getByRole("button", { name: "編集する" }).click();
Comment on lines -11 to +12
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

実装の方では「settingDialog」だったので、名称をそちらに合わせるようにしました。

await page.waitForTimeout(500);

const filenameDialog = getNewestQuasarDialog(page);
Expand All @@ -28,9 +28,9 @@ const moveToFilenameDialog = async (page: Page, optionDialog: Locator) => {
test("「オプション」から「書き出しファイル名パターン」を変更したり保存したりできる", async ({
page,
}) => {
const optionDialog = await navigateToOptionDialog(page);
const settingDialog = await navigateToSettingDialog(page);

let { doneButton, textbox } = await moveToFilenameDialog(page, optionDialog);
let { doneButton, textbox } = await moveToFilenameDialog(page, settingDialog);

// デフォルト状態は確定ボタンが押せる
await expect(textbox).toHaveValue("$連番$_$キャラ$($スタイル$)_$テキスト$");
Expand All @@ -40,15 +40,15 @@ test("「オプション」から「書き出しファイル名パターン」
await textbox.click();
await textbox.fill("");
await textbox.press("Enter");
await expect(optionDialog.getByText("何か入力してください")).toBeVisible();
await expect(settingDialog.getByText("何か入力してください")).toBeVisible();
await expect(doneButton).toBeDisabled();

// $連番$ が含まれていない場合は確定ボタンが押せない
await textbox.click();
await textbox.fill("test");
await textbox.press("Enter");
await expect(textbox).toHaveValue("test");
await expect(optionDialog.getByText("$連番$は必須です")).toBeVisible();
await expect(settingDialog.getByText("$連番$は必須です")).toBeVisible();
await expect(doneButton).toBeDisabled();

// 無効な文字が含まれている場合は確定ボタンが押せない
Expand All @@ -57,7 +57,7 @@ test("「オプション」から「書き出しファイル名パターン」
await textbox.press("Enter");
await expect(doneButton).toBeDisabled();
await expect(
optionDialog.getByText("使用できない文字が含まれています:「\\」")
settingDialog.getByText("使用できない文字が含まれています:「\\」")
).toBeVisible();

// $連番$ を含めると確定ボタンが押せる
Expand All @@ -72,10 +72,10 @@ test("「オプション」から「書き出しファイル名パターン」
// 確定するとダイアログが閉じて設定した内容が反映されている
await doneButton.click();
await page.waitForTimeout(700);
await expect(optionDialog.getByText("test$連番$.wav")).toBeVisible();
await expect(settingDialog.getByText("test$連番$.wav")).toBeVisible();

// 再度開くと設定した内容が反映されている
({ doneButton, textbox } = await moveToFilenameDialog(page, optionDialog));
({ doneButton, textbox } = await moveToFilenameDialog(page, settingDialog));
await expect(textbox).toHaveValue("test$連番$");

// デフォルト値にリセットできる
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from "@playwright/test";
import { gotoHome, navigateToSettingDialog } from "../../navigators";

test.beforeEach(gotoHome);

test("スクリーンショット", async ({ page }) => {
test.skip(process.platform !== "win32", "Windows以外のためスキップします");

await navigateToSettingDialog(page);
await page.waitForTimeout(500);

// スクリーンショット撮影とスクロールを繰り返す
for (let i = 0; i < 5; i++) {
await expect(page).toHaveScreenshot(`スクリーンショット_${i}.png`);
await page.mouse.wheel(0, 500);
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
await page.waitForTimeout(300);
}
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

後で設定パラメータが追加されることも考えて、スクリーンショットはちょっとだけ長めに撮影しています。

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/e2e/navigators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ export async function navigateToHelpDialog(page: Page) {
}

/**
* オプションダイアログの表示まで移動
* 設定ダイアログの表示まで移動
*/
export async function navigateToOptionDialog(page: Page) {
export async function navigateToSettingDialog(page: Page) {
await navigateToMain(page);
await page.waitForTimeout(100);
await page.getByRole("button", { name: "設定" }).click();
Expand Down
Loading