import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

import 'package:alt_client/src/integrations/socket/alt_socket_client.dart';
import 'package:alt_client/src/integrations/socket/socket_endpoint.dart';

void main() {
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();

  testWidgets('connects to configured ALT API and completes hello handshake', (
    tester,
  ) async {
    const endpoint = AltSocketEndpoint();

    final client = await AltSocketClient.connect(endpoint);
    addTearDown(client.close);

    final response = await client.hello(timeout: const Duration(seconds: 5));

    expect(response.serverName, equals('alt-api'));
    expect(response.serverVersion, equals('dev'));
    expect(response.altProtocolVersion, equals('alt.v1'));
    expect(response.capabilities, contains('hello'));
    expect(response.capabilities, contains('request-response'));
  });
}
