컴퓨터 난이도 1~60단계·방장 선택·판마다 변화·운, 공정성 확인에 표기, 업데이트 알림 팝업
- 난이도 1~60(쉬움 1~20·보통 21~40·어려움 41~60): 넣을 때 랜덤, 방장이 대기실에서 [랜덤][쉬움][보통][어려움] 선택(botLevel) → 범위 안 무작위 - 다음 판마다 -2~+2, 처음 단계 ±5·같은 범위 안(drift); 말투는 처음 단계(>30 존댓말) - humanBest 확률을 단계별로 보간(BOT_PLAY_ANCHORS: 1·10·30·50·60) - 운(-1~+1): 카드·주사위 게임에서 시작 전에 시드 후보 1~5개를 작업 스레드에서 끝까지 둬 보고 운에 맞는 것을 고름(luck.ts, luck-worker.ts). 해시 공개는 그대로 - 결과 화면 공정성 확인에 컴퓨터별 단계·운, 섞어 본 후보 수 - 업데이트 알림: 빌드 ID meta + /api/version + welcome.build → 상단 팝업 [지금 새로고침하기] [✕] - 문서 03·04 §5.1·06 §12·07 §11.1·09 §9.1, 테스트(bot-level.room, luck, version, e2e bots·pwa) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -172,6 +172,11 @@ try {
|
||||
await seats.getByText('컴퓨터 3').waitFor();
|
||||
await seats.getByRole('button', { name: '컴퓨터 3 빼기' }).click();
|
||||
await seats.getByText('컴퓨터 3').waitFor({ state: 'detached' });
|
||||
// Difficulty per computer (docs/06 §12): 랜덤 at first, the host picks 쉬움.
|
||||
const level = seats.getByRole('group', { name: '컴퓨터 2 난이도' });
|
||||
if ((await level.getByRole('button', { name: '랜덤' }).getAttribute('aria-pressed')) !== 'true') throw new Error('a new computer is not 랜덤');
|
||||
await level.getByRole('button', { name: '쉬움' }).click();
|
||||
await b.waitForFunction(() => document.querySelector('[aria-label="컴퓨터 2 난이도"] [aria-pressed="true"]')?.textContent === '쉬움');
|
||||
await b.screenshot({ path: join(SHOTS, 'bots-3-lobby-phone.png'), fullPage: true });
|
||||
});
|
||||
|
||||
@@ -249,6 +254,12 @@ try {
|
||||
await b.getByRole('button', { name: '🤖 컴퓨터와 연습하기' }).click();
|
||||
await b.waitForURL(/\/r\/\d{6}$/);
|
||||
await b.getByLabel('자리').getByText('컴퓨터 1').waitFor();
|
||||
await b.getByRole('group', { name: '컴퓨터 1 난이도' }).getByRole('button', { name: '어려움' }).click();
|
||||
await b.waitForFunction(() => document.querySelector('[aria-label="컴퓨터 1 난이도"] [aria-pressed="true"]')?.textContent === '어려움');
|
||||
// The best luck: the server plays out 5 shuffles on its worker before the game (docs/04 §5.1).
|
||||
const room = app.rooms.get(codeOf(b))!;
|
||||
const bot = room.seatedIds().find((u) => u.startsWith('bot:'))!;
|
||||
room.botProfiles[bot]!.luck = 1;
|
||||
await b.getByRole('button', { name: '▶ 게임 시작' }).click();
|
||||
await b.getByRole('button', { name: '🏳 기권' }).click();
|
||||
await b.getByRole('button', { name: '기권하기' }).click();
|
||||
@@ -259,6 +270,12 @@ try {
|
||||
if (ranks.length !== 2 || scores.length !== 2 || !scores.every((t) => /^\d+점$/.test(t))) {
|
||||
throw new Error(`ranks ${JSON.stringify(ranks)} scores ${JSON.stringify(scores)}`);
|
||||
}
|
||||
// Fairness check: the computer's level and luck in this game, and the shuffles tried for its luck.
|
||||
await result.getByText('공정성 확인').click();
|
||||
const fair = await result.locator('details').innerText();
|
||||
if (!/컴퓨터 1: 난이도 (4[1-9]|5\d|60)단계 \(어려움\) · 운 아주 좋음/.test(fair) || !fair.includes('미리 섞어 본 5가지')) throw new Error(`fairness: ${fair}`);
|
||||
await result.getByRole('button', { name: '내 브라우저에서 직접 확인하기' }).click();
|
||||
await result.getByText('✓ 일치해요.').waitFor();
|
||||
await Bun.sleep(400); // let the sheet finish sliding in
|
||||
await b.screenshot({ path: join(SHOTS, 'bots-5-yacht-result-phone.png') });
|
||||
console.log(` yacht result: ${ranks.map((r, i) => `${r} ${scores[i]}`).join(', ')}`);
|
||||
|
||||
@@ -176,6 +176,46 @@ try {
|
||||
assert((await card.count()) === 0, 'dismissed card came back');
|
||||
await ios.close();
|
||||
});
|
||||
|
||||
await step('사이트 업데이트: 상단 팝업 → ✕로 닫으면 다음 업데이트까지 안 보임 → 새로고침', async () => {
|
||||
const ctx = await browser.newContext({ viewport: { width: 390, height: 844 }, locale: 'ko-KR', serviceWorkers: 'block' });
|
||||
const p = await ctx.newPage();
|
||||
const errors: string[] = [];
|
||||
p.on('pageerror', (e) => errors.push(e.message));
|
||||
let served: string | null = null;
|
||||
await p.route('**/api/version', (r) => (served ? r.fulfill({ json: { build: served } }) : r.continue()));
|
||||
const banner = p.getByRole('alert').filter({ hasText: '업데이트 내용이 있습니다.' });
|
||||
const look = () => p.evaluate(() => document.dispatchEvent(new Event('visibilitychange')));
|
||||
await p.goto(ORIGIN);
|
||||
await p.getByText('게임 고르기').waitFor();
|
||||
const mine = await p.locator('meta[name="bg-build"]').getAttribute('content');
|
||||
assert(mine && mine === (await (await fetch(`${ORIGIN}/api/version`)).json()).build, `page build ${mine} ≠ server build`);
|
||||
await look();
|
||||
await p.waitForTimeout(300);
|
||||
assert((await banner.count()) === 0, 'banner without an update');
|
||||
served = 'ffffffffffff';
|
||||
await look();
|
||||
await banner.waitFor();
|
||||
await p.waitForTimeout(400); // slide-in finished
|
||||
await axe(p, 'update banner');
|
||||
await p.screenshot({ path: join(SHOTS, 'pwa-5-update-banner.png') });
|
||||
await banner.getByRole('button', { name: '업데이트 알림 닫기' }).click();
|
||||
await banner.waitFor({ state: 'detached' });
|
||||
await look();
|
||||
await p.waitForTimeout(300);
|
||||
assert((await banner.count()) === 0, 'closed banner came back for the same update');
|
||||
served = 'eeeeeeeeeeee';
|
||||
await look();
|
||||
await banner.waitFor();
|
||||
served = null;
|
||||
await Promise.all([p.waitForEvent('load'), banner.getByRole('button', { name: '지금 새로고침하기' }).click()]);
|
||||
await p.getByText('게임 고르기').waitFor();
|
||||
await look();
|
||||
await p.waitForTimeout(300);
|
||||
assert((await banner.count()) === 0, 'banner after refreshing to the current build');
|
||||
assert(!errors.length, errors.join(' / '));
|
||||
await ctx.close();
|
||||
});
|
||||
} catch (e) {
|
||||
failed = true;
|
||||
console.error(e);
|
||||
|
||||
Reference in New Issue
Block a user