-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* e2eテスト追加 * バグフィックス
- Loading branch information
Showing
4 changed files
with
89 additions
and
2 deletions.
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
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,73 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import dotenv from "dotenv"; | ||
import semver from "semver"; | ||
import { navigateToMain, gotoHome } from "../navigators"; | ||
import { getNewestQuasarDialog } from "../locators"; | ||
import { UpdateInfo } from "@/type/preload"; | ||
import { assertNonNullable } from "@/type/utility"; | ||
|
||
// アップデート通知が出る環境にする | ||
test.beforeEach(async ({ page }) => { | ||
dotenv.config(); | ||
|
||
// 動作環境より新しいバージョン | ||
const latestVersion = semver.inc( | ||
process.env.VITE_APP_VERSION ?? process.env.npm_package_version ?? "0.0.0", | ||
"major" | ||
); | ||
assertNonNullable(latestVersion); | ||
|
||
// アップデート情報を返すAPIのモック | ||
if (process.env.VITE_LATEST_UPDATE_INFOS_URL == undefined) { | ||
throw new Error("VITE_LATEST_UPDATE_INFOS_URL is not defined"); | ||
} | ||
page.route(process.env.VITE_LATEST_UPDATE_INFOS_URL, (route) => { | ||
const updateInfos: UpdateInfo[] = [ | ||
{ | ||
version: latestVersion, | ||
descriptions: [], | ||
contributors: [], | ||
}, | ||
]; | ||
route.fulfill({ | ||
status: 200, | ||
body: JSON.stringify(updateInfos), | ||
}); | ||
}); | ||
}); | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await gotoHome({ page }); | ||
|
||
await navigateToMain(page); | ||
await page.waitForTimeout(100); | ||
}); | ||
|
||
test("アップデートが通知されたりスキップしたりできる", async ({ page }) => { | ||
await page.waitForTimeout(500); | ||
|
||
// 通知されている | ||
const dialog = getNewestQuasarDialog(page); | ||
await expect(dialog.getByText("アップデートのお知らせ")).toBeVisible(); | ||
|
||
// 普通に閉じると消える | ||
await dialog.getByRole("button", { name: "閉じる" }).click(); | ||
await page.waitForTimeout(500); | ||
await expect(dialog).not.toBeVisible(); | ||
|
||
// 再度開くとまた表示される | ||
await page.reload(); | ||
await expect(dialog.getByText("アップデートのお知らせ")).toBeVisible(); | ||
|
||
// スキップすると消える | ||
await dialog | ||
.getByRole("button", { name: "このバージョンをスキップ" }) | ||
.click(); | ||
await page.waitForTimeout(500); | ||
await expect(dialog).not.toBeVisible(); | ||
|
||
// 再度開いても表示されない(スキップされた) | ||
await page.reload(); | ||
await page.waitForTimeout(5000); // エンジン読み込み待機 | ||
await expect(dialog).not.toBeVisible(); | ||
}); |