// #region ReportDetailIntegrationTest:Module [TYPE Function]
// @SEMANTICS: tests, reports, detail, recovery-guidance, integration
// @PURPOSE: Validate detail-panel behavior for failed reports and recovery guidance visibility.
// @LAYER UI (Tests)
// @RELATION DEPENDS_ON -> [EXT:frontend:ReportDetailPanel]
// @RELATION DEPENDS_ON -> [UnifiedReportsPage]
// @INVARIANT: Failed report detail exposes actionable next actions when available.

import { describe, it, expect } from 'vitest';
import { mixedTaskReports } from './fixtures/reports.fixtures.js';

function buildFailedDetailFixture() {
  const failed = mixedTaskReports.find((item) => item.status === 'failed');
  return {
    report: failed,
    diagnostics: {
      error_context: failed?.error_context || { message: 'Not provided', next_actions: [] }
    },
    next_actions: failed?.error_context?.next_actions || []
  };
}

describe('report detail integration - failed report guidance', () => {
  it('failed fixture includes error context and next actions', () => {
    const detail = buildFailedDetailFixture();

    expect(detail.report).toBeTruthy();
    expect(detail.report.status).toBe('failed');
    expect(detail.diagnostics).toBeTruthy();
    expect(Array.isArray(detail.next_actions)).toBe(true);
    expect(detail.next_actions.length).toBeGreaterThan(0);
  });

  it('next actions are human-readable strings for operator recovery', () => {
    const detail = buildFailedDetailFixture();

    for (const action of detail.next_actions) {
      expect(typeof action).toBe('string');
      expect(action.trim().length).toBeGreaterThan(0);
    }
  });
});

// #endregion ReportDetailIntegrationTest:Module
