Files
999/test/g4f_live_providers_test.dart
Alma Alexyz fbf04d90db feat: embed a Flutter G4F client with Cronet, cookie jar, and origin WebView
Port the Oracle off the Python g4f container onto on-device providers: Chromium HTTP via Cronet, a shared cookie session, IterList retry, hosted OpenAI-compat aggregators, and same-origin WebView fallbacks instead of CORS fetch.
2026-09-01 22:05:38 +05:00

38 lines
1.4 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:words999/g4f/g4f.dart';
void main() {
const messages = [
Message(role: Role.system, content: 'Отвечай одним словом.'),
Message(role: Role.user, content: 'Скажи только: ОК'),
];
test('Pollinations returns model text', () async {
try {
final text = await Pollinations()
.createAsyncGenerator('openai-fast', messages, stream: false)
.join();
expect(text.trim().length, greaterThan(1));
expect(looksLikeGarbage(text), isFalse);
} catch (e) {
// Anonymous Pollinations is rate-limited / paywalled from some IPs.
expect(e.toString().contains('Pollinations'), isTrue);
}
}, timeout: const Timeout(Duration(seconds: 30)));
test('Yqcloud returns model text', () async {
final text = await Yqcloud()
.createAsyncGenerator(G4FModels.gpt4, messages, stream: false)
.join();
expect(text.trim().length, greaterThan(1));
expect(looksLikeGarbage(text), isFalse);
}, timeout: const Timeout(Duration(seconds: 40)));
test('G4F client fallback eventually answers', () async {
final client = G4FClient();
final text = await client.chat.completions.create(messages: messages);
expect(text.trim().length, greaterThan(1));
expect(looksLikeGarbage(text), isFalse);
}, timeout: const Timeout(Duration(seconds: 90)));
}