feat(login): randomize Russian welcome headlines
This commit is contained in:
@@ -48,6 +48,21 @@ test("frontend name suggestions randomize both words and remain bounded", () =>
|
||||
assert.doesNotMatch(script, /suggest_name|name_suggestion/);
|
||||
});
|
||||
|
||||
test("login headline selection is randomizable, Russian, and has a fallback", () => {
|
||||
assert.ok(player.LOGIN_HEADLINES.length >= 8);
|
||||
const selected = player.randomLoginHeadline(() => 5);
|
||||
assert.deepEqual(selected, {first: "Крот сказал", highlight: "что это срез"});
|
||||
assert.equal(player.randomLoginHeadline(() => -1), player.LOGIN_HEADLINES[0]);
|
||||
for (const headline of player.LOGIN_HEADLINES) {
|
||||
assert.match(headline.first, /[А-Яа-яЁё]/u);
|
||||
assert.match(headline.highlight, /[А-Яа-яЁё]/u);
|
||||
}
|
||||
|
||||
const script = fs.readFileSync(path.join(project, "web/player.js"), "utf8");
|
||||
assert.match(script, /renderWelcomeHeadline\(randomLoginHeadline\(\)\)/);
|
||||
assert.match(script, /title\.replaceChildren/);
|
||||
});
|
||||
|
||||
test("command envelopes contain intentions rather than client-owned state", () => {
|
||||
const move = player.createEnvelope("move", 7, "move-7", {direction: "west"});
|
||||
assert.deepEqual(move, {v: 1, type: "move", seq: 7, requestId: "move-7", payload: {direction: "west"}});
|
||||
|
||||
Reference in New Issue
Block a user