Files
git.stella-ops.org/tests/fixtures/micro/micro-fixtures.ts
StellaOps Bot 8768c27f30
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Signals DSSE Sign & Evidence Locker / sign-signals-artifacts (push) Has been cancelled
Signals DSSE Sign & Evidence Locker / verify-signatures (push) Has been cancelled
Add signal contracts for reachability, exploitability, trust, and unknown symbols
- Introduced `ReachabilityState`, `RuntimeHit`, `ExploitabilitySignal`, `ReachabilitySignal`, `SignalEnvelope`, `SignalType`, `TrustSignal`, and `UnknownSymbolSignal` records to define various signal types and their properties.
- Implemented JSON serialization attributes for proper data interchange.
- Created project files for the new signal contracts library and corresponding test projects.
- Added deterministic test fixtures for micro-interaction testing.
- Included cryptographic keys for secure operations with cosign.
2025-12-05 00:27:00 +02:00

90 lines
2.4 KiB
TypeScript

/**
* Micro-interaction test fixtures with deterministic seeds (MI8)
*
* Usage:
* - Import these constants in Storybook stories and Playwright tests
* - Use frozenTimestamp for all date operations
* - Use rngSeed for any randomized content
*/
// Frozen timestamp: 2025-12-04T12:00:00Z (as per advisory)
export const FROZEN_TIMESTAMP = new Date('2025-12-04T12:00:00.000Z');
export const FROZEN_TIMESTAMP_MS = 1733313600000;
// Fixed RNG seed as per advisory: 0x5EED2025
export const RNG_SEED = 0x5EED2025;
// Deterministic UUID generator (seeded)
export function seededUuid(seed: number = RNG_SEED, index: number = 0): string {
const hash = ((seed + index) * 2654435761) >>> 0;
const hex = hash.toString(16).padStart(8, '0');
return `${hex.slice(0, 8)}-${hex.slice(0, 4)}-4${hex.slice(1, 4)}-8${hex.slice(4, 7)}-${hex}0000`.slice(0, 36);
}
// Skeleton state fixture
export const skeletonFixture = {
showAfterMs: 400,
loadingDurationMs: 1200,
state: 'loading' as const,
timestamp: FROZEN_TIMESTAMP,
};
// Error state fixture
export const errorFixture = {
code: 'UI_ERR_001',
message: 'Failed to load data',
retryAvailable: true,
timestamp: FROZEN_TIMESTAMP,
correlationId: seededUuid(RNG_SEED, 1),
};
// Offline state fixture
export const offlineFixture = {
isOffline: true,
lastOnline: new Date(FROZEN_TIMESTAMP_MS - 300000), // 5 minutes ago
cachedDataAge: 'less than 1 hour',
timestamp: FROZEN_TIMESTAMP,
};
// Toast/snackbar fixture
export const toastFixture = {
id: seededUuid(RNG_SEED, 2),
type: 'info' as const,
message: 'Changes saved successfully',
undoAvailable: true,
undoWindowMs: 8000,
timestamp: FROZEN_TIMESTAMP,
};
// Reduced motion test config
export const reducedMotionConfig = {
enabled: true,
emulateQuery: true,
dataAttribute: 'data-reduce-motion',
dataValue: '1',
};
// Playwright/Storybook timer config
export const timerConfig = {
useFakeTimers: true,
now: FROZEN_TIMESTAMP_MS,
shouldAdvanceTime: false,
};
// Sample telemetry event
export const sampleTelemetryEvent = {
schema_version: 'v1.0',
event_type: 'ui.micro.interaction',
timestamp: FROZEN_TIMESTAMP.toISOString(),
tenant_id: 'test-tenant',
surface: 'dashboard',
component: 'button',
action: 'click',
latency_ms: 45,
outcome: 'success',
reduced_motion: false,
offline_mode: false,
error_code: null,
correlation_id: seededUuid(RNG_SEED, 3),
};