2026-01-05 01:37:32 +09:00
|
|
|
import {
|
|
|
|
|
expect,
|
|
|
|
|
getChatInput,
|
|
|
|
|
getIframe,
|
2026-10-06 09:28:46 +09:00
|
|
|
getSendButton,
|
|
|
|
|
openSettingsTab,
|
2026-01-05 01:37:32 +09:00
|
|
|
sleep,
|
|
|
|
|
test,
|
|
|
|
|
} from "./lib/fixtures"
|
|
|
|
|
|
|
|
|
|
test.describe("Language Switching", () => {
|
|
|
|
|
test("loads English by default", async ({ page }) => {
|
|
|
|
|
await page.goto("/", { waitUntil: "networkidle" })
|
|
|
|
|
await getIframe(page).waitFor({ state: "visible", timeout: 30000 })
|
|
|
|
|
|
|
|
|
|
const chatInput = getChatInput(page)
|
|
|
|
|
await expect(chatInput).toBeVisible({ timeout: 10000 })
|
|
|
|
|
|
2026-10-06 09:28:46 +09:00
|
|
|
await expect(getSendButton(page, "Send")).toBeVisible()
|
2026-01-05 01:37:32 +09:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test("can switch to Japanese", async ({ page }) => {
|
|
|
|
|
await page.goto("/", { waitUntil: "networkidle" })
|
|
|
|
|
await getIframe(page).waitFor({ state: "visible", timeout: 30000 })
|
|
|
|
|
|
|
|
|
|
await test.step("open settings and select Japanese", async () => {
|
2026-10-06 09:28:46 +09:00
|
|
|
await openSettingsTab(page, "appearance")
|
|
|
|
|
await page.locator("#language-select").click()
|
|
|
|
|
await page
|
|
|
|
|
.getByRole("option", { name: "日本語", exact: true })
|
|
|
|
|
.click()
|
|
|
|
|
await page.keyboard.press("Escape")
|
2026-01-05 01:37:32 +09:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
await test.step("verify UI is in Japanese", async () => {
|
2026-10-06 09:28:46 +09:00
|
|
|
await expect(getSendButton(page, "送信")).toBeVisible({
|
2026-01-05 01:37:32 +09:00
|
|
|
timeout: 5000,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test("can switch to Chinese", async ({ page }) => {
|
|
|
|
|
await page.goto("/", { waitUntil: "networkidle" })
|
|
|
|
|
await getIframe(page).waitFor({ state: "visible", timeout: 30000 })
|
|
|
|
|
|
|
|
|
|
await test.step("open settings and select Chinese", async () => {
|
2026-10-06 09:28:46 +09:00
|
|
|
await openSettingsTab(page, "appearance")
|
|
|
|
|
await page.locator("#language-select").click()
|
|
|
|
|
await page
|
|
|
|
|
.getByRole("option", { name: "中文", exact: true })
|
|
|
|
|
.click()
|
|
|
|
|
await page.keyboard.press("Escape")
|
2026-01-05 01:37:32 +09:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
await test.step("verify UI is in Chinese", async () => {
|
2026-10-06 09:28:46 +09:00
|
|
|
await expect(getSendButton(page, "发送")).toBeVisible({
|
2026-01-05 01:37:32 +09:00
|
|
|
timeout: 5000,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test("language persists after reload", async ({ page }) => {
|
|
|
|
|
await page.goto("/", { waitUntil: "networkidle" })
|
|
|
|
|
await getIframe(page).waitFor({ state: "visible", timeout: 30000 })
|
|
|
|
|
|
|
|
|
|
await test.step("switch to Japanese", async () => {
|
2026-10-06 09:28:46 +09:00
|
|
|
await openSettingsTab(page, "appearance")
|
|
|
|
|
await page.locator("#language-select").click()
|
|
|
|
|
await page
|
|
|
|
|
.getByRole("option", { name: "日本語", exact: true })
|
|
|
|
|
.click()
|
|
|
|
|
await page.keyboard.press("Escape")
|
2026-01-05 01:37:32 +09:00
|
|
|
await page.keyboard.press("Escape")
|
|
|
|
|
await sleep(500)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
await test.step("verify Japanese before reload", async () => {
|
2026-10-06 09:28:46 +09:00
|
|
|
await expect(getSendButton(page, "送信")).toBeVisible({
|
2026-01-05 01:37:32 +09:00
|
|
|
timeout: 10000,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
await test.step("reload and verify Japanese persists", async () => {
|
|
|
|
|
await page.reload({ waitUntil: "networkidle" })
|
|
|
|
|
await getIframe(page).waitFor({ state: "visible", timeout: 30000 })
|
|
|
|
|
// Wait for hydration and localStorage to be read
|
|
|
|
|
await sleep(1000)
|
2026-10-06 09:28:46 +09:00
|
|
|
await expect(getSendButton(page, "送信")).toBeVisible({
|
2026-01-05 01:37:32 +09:00
|
|
|
timeout: 10000,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test("Japanese locale URL works", async ({ page }) => {
|
|
|
|
|
await page.goto("/ja", { waitUntil: "networkidle" })
|
|
|
|
|
await getIframe(page).waitFor({ state: "visible", timeout: 30000 })
|
|
|
|
|
|
2026-10-06 09:28:46 +09:00
|
|
|
await expect(getSendButton(page, "送信")).toBeVisible({
|
2026-01-05 01:37:32 +09:00
|
|
|
timeout: 10000,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test("Chinese locale URL works", async ({ page }) => {
|
|
|
|
|
await page.goto("/zh", { waitUntil: "networkidle" })
|
|
|
|
|
await getIframe(page).waitFor({ state: "visible", timeout: 30000 })
|
|
|
|
|
|
2026-10-06 09:28:46 +09:00
|
|
|
await expect(getSendButton(page, "发送")).toBeVisible({
|
2026-01-05 01:37:32 +09:00
|
|
|
timeout: 10000,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|