fix: two-player lobby deadlock

This commit is contained in:
2026-08-30 23:42:26 +03:00
parent d5eb26d330
commit 93af738e36
9 changed files with 77 additions and 10 deletions
+18
View File
@@ -0,0 +1,18 @@
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const test = require('node:test');
const app = fs.readFileSync(path.join(__dirname, '../../data/app.js'), 'utf8');
test('Play requests the server-authoritative next player slot', () => {
assert.match(app, /join\('player'\)/);
assert.doesNotMatch(app, /info\?\.player1Available \? 'player1'/);
});
test('lobby controls are visible only to player1 and enable when player2 is present', () => {
assert.match(app, /const playerOne = role === 'player1'/);
assert.match(app, /ui\.modeControls\.hidden = !playerOne/);
assert.match(app, /state\.players\[1\]\.trim\(\) !== '' \|\| info\?\.player2Available === false/);
assert.match(app, /const canStart = playerOne && \(state\.mode === 'bot' \|\| playerTwoReady\)/);
});