SOURCE / PINNED RELEASE
Made of little things.
Faultline
- Release
- da1ffaa5624c…
- Author-recorded commit
- 60f5f03189db…
- License
- LICENSE
- Author’s source reference
- nostr://npub182jczunncwe0jn6frpqwq3e0qjws7yqqnc3auccqv9nte2dnd63scjm4rf/wss%3A%2F%2Fgit.napplet.soy%2F/n-6932b12c78c
Archive hash verified: 5a2e0492417ec4e7…. The source-to-build association is the author’s claim; it has not been independently rebuilt.
// Runs in soyLI's disposable local room service and independent browser contexts.
export default async ({ players, check, measure, diagnostics, network }) => {
const [host, ...guests] = players;
const button = (player, name) => player.frame.getByRole('button', { name, exact: true });
try {
const guest = guests[0],
office = players.length === 2,
roomTitle = office ? /North Annex.*8/ : /Alder Ridge.*8/;
await button(guest, 'Settings').click();
await guest.frame.getByLabel('Custom name').fill('Maple');
await button(guest, 'Done').click();
if (office) {
await button(host, 'Next battlefield').click();
await button(host, 'Next battlefield').click();
} else await button(host, 'Previous battlefield').click();
await button(host, 'Create room').click();
await host.frame.getByLabel('Game mode').selectOption('team');
await button(host, 'Open lobby').click();
check('host can start alone', await button(host, 'Start match').isEnabled());
await Promise.all(
guests.map(async (g) => {
await button(g, 'Browse rooms').click();
await g.frame.getByRole('button', { name: roomTitle }).click();
await g.frame.getByText('Waiting for the host to start.').waitFor({ timeout: 55000 });
}),
);
await host.frame.getByText(/Maple · (Amber|Slate)/).waitFor();
check('guest alias is visible in the team lobby', true);
await host.frame
.locator('.roster-row')
.filter({ hasText: 'Maple' })
.getByText(/^\d+ ms$/)
.waitFor({ timeout: 35000 });
check('host measures guest ping in the lobby', true);
await button(host, 'Start match').click({ timeout: 60000 });
await Promise.all(
players.map((p) =>
p.frame.waitForFunction(() => document.querySelector('#scene').dataset.remote?.length > 0),
),
);
check(
'all players have a negotiated peer',
(await diagnostics()).every((rows) => rows.some((r) => r.state === 'connected')),
);
await network({ latencyMs: office ? 30 : 50, jitterMs: office ? 20 : 15, seed: 3,
lossRatio: 0.04, retransmitMs: 150 });
await guest.frame.evaluate(() => {
const scene = document.querySelector('#scene');
const metrics = window.renderClockSample = { frames: 0, backwards: 0, previous: -1 };
const sample = () => {
const tick = Number(scene.dataset.viewTick);
if (Number.isFinite(tick)) {
if (tick < metrics.previous) metrics.backwards++;
metrics.previous = tick;
metrics.frames++;
}
if (metrics.frames < 300) requestAnimationFrame(sample);
};
requestAnimationFrame(sample);
});
await guest.page.keyboard.down('Tab');
await guest.frame
.locator('#scoreboard:not([hidden]) tr')
.filter({ hasText: 'Maple' })
.getByText(/^\d+ ms$/)
.waitFor();
await guest.page.keyboard.up('Tab');
await guest.frame.locator('#scoreboard').waitFor({ state: 'hidden' });
check('holding Tab shows measured pings in game and releasing it hides the list', true);
await host.frame.getByText(/Amber 0 \/ Slate 0/).waitFor();
if (office) {
await host.frame.evaluate(() => {
const scene = document.querySelector('#scene');
for (const type of ['keydown', 'keyup'])
scene.dispatchEvent(new KeyboardEvent(type, { code: 'KeyF', bubbles: true }));
});
await Promise.all(
players.map((p) =>
p.frame.waitForFunction(() => +document.querySelector('#scene').dataset.glass > 0, null, {
timeout: 6000,
}),
),
);
check('authoritative broken office window reaches every peer', true);
} else {
await guest.frame.waitForFunction(() =>
document
.querySelector('#scene')
.dataset.position.split(',')
.some((v) => Math.abs(+v) > 26),
);
check('woodland player positions replicate beyond the original map bounds', true);
}
if (office) {
// Both the host's authoritative renderer and a guest's snapshot playout.
for (const [actor, observer] of [[guest,host],[host,guest]]) {
const seat = await actor.frame.locator('#scene').getAttribute('data-seat');
const key = (type, code) => actor.frame.evaluate(([type,code]) =>
window.dispatchEvent(new KeyboardEvent(type,{code,bubbles:true})),[type,code]);
const see = (sign, duck) => observer.frame.waitForFunction(([id,sign,duck]) =>
document.querySelector('#scene').dataset.remote.split('|').map(row=>row.split(','))
.some(([other,,,pitch,stance]) => other===id && Number(pitch)*sign>0.4 && Number(stance)===duck),
[seat,sign,duck], {timeout:10000});
await key('keydown','KeyC'); await key('keyup','KeyC');
await key('keydown','ArrowUp');
try { await see(1,1); } finally { await key('keyup','ArrowUp'); }
await key('keydown','KeyC'); await key('keyup','KeyC');
await key('keydown','ArrowDown');
try { await see(-1,0); } finally { await key('keyup','ArrowDown'); }
}
check('peers see each other aim up and crouch, then stand and aim down', true);
}
await guest.frame.evaluate(() =>
document
.querySelector('#scene')
.dispatchEvent(new KeyboardEvent('keydown', { code: 'KeyE', bubbles: true })),
);
await guest.frame.waitForFunction(() => +document.querySelector('#scene').dataset.lean > 60);
await guest.frame.evaluate(() =>
document
.querySelector('#scene')
.dispatchEvent(new KeyboardEvent('keyup', { code: 'KeyE', bubbles: true })),
);
await guest.frame.waitForFunction(() => Number(document.querySelector('#scene').dataset.ack) > 125);
const loadPlayers = [host, ...guests.slice(1)];
const load = async (phase) =>
Promise.all(
loadPlayers.map((p) =>
p.frame.evaluate((phase) => {
const el = document.querySelector('#scene');
for (const code of ['KeyW', 'KeyF', 'ArrowUp'])
el.dispatchEvent(new KeyboardEvent(phase, { code, bubbles: true }));
}, phase),
),
);
await load('keydown');
const samples = [];
for (let trial = 0; trial < 5; trial++)
samples.push(
await guest.frame.evaluate(async () => {
await new Promise((resolve) => setTimeout(resolve, 240));
const el = document.querySelector('#scene');
const key = (type, code) => el.dispatchEvent(new KeyboardEvent(type, { code, bubbles: true }));
const old = { position: el.dataset.position, shots: el.dataset.shots, aim: el.dataset.aim },
times = {};
await new Promise((resolve) => requestAnimationFrame(resolve));
const start = performance.now();
for (const k of ['KeyD', 'ArrowLeft', 'KeyF']) key('keydown', k);
try {
await new Promise((resolve, reject) => {
const poll = () => {
for (const field of Object.keys(old))
if (times[field] === undefined && el.dataset[field] !== old[field])
times[field] = performance.now() - start;
if (Object.keys(times).length === 3) resolve();
else if (performance.now() - start > 2000)
reject(
Error('Missing guest feedback ' + JSON.stringify(old) + ' ' + JSON.stringify(times)),
);
else requestAnimationFrame(poll);
};
requestAnimationFrame(poll);
});
await new Promise((r) => setTimeout(r, 200));
} finally {
for (const k of ['KeyD', 'ArrowLeft', 'KeyF']) key('keyup', k);
}
return times;
}),
);
await load('keyup');
for (const field of ['position', 'aim', 'shots']) {
const values = samples.map((sample) => sample[field]).sort((a, b) => a - b);
measure(
'guest rendered ' + field + ' (median of 5, maximum ' + Math.round(values[4]) + ' ms)',
values[2],
50,
);
}
await guest.frame.waitForFunction(() => Number(document.querySelector('#scene').dataset.ack) > 10);
const state = await guest.frame.locator('#scene').getAttribute('data-position');
const remoteId = Number(await guest.frame.locator('#scene').getAttribute('data-seat'));
await host.frame.waitForFunction(
({ state, remoteId }) => {
const [x, z] = state.split(',').map(Number);
return document
.querySelector('#scene')
.dataset.remote.split('|')
.some((v) => {
const [id, rx, rz] = v.split(',').map(Number);
return id === remoteId && Math.hypot(x - rx, z - rz) < 0.55;
});
},
{ state, remoteId },
{ timeout: 7000 },
);
check('host and guest agree on the moved player', true);
const clock = await guest.frame.evaluate(() => window.renderClockSample);
check('remote playback clock advances without a backward frame under jitter and loss',
clock.frames >= 60 && clock.previous > 0 && clock.backwards === 0);
const waitForBlasts = () =>
[host, guest].map((p) =>
p.frame.waitForFunction(
() => Number(document.querySelector('#scene').dataset.blasts) > 0,
null,
{
timeout: 8000,
},
),
);
await guest.frame.evaluate(() => {
const scene = document.querySelector('#scene');
scene.dispatchEvent(new KeyboardEvent('keydown', { code: 'KeyG', bubbles: true }));
});
await guest.frame.waitForFunction(() =>
document.querySelector('#game-message').textContent.includes('Frag'),
);
const blasts = waitForBlasts();
await guest.frame.evaluate(() =>
document
.querySelector('#scene')
.dispatchEvent(new KeyboardEvent('keyup', { code: 'KeyG', bubbles: true })),
);
await Promise.all(blasts);
check('guest grenade detonates on the host and renders on both screens', true);
await button(guest, 'Open match menu').click();
await button(guest, 'Change loadout').click();
await guest.frame.getByRole('combobox', { name: /Secondary/ }).selectOption({ label: 'Comet R1' });
await button(guest, 'Equip and resume').click();
const key = async (type, code) =>
guest.frame.evaluate(
([type, code]) =>
document
.querySelector('#scene')
.dispatchEvent(new KeyboardEvent(type, { code, bubbles: true })),
[type, code],
);
await key('keydown', 'Digit2');
await key('keyup', 'Digit2');
await guest.frame.waitForFunction(
() =>
document.querySelector('#gun-label').textContent.includes('Comet R1') &&
document.querySelector('#ammo').textContent === '1 / 1',
);
await Promise.all(
[host, guest].map((p) =>
p.frame.waitForFunction(() => Number(document.querySelector('#scene').dataset.blasts) === 0),
),
);
const rocketBlasts = waitForBlasts();
await key('keydown', 'KeyF');
await key('keyup', 'KeyF');
await Promise.all(rocketBlasts);
check(
'guest changes secondary from the match menu and both peers render the rocket detonation',
true,
);
await button(guest, 'Open match menu').click();
await button(guest, 'Leave room').click();
await button(guest, 'Browse rooms').click();
await guest.frame.getByRole('button', { name: roomTitle }).click();
await guest.frame.waitForFunction(
() =>
!document.getElementById('game').hidden &&
Number(document.getElementById('scene').dataset.ack) > 0,
null,
{ timeout: 35000 },
);
if (office)
await guest.frame.waitForFunction(() => +document.querySelector('#scene').dataset.glass > 0);
check(
office
? 'guest can rejoin a running round with its broken glass state'
: 'guest can rejoin the woodland round',
true,
);
await button(host, 'Open match menu').click();
await button(host, 'Leave room').click();
await Promise.all(
guests.map((g) =>
g.frame.getByRole('heading', { name: 'Room closed' }).waitFor({ timeout: 17000 }),
),
);
check('host departure ends the round for the remaining players', true);
} catch (error) {
const states = await Promise.all(
players.map((p) =>
p.frame
.evaluate(() => ({
dialog: document.querySelector('dialog[open]')?.innerText,
hud: document.querySelector('#network-label')?.textContent,
}))
.catch(() => null),
),
);
throw new Error(String(error) + ' ' + JSON.stringify(states));
}
};
