설정을 팝업으로: 방 안에서 설정을 열어도 방에서 나가지 않게 방 막대·헤더 계정 메뉴의 ⚙️ 설정을 화면 설정 팝업으로(설정 페이지와 같은 화면 설정 공용, 헤더 팝업에는 내 계정·기록 링크), e2e/settings.e2e.ts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-14 04:15:08 +09:00
parent 73b929739d
commit 18f0530237
9 changed files with 254 additions and 49 deletions

View File

@@ -49,6 +49,7 @@ bun e2e/bots.e2e.ts # 컴퓨터 상대, 방 나가기, 게스트
bun e2e/replay.e2e.ts # 다시 보기
bun e2e/tutorial.e2e.ts # 처음 하는 사람용 규칙 요약
bun e2e/speed.e2e.ts # 게임 속도 배율: 판 애니메이션 재생 속도와 컴퓨터 응답 시간
bun e2e/settings.e2e.ts # 설정 팝업: 게임 중에 열어도 방에서 나가지 않음, 바로 적용, 닫기·포커스
bun scripts/loadtest.ts --help # 부하·장애 주입 (docs/reports 참고)
```

View File

@@ -0,0 +1,67 @@
/** 화면 설정 (font size, colours, sound, vibration, tap-to-place), shared by the 설정 page and the 설정 popup. */
import { Link } from 'react-router';
import { useSession } from '../store/session';
import { Sheet } from './ui';
function Seg<T extends string>({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) {
return (
<div className="setting-row">
<strong>{label}</strong>
<div className="segmented" role="group" aria-label={label}>
{options.map(([k, l]) => (
<button key={k} type="button" aria-pressed={value === k} onClick={() => onChange(k)}>
{l}
</button>
))}
</div>
</div>
);
}
/** The setting rows only; the caller adds the heading and the box. Changes apply and save at once. */
export function DisplaySettings() {
const settings = useSession((s) => s.settings);
const updateSettings = useSession((s) => s.updateSettings);
return (
<>
<Seg label="글자 크기" value={settings.fontScale} options={[['normal', '보통'], ['large', '크게'], ['xlarge', '아주 크게']]} onChange={(fontScale) => updateSettings({ fontScale })} />
<Seg label="화면 색" value={settings.theme} options={[['auto', '자동'], ['light', '밝게'], ['dark', '어둡게']]} onChange={(theme) => updateSettings({ theme })} />
<Seg label="소리" value={settings.sound ? 'on' : 'off'} options={[['on', '켜기'], ['off', '끄기']]} onChange={(v) => updateSettings({ sound: v === 'on' })} />
<label className="stack" style={{ gap: 4 }}>
<span style={{ fontWeight: 700 }}>
소리 크기 <span className="muted">{settings.volume} (기본 50, 이 기기에만 저장)</span>
</span>
<input type="range" min={0} max={100} step={5} value={settings.volume} aria-label="소리 크기 (0~100)" style={{ accentColor: 'var(--primary)' }} onChange={(e) => updateSettings({ volume: Number(e.target.value) })} />
</label>
<Seg label="진동" value={settings.vibrate ? 'on' : 'off'} options={[['on', '켜기'], ['off', '끄기']]} onChange={(v) => updateSettings({ vibrate: v === 'on' })} />
<Seg
label="돌·카드 놓기"
value={settings.tapConfirm ? 'on' : 'off'}
options={[['on', '두 번 눌러 놓기'], ['off', '한 번에 놓기']]}
onChange={(v) => updateSettings({ tapConfirm: v === 'on' })}
/>
</>
);
}
/**
* 설정 팝업: opens over the current page so a room stays open underneath (no navigation, no leave).
* `account` adds a link to the full 설정 page (nickname, records, logout); rooms leave it out because following it leaves the room.
* Pass a stable `onClose`: Sheet re-focuses itself whenever it changes.
*/
export function SettingsPopup({ onClose, account }: { onClose: () => void; account?: boolean }) {
return (
<Sheet onClose={onClose} label="설정">
<h2>화면 설정</h2>
<DisplaySettings />
{account && (
<Link className="btn btn-soft btn-block" to="/me" onClick={onClose}>
👤 내 계정 · 기록 보기
</Link>
)}
<button type="button" className="btn btn-secondary btn-block" onClick={onClose}>
닫기
</button>
</Sheet>
);
}

View File

@@ -1,10 +1,11 @@
/** PC top menu (docs/07-ui-ux.md §3.2): 로고·메뉴, 오른쪽에 소리 크기·테마 버튼과 로그인/계정 메뉴. */
import { useEffect, useRef, useState } from 'react';
import { useCallback, useEffect, useRef, useState } from 'react';
import { Link, NavLink, useNavigate } from 'react-router';
import { api } from '../net/api';
import { useSession } from '../store/session';
import { Avatar, ConfirmSheet } from './ui';
import { VolumeControl } from './VolumeControl';
import { SettingsPopup } from './SettingsPopup';
export function SiteHeader() {
const { me, siteName, role } = useSession();
@@ -60,14 +61,17 @@ function ThemeToggle() {
);
}
/** 로그인한 뒤: 닉네임(디스코드 연결 시 디스코드 이름) → 누르면 [설정] ([관리자 메뉴]) [로그아웃] 메뉴. */
/** 로그인한 뒤: 닉네임(디스코드 연결 시 디스코드 이름) → 누르면 [설정](팝업) ([관리자 메뉴]) [로그아웃] 메뉴. */
function AccountMenu() {
const me = useSession((s) => s.me)!;
const role = useSession((s) => s.role);
const nav = useNavigate();
const [open, setOpen] = useState(false);
const [confirm, setConfirm] = useState(false);
const [settings, setSettings] = useState(false);
const closeSettings = useCallback(() => setSettings(false), []);
const ref = useRef<HTMLDivElement>(null);
const btn = useRef<HTMLButtonElement>(null);
useEffect(() => {
if (!open) return;
@@ -83,7 +87,7 @@ function AccountMenu() {
return (
<div className="account-menu" ref={ref}>
<button type="button" className="header-user" aria-haspopup="menu" aria-expanded={open} aria-label={`내 계정: ${me.nickname}`} onClick={() => setOpen((o) => !o)}>
<button type="button" ref={btn} className="header-user" aria-haspopup="menu" aria-expanded={open} aria-label={`내 계정: ${me.nickname}`} onClick={() => setOpen((o) => !o)}>
<Avatar user={me} size={36} />
<span className="header-user-name">{me.nickname}</span>
<span aria-hidden className="small muted">
@@ -92,7 +96,8 @@ function AccountMenu() {
</button>
{open && (
<div className="account-menu-list" role="menu" aria-label="내 계정">
<button type="button" role="menuitem" onClick={() => (setOpen(false), nav('/me'))}>
{/* A popup, not a page. The menu item is about to go away, so focus the account button first: the popup returns focus there. */}
<button type="button" role="menuitem" aria-haspopup="dialog" onClick={() => (btn.current?.focus(), setOpen(false), setSettings(true))}>
⚙️ 설정
</button>
{role !== 'user' && (
@@ -105,6 +110,7 @@ function AccountMenu() {
</button>
</div>
)}
{settings && <SettingsPopup onClose={closeSettings} account />}
{confirm && (
<ConfirmSheet
title="로그아웃할까요?"

View File

@@ -1,6 +1,6 @@
/**
* 로그인 페이지: 큰 [디스코드로 로그인] + 아래 [게스트로 시작하기].
* 게스트를 고르면 /login/guest에서 계정 이름(닉네임)을 정한다. 설정은 로그인 뒤 헤더 계정 메뉴 → 설정(/me).
* 게스트를 고르면 /login/guest에서 계정 이름(닉네임)을 정한다. 설정은 로그인 뒤 헤더 계정 메뉴 → 설정(팝업, 계정·기록은 /me).
*/
import { Link, Navigate, useMatch, useNavigate, useSearchParams } from 'react-router';
import { TopBar } from '../components/ui';

View File

@@ -1,33 +1,19 @@
/** 설정(계정) 페이지 (docs/05 §7). 헤더 계정 메뉴 → 설정으로 들어와요. */
/** 설정(계정) 페이지 (docs/05 §7). 헤더 계정 메뉴 → 설정 팝업 → [내 계정 · 기록 보기]로 들어와요. */
import { useEffect, useState } from 'react';
import { Link, Navigate, useNavigate } from 'react-router';
import { catalogById, nicknameError, normalizeNickname, type MyGameSummary } from '@bg/shared/lite';
import { Avatar, ConfirmSheet, TopBar } from '../components/ui';
import { GuestWarning } from '../components/NicknameForm';
import { DisplaySettings } from '../components/SettingsPopup';
import { resultLabel } from '../components/PlayerCard';
import { gameName } from '../components/GameNotice';
import { api, discordLoginUrl } from '../net/api';
import { useSession } from '../store/session';
import { toast } from '../store/toast';
function Seg<T extends string>({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) {
return (
<div className="setting-row">
<strong>{label}</strong>
<div className="segmented" role="group" aria-label={label}>
{options.map(([k, l]) => (
<button key={k} type="button" aria-pressed={value === k} onClick={() => onChange(k)}>
{l}
</button>
))}
</div>
</div>
);
}
export default function MePage() {
const nav = useNavigate();
const { me, settings, discordEnabled, useAvatar, hasDiscordAvatar, updateSettings, role } = useSession();
const { me, discordEnabled, useAvatar, hasDiscordAvatar, role } = useSession();
const [editing, setEditing] = useState(false);
const [nick, setNick] = useState(me?.nickname ?? '');
const [error, setError] = useState<string | null>(null);
@@ -52,28 +38,6 @@ export default function MePage() {
}
};
const display = (
<section className="card stack">
<h2>화면 설정</h2>
<Seg label="글자 크기" value={settings.fontScale} options={[['normal', '보통'], ['large', '크게'], ['xlarge', '아주 크게']]} onChange={(fontScale) => updateSettings({ fontScale })} />
<Seg label="화면 색" value={settings.theme} options={[['auto', '자동'], ['light', '밝게'], ['dark', '어둡게']]} onChange={(theme) => updateSettings({ theme })} />
<Seg label="소리" value={settings.sound ? 'on' : 'off'} options={[['on', '켜기'], ['off', '끄기']]} onChange={(v) => updateSettings({ sound: v === 'on' })} />
<label className="stack" style={{ gap: 4 }}>
<span style={{ fontWeight: 700 }}>
소리 크기 <span className="muted">{settings.volume} (기본 50, 이 기기에만 저장)</span>
</span>
<input type="range" min={0} max={100} step={5} value={settings.volume} aria-label="소리 크기 (0~100)" style={{ accentColor: 'var(--primary)' }} onChange={(e) => updateSettings({ volume: Number(e.target.value) })} />
</label>
<Seg label="진동" value={settings.vibrate ? 'on' : 'off'} options={[['on', '켜기'], ['off', '끄기']]} onChange={(v) => updateSettings({ vibrate: v === 'on' })} />
<Seg
label="돌·카드 놓기"
value={settings.tapConfirm ? 'on' : 'off'}
options={[['on', '두 번 눌러 놓기'], ['off', '한 번에 놓기']]}
onChange={(v) => updateSettings({ tapConfirm: v === 'on' })}
/>
</section>
);
// 로그인 안 했으면 로그인 페이지로 (로그인 페이지에는 로그인만 있어요).
if (!me) return <Navigate to="/login?next=/me" replace />;
@@ -149,7 +113,10 @@ export default function MePage() {
</div>
<div className="me-main">
{display}
<section className="card stack">
<h2>화면 설정</h2>
<DisplaySettings />
</section>
<section className="card stack">
<h2>내 기록</h2>

View File

@@ -1,11 +1,12 @@
/** 방: 대기실 ↔ 게임 ↔ 결과를 한 주소에서 전환 (docs/06 §5–§9). */
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from 'react';
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from 'react';
import { Link, useNavigate, useParams } from 'react-router';
import { BOT_BANDS, BOT_PICKS, BOT_PICK_LABEL, bandOf, botChatRequired, botsAllowed, formatRoomCode, isBotId, luckLabel, type PublicUser, type RoomView } from '@bg/shared/lite';
import { Avatar, CodeLabel, ConfirmSheet, CopyButton, ShareButton, Sheet, TopBar } from '../components/ui';
import { GuestWarning, NicknameForm } from '../components/NicknameForm';
import { GameNotice, gameName } from '../components/GameNotice';
import { QrModal } from '../components/QrModal';
import { SettingsPopup } from '../components/SettingsPopup';
import { api, type RoomPreview } from '../net/api';
import { socket, useRoom } from '../net/socket';
import { useSession } from '../store/session';
@@ -94,6 +95,9 @@ function Room({ code, me }: { code: string; me: PublicUser }) {
const [ui, setUi] = useState<GameUI | null>(null);
const [leaveAsk, setLeaveAsk] = useState(false);
const [chatOpen, setChatOpen] = useState(false);
// 설정 opens as a popup over the room: going to /me would unmount the room and detach from it.
const [settingsOpen, setSettingsOpen] = useState(false);
const closeSettings = useCallback(() => setSettingsOpen(false), []);
// [한 판 더] takes me back to this room's lobby after game N (kept per tab so a reload stays there).
const lobbyKey = `bg:lobby:${code}`;
const [lobbyAfter, setLobbyAfter] = useState<number | null>(() => Number(sessionStorage.getItem(lobbyKey)) || null);
@@ -217,7 +221,7 @@ function Room({ code, me }: { code: string; me: PublicUser }) {
<span className="rb-ico">📖</span>
<span className="rb-lbl">규칙</span>
</button>
<button className="btn btn-ghost btn-sm rb-btn" onClick={() => nav('/me')} aria-label="글자 크기 · 소리 설정">
<button className="btn btn-ghost btn-sm rb-btn" onClick={() => setSettingsOpen(true)} aria-haspopup="dialog" aria-label="글자 크기 · 소리 설정">
<span className="rb-ico">⚙️</span>
<span className="rb-lbl">설정</span>
</button>
@@ -242,6 +246,7 @@ function Room({ code, me }: { code: string; me: PublicUser }) {
</button>
</Sheet>
)}
{settingsOpen && <SettingsPopup onClose={closeSettings} />}
{leaveAsk && (
<ConfirmSheet
title="방에서 나갈까요?"

View File

@@ -58,7 +58,7 @@
## 8. 게임 중
- 위쪽 상태 줄: 지금 할 일 문장("내 차례예요" / "OO님 차례예요"), 남은 시간 링.
- 방 막대(메뉴 버튼 없이 모두 밖에): [← 홈] 게임 이름(PC) · [🔗 방 코드 링크 복사] · [💬 채팅](휴대폰) · [📖 규칙] · [⚙️ 설정](글자 크기·소리, `/me`) · **[🚪 나가기]**. 휴대폰에서는 아이콘 아래 짧은 글자로 쌓아 한 줄(320px)에 들어가게 한다(버튼은 최대 6개).
- 방 막대(메뉴 버튼 없이 모두 밖에): [← 홈] 게임 이름(PC) · [🔗 방 코드 링크 복사] · [💬 채팅](휴대폰) · [📖 규칙] · [⚙️ 설정](글자 크기·소리 팝업, 방에서 나가지 않음) · **[🚪 나가기]**. 휴대폰에서는 아이콘 아래 짧은 글자로 쌓아 한 줄(320px)에 들어가게 한다(버튼은 최대 6개).
- 오류로 게임이 멈추면 방장에게만 상태 줄 바로 아래 [⏹ 게임 끝내기(무효)] 버튼이 나온다.
- [🚪 나가기]와 [← 홈]은 같은 동작이다: 방에서 나가고 홈으로. 한 번 누르면 바로 나가고, 게임 중에 자리에 앉아 있을 때만 "게임 중에 나가면 기권으로 처리돼요" 확인을 한 번 더 묻는다.
- 무르기 요청·무승부 제안·기권은 게임 화면 안의 버튼으로 한다(지원 게임).

View File

@@ -64,7 +64,7 @@
└──────────────────────────────────────────────────────────────────────────┘
```
- 오른쪽에 테마 버튼(🌙/☀️)을 둔다. 누를 때마다 밝은 화면 ↔ 어두운 화면으로 바뀌고, `/me`의 '화면 색' 설정과 같은 값을 쓴다('자동'이면 지금 보이는 색의 반대로). 코드로 참여는 홈의 [🔢 코드로 참여](→ `/j`)로 한다.
- 오른쪽 끝: 로그인 전에는 [로그인](→ `/login`: 큰 [디스코드로 로그인], 아래 [게스트로 시작하기] → `/login/guest`에서 계정 이름 정하기). 로그인 뒤에는 닉네임(디스코드로 가입했으면 디스코드 이름)을 보이고, 누르면 [⚙️ 설정](→ `/me`)·[🚪 로그아웃] 메뉴가 열린다. 테마 버튼 말고 글자 크기·소리 같은 설정은 `/me`에 있다.
- 오른쪽 끝: 로그인 전에는 [로그인](→ `/login`: 큰 [디스코드로 로그인], 아래 [게스트로 시작하기] → `/login/guest`에서 계정 이름 정하기). 로그인 뒤에는 닉네임(디스코드로 가입했으면 디스코드 이름)을 보이고, 누르면 [⚙️ 설정]·[🚪 로그아웃] 메뉴가 열린다. [⚙️ 설정]은 페이지를 옮기지 않는 팝업(화면 설정 + [내 계정 · 기록 보기] → `/me`)이고, 방 막대의 [⚙️ 설정]도 같은 팝업(계정 링크 없음)이라 방에서 나가지 않는다. `/me`에도 같은 화면 설정이 있다.
- 내용 폭은 최대 1280px, 가운데 정렬. 게임 화면만 화면 전체 폭을 쓴다.
- 한 줄로 읽고 입력하는 화면(게임 소개 `/g/:id`, 코드로 참여 `/j`, 규칙 `/rules/:id`)은 PC에서 가운데 768px 칸만 쓴다. 휴대폰용 한 줄 배치를 1,200px로 늘리면 버튼·입력칸·글 줄이 너무 길어져 오히려 흩어져 보인다(2026-10-09). 페이지 위 [← 뒤로] 줄도 같은 폭(`TopBar width`).
- 설정(`/me`)은 PC에서 1080px 두 칸: 왼쪽 프로필·로그아웃(따라 내려옴), 오른쪽 화면 설정·기록. 휴대폰은 한 줄이고 로그아웃은 맨 아래.

