feat: 完善芽说英语品牌Logo与图标配置,完成跨平台云端同步服务开发与自动化部署
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:kouyu_english/core/app_state.dart';
|
||||
import 'package:kouyu_english/core/seed_courses.dart';
|
||||
import 'package:kouyu_english/features/dialogue/dialogue_flow.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Dialogue bottom translation chip displays latest partner translation', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
final state = AppState();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: DialoguePage(
|
||||
state: state,
|
||||
onFinished: (_) {},
|
||||
isLessonDialogue: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Initial partner prompt is displayed
|
||||
expect(find.text('Hi! My name is Mia. What’s your name?'), findsOneWidget);
|
||||
|
||||
// Click the bottom "翻译" assist chip
|
||||
final bottomTranslateChip = find.widgetWithText(ActionChip, '翻译');
|
||||
expect(bottomTranslateChip, findsOneWidget);
|
||||
await tester.tap(bottomTranslateChip);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Hint banner displays the latest AI translation
|
||||
expect(find.text('对方说:嗨!我叫 Mia。你叫什么名字?'), findsOneWidget);
|
||||
|
||||
// Message bubble also shows the inline translation
|
||||
expect(find.text('嗨!我叫 Mia。你叫什么名字?'), findsOneWidget);
|
||||
expect(find.text('隐藏翻译'), findsOneWidget);
|
||||
|
||||
// Tap "隐藏翻译" on the bubble to hide it
|
||||
await tester.tap(find.text('隐藏翻译'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('翻译'), findsWidgets); // Both the bottom chip and bubble button
|
||||
});
|
||||
|
||||
testWidgets('Course lesson dialogue resolves translations correctly for lesson prompts', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
final state = AppState()..activeLessonId = 'a0-02';
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: DialoguePage(
|
||||
state: state,
|
||||
onFinished: (_) {},
|
||||
isLessonDialogue: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Lesson a0-02 initial prompt
|
||||
final expectedPrompt = a0Dialogues['a0-02']!.prompts.first;
|
||||
expect(find.text(expectedPrompt), findsOneWidget);
|
||||
|
||||
// Tap bubble's "翻译" button
|
||||
final bubbleTranslateBtn = find.text('翻译').first;
|
||||
await tester.tap(bubbleTranslateBtn);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Check translation is shown
|
||||
final expectedTranslation = a0Dialogues['a0-02']!.translations.first;
|
||||
expect(find.text(expectedTranslation), findsOneWidget);
|
||||
expect(find.text('隐藏翻译'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user