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
11 changes: 7 additions & 4 deletions lib/src/host/remote/test-burrow-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ const HOUR_MS = 60 * 60_000;
* first paired an hour ago and connected now; each after it paired a day
* before the last and was last seen two hours after pairing. Relative to now,
* like {@link setupQrResult}, so "Last seen" reads the same in every story.
* A caller that runs before a story pins the clock (a `parameters` literal is
* built at module load) passes its pinned `now`.
*/
export function pairedDevices(count: number): PairedDevice[] {
const now = Date.now();
export function pairedDevices(count: number, now = Date.now()): PairedDevice[] {
return Array.from({ length: count }, (_, index) => {
const pairedAt = now - HOUR_MS - index * 24 * HOUR_MS;
return {
Expand All @@ -176,7 +177,10 @@ export function pairedDevices(count: number): PairedDevice[] {
* one's pairing, the second's session that went direct and ended, a one-time
* connection, an unpaired phone refused, and the first's session open now.
*/
export function accessLogEntries(devices: PairedDevice[] = pairedDevices(2)): AccessLogEntry[] {
export function accessLogEntries(
devices: PairedDevice[] = pairedDevices(2),
now = Date.now(),
): AccessLogEntry[] {
const entries: AccessLogEntry[] = [];
for (const [index, { label: device, id: deviceId, pairedAt, lastSeenAt }] of devices.entries()) {
entries.push({ at: pairedAt, event: 'paired', device, deviceId });
Expand All @@ -192,7 +196,6 @@ export function accessLogEntries(devices: PairedDevice[] = pairedDevices(2)): Ac
{ at: lastSeenAt, event: 'ended', device, deviceId, path: 'direct', durationMs: 4 * 60_000 },
);
}
const now = Date.now();
const oneTime = 'Dormouse Pocket (browser)';
entries.push(
{ at: now - 3 * HOUR_MS, event: 'one-time-connected', device: oneTime, path: 'direct' },
Expand Down
8 changes: 5 additions & 3 deletions lib/src/stories/RemoteControlSection.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ function RemoteControlStory() {
}

/** The clock every story here reads. A setup code encodes its expiry, so a real
* clock would draw a different QR on every run. */
* clock would draw a different QR on every run. `beforeEach` pins it only
* around render: a `parameters` literal is built at module load, under the
* real clock, so a timestamp there must use `STORY_NOW` itself. */
const STORY_NOW = Date.UTC(2026, 0, 1);

const meta: Meta<typeof RemoteControlStory> = {
Expand Down Expand Up @@ -342,7 +344,7 @@ export const PairedPhonesAndAccessLog: Story = {
parameters: {
primedBurrow: {
status: enrolledStatus({ pairedClients: 2 }),
accessLog: accessLogEntries(pairedDevices(2)),
accessLog: accessLogEntries(pairedDevices(2, STORY_NOW), STORY_NOW),
},
docs: { story: { height: '620px' } },
},
Expand Down Expand Up @@ -703,7 +705,7 @@ export const OneTimeEndedNetworkNotAllowed: Story = {
oneTime: {
status: 'ended',
reason: 'network-not-allowed',
refusal: { at: Date.now(), kind: 'path-refused', end: 'remote', address: '172.58.12.9', addressSource: 'observed' },
refusal: { at: STORY_NOW, kind: 'path-refused', end: 'remote', address: '172.58.12.9', addressSource: 'observed' },
},
},
docs: { story: { height: '360px' } },
Expand Down
Loading