이지선다: 재생기가 준비되기 전에 A→B를 누르면 준비된 뒤 A·B가 같이 나오던 것(A→A 멈춤도 A가 나옴) — 다른 카드를 누르거나 멈출 때 기다리던 불러오기를 취소. e2e에 준비 전 A→B·A→A 회귀(가짜 플레이어 준비 지연 mq:fakeInitMs)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -60,9 +60,10 @@ async function fakeDiscord(ctx: BrowserContext, discordId: string) {
|
||||
await route.fulfill({ status: 200, headers: { 'content-type': 'text/html', 'set-cookie': res.headers.get('set-cookie') ?? '' }, body: `<script>location.replace(${JSON.stringify(back)})</script>` });
|
||||
});
|
||||
}
|
||||
async function guestPage(name: string, opts: { width?: number; height?: number; mobile?: boolean; fake?: boolean } = {}): Promise<Page> {
|
||||
async function guestPage(name: string, opts: { width?: number; height?: number; mobile?: boolean; fake?: boolean; initMs?: number } = {}): Promise<Page> {
|
||||
const ctx = await browser.newContext({ viewport: { width: opts.width ?? 1440, height: opts.height ?? 900 }, locale: 'ko-KR', isMobile: opts.mobile, hasTouch: opts.mobile });
|
||||
if (opts.fake !== false) await ctx.addInitScript(() => localStorage.setItem('mq:fakePlayer', '1'));
|
||||
if (opts.initMs) await ctx.addInitScript((ms) => localStorage.setItem('mq:fakeInitMs', String(ms)), opts.initMs);
|
||||
const p = await ctx.newPage();
|
||||
p.on('pageerror', (e) => errors.push(`${name}: ${e.message}`));
|
||||
await p.goto(ORIGIN + '/');
|
||||
@@ -197,6 +198,40 @@ try {
|
||||
await audit(host, 'PC 게임 결과');
|
||||
});
|
||||
|
||||
await step('플레이어 준비 전에 누르기: A→B면 B만 나오고 A는 안 나옴, A→A(멈춤)면 둘 다 안 나옴', async () => {
|
||||
db.query("UPDATE custom_quizzes SET visibility = 'public' WHERE id = ?").run(quizId);
|
||||
// players that get ready 5s late, so both taps land before
|
||||
const x = await guestPage('늦은준비1', { initMs: 5000 });
|
||||
const y = await guestPage('늦은준비2', { initMs: 5000 });
|
||||
const rc = await x.evaluate(async () => (await (await fetch('/api/rooms', { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' })).json()).code as string);
|
||||
await x.goto(`${ORIGIN}/r/${rc}`);
|
||||
await x.getByRole('radio', { name: '🆚 이지선다' }).click();
|
||||
await x.getByRole('listbox', { name: '이지선다 퀴즈 목록' }).getByRole('option', { name: /조회수 대결/ }).click();
|
||||
await x.getByText('퀴즈 곡 4곡').waitFor();
|
||||
await y.goto(`${ORIGIN}/r/${rc}`);
|
||||
await x.locator('.pl', { hasText: '늦은준비2' }).waitFor();
|
||||
await x.getByRole('button', { name: '게임 시작' }).click();
|
||||
await Promise.all([x, y].map((p) => p.locator('.duel-card').nth(1).waitFor({ timeout: 8000 })));
|
||||
await card(x, 'A').click();
|
||||
await card(x, 'B').click();
|
||||
await card(y, 'A').click();
|
||||
await card(y, 'A').click();
|
||||
// nothing has loaded yet (state 1 = playing; the fake's pause shows 2)
|
||||
const before = await x.evaluate(() => [(window as any).mqDuel.state('a'), (window as any).mqDuel.state('b')]);
|
||||
expect(!before.includes(1) && !before.includes(3), `준비 전이 아님 (상태 ${before})`);
|
||||
await x.waitForFunction(() => (window as any).mqDuel.state('b') === 1, null, { timeout: 8000 });
|
||||
await x.waitForTimeout(500);
|
||||
const st = (p: Page) => p.evaluate(() => ({ a: (window as any).mqDuel.state('a'), b: (window as any).mqDuel.state('b') }));
|
||||
const sx = await st(x);
|
||||
const sy = await st(y);
|
||||
expect(sx.a !== 1 && sx.b === 1, `A→B: B만 나와야 함 ${JSON.stringify(sx)}`);
|
||||
expect(sy.a !== 1 && sy.b !== 1, `A→A: 둘 다 멈춰야 함 ${JSON.stringify(sy)}`);
|
||||
expect((await x.locator('.duel-card.playing').count()) === 1 && (await card(x, 'B').getAttribute('class'))!.includes('playing'), 'A→B 화면 표시가 B가 아님');
|
||||
expect((await y.locator('.duel-card.playing').count()) === 0, 'A→A 화면에 재생 중 표시가 남음');
|
||||
await x.context().close();
|
||||
await y.context().close();
|
||||
});
|
||||
|
||||
if (!process.env.E2E_NO_YT) {
|
||||
await step('실제 유튜브: A를 누르면 소리 나게 재생, B를 누르면 A가 멈추고 B 재생, 다시 A는 멈춘 곳부터 이어서', async () => {
|
||||
const r = await host.evaluate(async () => {
|
||||
|
||||
Reference in New Issue
Block a user