159
e2e/settings.e2e.ts Normal file
View File

@@ -0,0 +1,159 @@
/**
* E2E: 설정 opens as a popup, so opening it in the middle of a game keeps me in the room.
* - Phone, 오목 against the computer: room bar ⚙️ 설정 → dialog over the board; the address stays, no `leave`/`detach` goes to
* the server, a change applies at once, and Escape / backdrop / 닫기 all close it with focus back on ⚙️.
* - PC header account menu → ⚙️ 설정 is the same popup (with a link to the full 설정 page), and /me still works.
* Run: E2E_PORT=4645 bun e2e/settings.e2e.ts (needs apps/web/dist built)
*/
import { chromium, type Page } from 'playwright-core';
import { mkdirSync, mkdtempSync } from 'node:fs';
import { join } from 'node:path';
import { loadConfig } from '../apps/server/src/config';
import { startServer } from '../apps/server/src/server';
const PORT = Number(process.env.E2E_PORT ?? 4645);
const ORIGIN = `http://localhost:${PORT}`;
const SHOTS = process.env.E2E_SHOTS ?? join(import.meta.dir, '../test-results');
mkdirSync(SHOTS, { recursive: true });
const dbDir = mkdtempSync(join(process.env.TMPDIR ?? '/tmp', 'bg-e2e-'));
const app = startServer({
config: loadConfig({ PORT: String(PORT), DB_PATH: join(dbDir, 'app.db'), PUBLIC_ORIGIN: ORIGIN }),
log: () => {},
staticDir: join(import.meta.dir, '../apps/web/dist'),
});
const browser = await chromium.launch({ executablePath: process.env.CHROME ?? '/usr/bin/google-chrome', headless: true });
let failed = false;
const step = async (name: string, fn: () => Promise<void>) => {
const t0 = performance.now();
try {
await fn();
console.log(`✓ ${name} (${Math.round(performance.now() - t0)}ms)`);
} catch (e) {
failed = true;
console.log(`✗ ${name}: ${(e as Error).message.split('\n')[0]}`);
throw e;
}
};
/** Every socket message the page sends, as text. */
function recordSent(p: Page): string[] {
const sent: string[] = [];
p.on('websocket', (ws) => ws.on('framesent', (f) => sent.push(String(f.payload))));
return sent;
}
const leftRoom = (sent: string[]) => sent.filter((m) => /"t":"(leave|detach)"/.test(m));
const focusedLabel = (p: Page) => p.evaluate(() => document.activeElement?.getAttribute('aria-label') ?? document.activeElement?.tagName ?? '');
/** 오목 against the computer, game started; returns the room address. */
async function practiceGame(p: Page, name: string): Promise<string> {
await p.goto(`${ORIGIN}/g/omok`);
await p.getByRole('button', { name: '🤖 컴퓨터와 연습하기' }).click();
await p.getByLabel('내 이름(닉네임)').fill(name);
await p.getByRole('button', { name: '이 이름으로 시작하기' }).click();
await p.waitForURL(/\/r\/\d{6}$/);
await p.getByRole('button', { name: '▶ 게임 시작' }).click();
await p.locator('svg[role="grid"]').waitFor();
return p.url();
}
try {
const phone = await browser.newContext({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2, isMobile: true, hasTouch: true, locale: 'ko-KR' });
await phone.addInitScript(() => localStorage.setItem('bg:qs:omok', '1'));
const a = await phone.newPage();
const errors: string[] = [];
a.on('pageerror', (e) => errors.push(e.message));
const sent = recordSent(a);
let roomUrl = '';
await step('휴대폰: 컴퓨터와 오목을 시작', async () => {
roomUrl = await practiceGame(a, '설정맨');
});
const opener = () => a.locator('.room-bar').getByRole('button', { name: '글자 크기 · 소리 설정' });
const dialog = () => a.getByRole('dialog', { name: '설정' });
await step('게임 중 ⚙️ 설정 → 팝업, 주소 그대로, 나가기·떠나기 신호 없음, 바꾸면 바로 적용', async () => {
await opener().click();
await dialog().waitFor();
if (a.url() !== roomUrl) throw new Error(`navigated to ${a.url()}`);
if ((await dialog().getAttribute('aria-modal')) !== 'true') throw new Error('dialog is not aria-modal');
if (!(await dialog().evaluate((el) => el.contains(document.activeElement)))) throw new Error('focus did not move into the popup');
// The board is still mounted underneath (the room did not unmount).
if (!(await a.locator('svg[role="grid"]').count())) throw new Error('board went away');
// No account link inside a room: following it would leave.
if (await dialog().getByRole('link', { name: /내 계정/ }).count()) throw new Error('account link shown inside a room');
await dialog().getByRole('group', { name: '글자 크기' }).getByRole('button', { name: '크게', exact: true }).click();
if ((await a.evaluate(() => document.documentElement.dataset.fontScale)) !== 'large') throw new Error('font size not applied at once');
await a.screenshot({ path: join(SHOTS, 'settings-popup-phone.png') });
});
await step('Escape로 닫으면 ⚙️로 초점이 돌아오고 판이 그대로', async () => {
await a.keyboard.press('Escape');
await dialog().waitFor({ state: 'detached' });
if ((await focusedLabel(a)) !== '글자 크기 · 소리 설정') throw new Error(`focus went to ${await focusedLabel(a)}`);
await a.locator('svg[role="grid"]').waitFor();
});
await step('바깥(어두운 곳)을 누르거나 [닫기]를 눌러도 닫혀요', async () => {
await opener().click();
await dialog().waitFor();
await a.mouse.click(195, 30); // the backdrop above the bottom sheet
await dialog().waitFor({ state: 'detached' });
await opener().click();
await dialog().getByRole('button', { name: '닫기' }).click();
await dialog().waitFor({ state: 'detached' });
if (a.url() !== roomUrl) throw new Error(`navigated to ${a.url()}`);
});
await step('방에 그대로 있어요: 신호 없음, 다시 불러와도 같은 크기 글자', async () => {
const bad = leftRoom(sent);
if (bad.length) throw new Error(`sent ${bad.join(', ')}`);
if (!sent.some((m) => /"t":"join"/.test(m))) throw new Error('socket frames were not recorded');
await a.locator('.turn-status').waitFor();
await a.reload();
await a.locator('svg[role="grid"]').waitFor();
if ((await a.evaluate(() => document.documentElement.dataset.fontScale)) !== 'large') throw new Error('font size not saved');
});
await step('PC 헤더 계정 메뉴 → ⚙️ 설정도 팝업, 계정 링크로 설정 페이지', async () => {
const pc = await browser.newContext({ viewport: { width: 1280, height: 800 }, locale: 'ko-KR' });
await pc.addInitScript(() => localStorage.setItem('bg:qs:omok', '1'));
const b = await pc.newPage();
b.on('pageerror', (e) => errors.push(e.message));
await practiceGame(b, '헤더맨');
await b.goto(`${ORIGIN}/games`);
await b.getByRole('button', { name: /^내 계정/ }).click();
await b.getByRole('menuitem', { name: '⚙️ 설정' }).click();
const d = b.getByRole('dialog', { name: '설정' });
await d.waitFor();
if (!b.url().endsWith('/games')) throw new Error(`navigated to ${b.url()}`);
await d.getByRole('group', { name: '화면 색' }).getByRole('button', { name: '어둡게' }).click();
if ((await b.evaluate(() => document.documentElement.dataset.theme)) !== 'dark') throw new Error('theme not applied at once');
await b.waitForTimeout(400); // let the colour transition finish for the screenshot
await b.screenshot({ path: join(SHOTS, 'settings-popup-pc.png') });
await b.keyboard.press('Escape');
await d.waitFor({ state: 'detached' });
if (!/^내 계정/.test(await focusedLabel(b))) throw new Error(`focus went to ${await focusedLabel(b)}`);
await b.getByRole('button', { name: /^내 계정/ }).click();
await b.getByRole('menuitem', { name: '⚙️ 설정' }).click();
await d.getByRole('link', { name: /내 계정 · 기록 보기/ }).click();
await b.waitForURL(`${ORIGIN}/me`);
await d.waitFor({ state: 'detached' });
// The page keeps the same settings (still dark after the popup changed it).
await b.getByRole('heading', { name: '화면 설정' }).waitFor();
if ((await b.getByRole('group', { name: '화면 색' }).getByRole('button', { name: '어둡게' }).getAttribute('aria-pressed')) !== 'true') throw new Error('page does not show the popup change');
await pc.close();
});
if (errors.length) throw new Error(`page errors: ${errors.join(' | ')}`);
} catch (e) {
failed = true;
console.error(e);
} finally {
await browser.close();
await app.stop();
}
console.log(failed ? 'E2E FAILED' : 'E2E PASSED');
process.exit(failed ? 1 : 0);