<?php

it('keeps booked vehicle search metadata aligned with filtered pending order bookings', function (): void {
    $routeFile = app_path('routes/vehiclesRoute.php');
    expect(is_file($routeFile))->toBeTrue();

    $code = (string) file_get_contents($routeFile);
    $normalized = preg_replace('/\s+/', ' ', $code);

    expect($normalized)->toContain("\$booking_lookup_filters = ['order_id' => null, 'deleted_at' => null, ...\$booked_filters];");
    expect($normalized)->toContain("\$booking = self::getPendingOrderBookingSummaryByPlate(\$reg, \$booking_lookup_filters);");
    expect($normalized)->toContain("'booking_datetime' => \$booking_datetime,");
    expect($normalized)->toContain("\$fields = ['id', 'customer_number', 'reference', 'note', 'datetime'];");
    expect($normalized)->toContain("'reg_1' => \$reg, ...\$filters");
    expect($normalized)->toContain("'reg_2' => \$reg, ...\$filters");
    expect($normalized)->toContain("\$left_has_datetime = self::hasPendingOrderBookingSummaryDatetime(\$left);");
    expect($normalized)->toContain('return $right_has_datetime <=> $left_has_datetime;');
    expect($normalized)->toContain("return trim((string)(\$booking['datetime'] ?? '')) !== '';");
});
