import test from 'node:test'; import assert from 'node:assert/strict'; import { normalizeNearIntentsStatus } from '../src/core/near-intents-status.mjs'; const postEnumsResponse = { post_enums: [ { id: 'PSCS3IV', post_enum_type: 'status', name: 'investigating' }, { id: 'PP34365', post_enum_type: 'status', name: 'detected' }, { id: 'P8TG2TF', post_enum_type: 'status', name: 'resolved' }, { id: 'P187122', post_enum_type: 'severity', name: 'minor' }, { id: 'PCIGMKW', post_enum_type: 'severity', name: 'degraded' }, ], }; const servicesResponse = { services: [ { id: 'PXQFSY1', name: 'Cross-Chain Bridging', display_name: 'Cross-Chain Bridging' }, { id: 'PLT88AT', name: 'Solvers Network', display_name: 'Solvers Network' }, ], }; test('NEAR Intents status normalizer exposes current quoting disruption as upstream paused evidence', () => { const normalized = normalizeNearIntentsStatus({ observedAt: '2026-04-16T12:40:00.000Z', servicesResponse, postEnumsResponse, postsResponse: { posts: [{ id: 'PM7LK6N', title: '1Click Quoting is temporarily stopped', post_type: 'incident', latest_update: { status_id: 'PSCS3IV', severity_id: 'P187122', reported_at: 1776342420000, impacts: [{ service_id: 'PXQFSY1', severity_id: 'PCIGMKW' }], message: '

The protocol is paused due to a security incident. Swaps are paused.

', }, }], }, }); assert.equal(normalized.source, 'near_intents_status_page'); assert.equal(normalized.status, 'disrupted'); assert.equal(normalized.label, 'upstream paused'); assert.equal(normalized.quoting_stopped, true); assert.deepEqual(normalized.affected_services, ['Cross-Chain Bridging']); assert.equal(normalized.current_incident_count, 1); assert.equal(normalized.current_incidents[0].status, 'investigating'); assert.equal(normalized.current_incidents[0].severity, 'minor'); assert.equal(normalized.current_incidents[0].impacts[0].severity, 'degraded'); assert.match(normalized.decisive_reason, /1Click Quoting is temporarily stopped/); assert.match(normalized.decisive_reason, /Swaps are paused/); }); test('resolved NEAR Intents status posts do not make the relay look disrupted', () => { const normalized = normalizeNearIntentsStatus({ observedAt: '2026-04-16T13:00:00.000Z', servicesResponse, postEnumsResponse, postsResponse: { posts: [{ id: 'PM7LK6N', title: '1Click Quoting is temporarily stopped', post_type: 'incident', latest_update: { status_id: 'P8TG2TF', severity_id: 'P187122', reported_at: 1776346020000, impacts: [{ service_id: 'PXQFSY1', severity_id: 'PCIGMKW' }], message: '

Resolved.

', }, }], }, }); assert.equal(normalized.status, 'operational'); assert.equal(normalized.label, 'operational'); assert.equal(normalized.quoting_stopped, false); assert.equal(normalized.current_incident_count, 0); assert.match(normalized.decisive_reason, /no active incident/i); });