import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ot_movil/models/work_order.dart';
import 'package:ot_movil/screens/work_order_screen.dart';

void main() {
  testWidgets('muestra el costo de mano de obra al final de la OT', (
    tester,
  ) async {
    final now = DateTime(2026, 7, 25, 18);
    const details = WorkOrderDetails(
      client: 'Cliente de prueba',
      phone: '+56 9 1234 5678',
      address: 'Av. Principal 123',
    );
    final order = WorkOrder(
      id: 'order-1',
      title: 'Mantención preventiva',
      createdAt: now,
      updatedAt: now,
      completedAt: now,
      status: WorkOrderStatus.completed,
      details: details,
      laborCost: 40000,
    );

    await tester.pumpWidget(
      MaterialApp(
        home: WorkOrderScreen(order: order, details: details),
      ),
    );

    await tester.dragUntilVisible(
      find.byKey(const Key('labor-cost-field')),
      find.byType(ListView),
      const Offset(0, -300),
    );
    final laborField = tester.widget<TextFormField>(
      find.byKey(const Key('labor-cost-field')),
    );
    expect(laborField.controller?.text, '40000');
    expect(find.text('+56 9 1234 5678'), findsNothing);
    expect(find.text('Av. Principal 123'), findsNothing);
  });
}
