Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions tests/browser/audio-check.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { FakeStream, FakeTrack, settle } from "./fake-media.js";
import { loadInterview, read } from "./source.js";

import {
MIC_CONFIRM_FRAMES,
Expand Down Expand Up @@ -106,6 +107,41 @@ test("hearing nothing keeps the room closed even with a working microphone", ()
assert.equal(state.blocker, "output");
});

test("the Sound step reads the same before and after the preflight paints it", () => {
// The candidate may confirm without playing anything, so no line may read
// as if the test sound were required. The step text is written twice, once
// in the markup and again by `paintPreflight` on every refresh, and the two
// drifting apart would change the instruction under the candidate's eyes.
const markup = /id="audio-output-state"[^>]*>([^<]*)</.exec(
read("web/interview.html"),
)[1];
const nodes = new Proxy(
{ audioHeard: {} },
{
get: (target, key) =>
(target[key] ??= { textContent: "", classList: { toggle() {} } }),
},
);
const { paintPreflight } = loadInterview(["paintPreflight"], { nodes });
paintPreflight(
mediaReadiness({ ...passingMedia, outputConfirmed: false }),
null,
);
assert.equal(
nodes.audioOutputState.textContent,
markup.replace(/\s+/g, " ").trim(),
);
assert.equal(
nodes.audioOutputState.textContent,
'play a test sound to check your audio, or click "I heard it" if it already works.',
);
// With output the remaining step, the status line says the same thing.
assert.equal(
nodes.audioStatus.textContent,
'Play the test tone or voice to check your audio, or click "I heard it" if it already works.',
);
});

test("all required media proven opens the room", () => {
const state = mediaReadiness(passingMedia);

Expand Down
3 changes: 2 additions & 1 deletion web/audio-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ export function mediaReadiness({
steps,
ready: false,
blocker: "output",
message: "Play the test tone or voice and confirm you heard it.",
message:
'Play the test tone or voice to check your audio, or click "I heard it" if it already works.',
};
}
return {
Expand Down
3 changes: 2 additions & 1 deletion web/interview.html
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,8 @@ <h3 id="devices-title" class="preflight-section-title">
<span class="step-mark" aria-hidden="true"></span
><strong>Sound</strong> —
<span id="audio-output-state" aria-live="polite"
>play a test sound and confirm you heard it.</span
>play a test sound to check your audio, or click "I heard
it" if it already works.</span
>
</p>
<div class="audio-check-actions">
Expand Down
2 changes: 1 addition & 1 deletion web/interview.js
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@ function paintPreflight(state, hint) {
nodes.audioStatus.textContent = hint || state.message;
nodes.audioOutputState.textContent = state.steps.output
? "Confirmed"
: "play a test sound and confirm you heard it.";
: 'play a test sound to check your audio, or click "I heard it" if it already works.';
nodes.cameraState.textContent = state.cameraSkipped
? `Not used (${state.cameraSkipReason}).`
: state.steps.camera
Expand Down