import { describe, it, expect } from 'vitest';
import type { Review, ReviewSummary, SellerReview } from '@alqove/api-client';

describe('Review / ReviewSummary / SellerReview type shape', () => {
  it('exposes is_editable on Review and ReviewSummary', () => {
    const review: Review = {
      id: 'r-1',
      order_item_id: 'oi-1',
      order_id: 'ord-1',
      store_id: 's-1',
      reviewer_user_id: 'u-1',
      rating: 5,
      rating_item_as_described: 5,
      rating_shipping_speed: 5,
      rating_communication: 5,
      rating_packaging: 5,
      title: 'Great',
      body: 'Body that is long enough to satisfy the validation rule.',
      state: 'visible',
      edited_at: null,
      hidden_by_admin_id: null,
      hidden_at: null,
      hide_reason: null,
      is_editable: true,
      photos: [],
      created_at: '2026-05-01T00:00:00Z',
      updated_at: '2026-05-01T00:00:00Z',
    };

    const summary: ReviewSummary = {
      id: 'r-2',
      store_id: 's-1',
      buyer: { name: 'Test Buyer' },
      rating: 4,
      rating_item_as_described: 4,
      rating_shipping_speed: 4,
      rating_communication: 4,
      rating_packaging: 4,
      title: null,
      body: 'Long enough public review body.',
      state: 'visible',
      edited_at: null,
      is_editable: false,
      photos: [],
      created_at: '2026-05-02T00:00:00Z',
    };

    expect(review.is_editable).toBe(true);
    expect(summary.is_editable).toBe(false);
  });

  it('SellerReview extends Review with a report_status block', () => {
    const sellerReview: SellerReview = {
      id: 'r-3',
      order_item_id: 'oi-3',
      order_id: 'ord-3',
      store_id: 's-1',
      reviewer_user_id: 'u-3',
      rating: 2,
      rating_item_as_described: 2,
      rating_shipping_speed: 3,
      rating_communication: 2,
      rating_packaging: 4,
      title: null,
      body: 'Not what I expected from this seller, sadly underwhelming.',
      state: 'visible',
      edited_at: null,
      hidden_by_admin_id: null,
      hidden_at: null,
      hide_reason: null,
      is_editable: false,
      photos: [],
      created_at: '2026-05-03T00:00:00Z',
      updated_at: '2026-05-03T00:00:00Z',
      report_status: {
        count: 1,
        latest_outcome: 'keep',
        latest_state: 'resolved',
      },
    };

    expect(sellerReview.report_status.count).toBe(1);
    expect(sellerReview.report_status.latest_outcome).toBe('keep');
    expect(sellerReview.report_status.latest_state).toBe('resolved');
  });
});
