The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(i18n): use shared browser helpers and decode persisted locale
Toyo Saga8fae68aa6156
diff --git a/app/test/e2e/helpers/element-helpers.ts b/app/test/e2e/helpers/element-helpers.tsindex 600446c722..c2a0bdab49 100644--- a/app/test/e2e/helpers/element-helpers.ts+++ b/app/test/e2e/helpers/element-helpers.ts@@ -1,7 +1,7 @@/*** Cross-platform WebView element helpers for E2E tests.*- * Two backends are supported:+ * Desktop backends and the Playwright web harness are supported:** ## Appium Mac2 (macOS)* The mac2 driver exposes WKWebView content through the macOS accessibility@@ -17,6 +17,7 @@* - `browser.execute()` runs JS inside the WebView* - `browser.getPageSource()` returns HTML (not accessibility XML)*/+import type { Page } from '@playwright/test';import type { ChainablePromiseElement } from 'webdriverio';import { isTauriDriver } from './platform';@@ -694,3 +695,34 @@ export async function dumpAccessibilityTree(): Promise<string> {return `[dumpAccessibilityTree] Failed: ${err}`;}}++// Playwright web-lane adapter. Keep platform locator types and locale-storage+// decoding here so web specs use the same shared element-helper boundary.+export type BrowserPage = Page;++export function browserElements(page: BrowserPage) {+ const language = (name: string) => page.getByRole('combobox', { name, exact: true });+ return {+ language,+ selectLanguage: (name: string, value: string | { label: string }) =>+ language(name).selectOption(value),+ document: page.locator('html'),+ chatTab: page.locator('[data-walkthrough="tab-chat"]'),+ text: (value: string) => page.getByText(value, { exact: true }),+ };+}++export async function persistedBrowserLocale(page: BrowserPage): Promise<string | null> {+ return page.evaluate(() => {+ const raw = localStorage.getItem('persist:locale');+ if (!raw) return null;+ try {+ // Redux Persist JSON-encodes each reducer property inside its outer JSON.+ const persisted = JSON.parse(raw) as { current?: string };+ if (!persisted.current) return null;+ return JSON.parse(persisted.current) as string;+ } catch {+ return null;+ }+ });+}diff --git a/app/test/e2e/specs/japanese-locale.browser.ts b/app/test/e2e/specs/japanese-locale.browser.tsindex ff8c1f8e7f..c9d839738a 100644--- a/app/test/e2e/specs/japanese-locale.browser.ts+++ b/app/test/e2e/specs/japanese-locale.browser.ts@@ -1,20 +1,25 @@-import { expect, type Page, test } from '@playwright/test';+import { expect, test } from '@playwright/test';import {bootAuthenticatedPage,dismissWalkthroughIfPresent,} from '../../playwright/helpers/core-rpc';+import {+ browserElements,+ type BrowserPage,+ persistedBrowserLocale,+} from '../helpers/element-helpers';-async function settings(page: Page, user: string) {+async function settings(page: BrowserPage, user: string) {await bootAuthenticatedPage(page, user, '/settings/account');await dismissWalkthroughIfPresent(page);}-async function expectJapanese(page: Page) {- await expect(page.getByRole('combobox', { name: '言語', exact: true })).toHaveValue('ja');- await expect(page.locator('html')).toHaveAttribute('lang', 'ja');- await expect(page.locator('html')).toHaveAttribute('dir', 'ltr');- await expect(page.locator('[data-walkthrough="tab-chat"]')).toContainText('チャット');+async function expectJapanese(page: BrowserPage) {+ await expect(browserElements(page).language('言語')).toHaveValue('ja');+ await expect(browserElements(page).document).toHaveAttribute('lang', 'ja');+ await expect(browserElements(page).document).toHaveAttribute('dir', 'ltr');+ await expect(browserElements(page).chatTab).toContainText('チャット');}test.describe('Japanese UI locale', () => {@@ -24,29 +29,19 @@ test.describe('Japanese UI locale', () => {page,}) => {await settings(page, 'pw-japanese-switch');- await page- .getByRole('combobox', { name: 'Language', exact: true })- .selectOption({ label: '🇯🇵 日本語' });+ await browserElements(page).selectLanguage('Language', { label: '🇯🇵 日本語' });await expectJapanese(page);// Wait for redux-persist to write, rather than dispatching or seeding a locale.- await expect- .poll(() =>- page.evaluate(() => Object.values(localStorage).some(value => value.includes('\\"ja\\"')))- )- .toBe(true);+ await expect.poll(() => persistedBrowserLocale(page)).toBe('ja');await page.reload();await expectJapanese(page);- await page.getByRole('combobox', { name: '言語', exact: true }).selectOption('en');- await expect(page.getByRole('combobox', { name: 'Language', exact: true })).toHaveValue('en');- await expect(page.locator('html')).toHaveAttribute('lang', 'en');- await expect(page.locator('[data-walkthrough="tab-chat"]')).toContainText('Chat');- await expect- .poll(() =>- page.evaluate(() => Object.values(localStorage).some(value => value.includes('\\"en\\"')))- )- .toBe(true);+ await browserElements(page).selectLanguage('言語', 'en');+ await expect(browserElements(page).language('Language')).toHaveValue('en');+ await expect(browserElements(page).document).toHaveAttribute('lang', 'en');+ await expect(browserElements(page).chatTab).toContainText('Chat');+ await expect.poll(() => persistedBrowserLocale(page)).toBe('en');await page.reload();- await expect(page.getByRole('combobox', { name: 'Language', exact: true })).toHaveValue('en');+ await expect(browserElements(page).language('Language')).toHaveValue('en');});test('detects ja-JP on a fresh browser and preserves a manual English override', async ({@@ -61,15 +56,11 @@ test.describe('Japanese UI locale', () => {await settings(page, 'pw-japanese-detect');expect(await page.evaluate(() => navigator.language)).toBe('ja-JP');await expectJapanese(page);- await expect(page.getByRole('combobox', { name: '言語', exact: true })).toBeInViewport();- await page.getByRole('combobox', { name: '言語', exact: true }).selectOption('en');- await expect- .poll(() =>- page.evaluate(() => Object.values(localStorage).some(value => value.includes('\\"en\\"')))- )- .toBe(true);+ await expect(browserElements(page).language('言語')).toBeInViewport();+ await browserElements(page).selectLanguage('言語', 'en');+ await expect.poll(() => persistedBrowserLocale(page)).toBe('en');await page.reload();- await expect(page.getByRole('combobox', { name: 'Language', exact: true })).toHaveValue('en');+ await expect(browserElements(page).language('Language')).toHaveValue('en');expect(await page.evaluate(() => navigator.language)).toBe('ja-JP');} finally {await context.close();@@ -125,26 +116,22 @@ test.describe('Japanese UI locale', () => {});await page.setViewportSize({ width: 1280, height: 720 });await settings(page, 'pw-japanese-interpolation');- await page.getByRole('combobox', { name: 'Language', exact: true }).selectOption('ja');- await expect- .poll(() =>- page.evaluate(() => Object.values(localStorage).some(value => value.includes('\\"ja\\"')))- )- .toBe(true);+ await browserElements(page).selectLanguage('Language', 'ja');+ await expect.poll(() => persistedBrowserLocale(page)).toBe('ja');await page.goto('/#/connections?tab=brain&brain=explorer');- const count = page.getByText('この場所の項目: 7件', { exact: true });+ const count = browserElements(page).text('この場所の項目: 7件');await expect(count).toBeVisible();await count.scrollIntoViewIfNeeded();await expect(count).toBeInViewport();expect(await count.evaluate(element => element.scrollWidth <= element.clientWidth)).toBe(true);await page.goto('/#/connections?tab=usage#tokens');- const attribution = page.getByText('Qwen3.8-Flash-Next のコストで計算', { exact: true });+ const attribution = browserElements(page).text('Qwen3.8-Flash-Next のコストで計算');await expect(attribution).toBeVisible();await attribution.scrollIntoViewIfNeeded();await expect(attribution).toBeInViewport();expect(await attribution.evaluate(element => element.scrollWidth <= element.clientWidth)).toBe(true);- await expect(page.getByText('3 回の圧縮で', { exact: true })).toBeVisible();+ await expect(browserElements(page).text('3 回の圧縮で')).toBeVisible();});});