Known improvements: dedup HUD letters-bar + validare stil import

Pasa de igiena (T8/T5/D8). Majoritatea erau deja livrate (persist guard D12,
esc/letter D13, validare 0 puzzle). Reale ramase:

- updateHud arcade/point NU erau identice (arcade: vieti/dusmani/bombe/raza;
  point: obiecte). Partea duplicata reala (scor + bara litere castigate) extrasa
  in SNIP.hudJs -> hudLetters(isSolved); isSolved(j) difera per motor
  (doorsSolved vs solvedFlags). Injectat in ambele; demo-uri regenerate.
- Stil top-level invalid la import: TOP_STYLES guard -> fallback classic + alert;
  idem la load din storage corupt. Test nou (smoke 28/28).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-06-13 19:36:41 +00:00
parent bfe9be28d7
commit 16cd521430
7 changed files with 107 additions and 38 deletions

View File

@@ -404,6 +404,34 @@ test.describe('Edge cases @regresie', () => {
expect(errors, 'Erori consola:\n' + errors.join('\n')).toHaveLength(0);
});
test('builder: JSON cu stil top-level necunoscut → fallback classic + avertisment (T5/D8)', async ({ page }) => {
const errors = trackErrors(page);
let warned = false;
page.on('dialog', d => { if (/stil necunoscut/i.test(d.message())) warned = true; d.accept(); });
await page.goto(fileURL('escape-builder.html'));
const tmpPath = join(ROOT, 'tests', '.tmp-invalid-style.json');
writeFileSync(tmpPath, JSON.stringify({
title: 'Test stil', style: 'banana', color: '#6d28d9', charName: 'X',
story: 'S', finalMessage: 'F',
puzzles: [{ title: 'P1', type: 'free', question: 'Q?', answer: 'A', tfAnswer: 'Adevarat', choices: '', hint: '', letter: 'X' }]
}));
try {
await page.locator('#fileLoad').setInputFiles(tmpPath);
await page.waitForTimeout(600);
} finally {
unlinkSync(tmpPath);
}
// Fallback la classic + avertisment + builder functional
await expect(page.locator('#gStyle')).toHaveValue('classic');
expect(warned, 'asteptam un alert despre stilul necunoscut').toBe(true);
await expect(page.locator('#addPuzzle')).toBeVisible();
expect(errors, 'Erori consola:\n' + errors.join('\n')).toHaveLength(0);
});
});
// ═══════════════════════════════════════════════════════════════════════