整个课程和数据UI重新设计版本
This commit is contained in:
@@ -12,11 +12,16 @@ void main() {
|
||||
expect(isSentenceQuery('check in'), isFalse);
|
||||
expect(isSentenceQuery('Where is the subway?'), isTrue);
|
||||
expect(isSentenceQuery("I'd like to check in."), isTrue);
|
||||
expect(isSentenceQuery('This is a longer sentence with more than three words'), isTrue);
|
||||
expect(
|
||||
isSentenceQuery('This is a longer sentence with more than three words'),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
|
||||
test('extractCourseLexiconPhrases finds embedded course lexicon items', () {
|
||||
final matches = extractCourseLexiconPhrases("Hello, nice to meet you, where's the taxi?");
|
||||
final matches = extractCourseLexiconPhrases(
|
||||
"Hello, nice to meet you, where's the taxi?",
|
||||
);
|
||||
expect(matches, isNotEmpty);
|
||||
final words = matches.map((m) => m.word.toLowerCase()).toList();
|
||||
expect(words.any((w) => w.contains('nice to meet you')), isTrue);
|
||||
@@ -49,10 +54,7 @@ void main() {
|
||||
grammarNote: 'would like 语气委婉客气,适合服务场景。',
|
||||
pronunciationTips: 'would like 发音轻柔,check in 发生连读。',
|
||||
phrases: const [
|
||||
PhraseBreakdownItem(
|
||||
phrase: 'would like to',
|
||||
meaning: '想要做某事(委婉)',
|
||||
),
|
||||
PhraseBreakdownItem(phrase: 'would like to', meaning: '想要做某事(委婉)'),
|
||||
PhraseBreakdownItem(
|
||||
phrase: 'check in',
|
||||
meaning: '办理入住',
|
||||
@@ -127,46 +129,62 @@ void main() {
|
||||
});
|
||||
|
||||
group('AppState Sentence Analysis & Review Integration', () {
|
||||
test('caching and retrieving sentence analyses with query normalization', () {
|
||||
final state = AppState();
|
||||
final result = SentenceAnalysisResult(
|
||||
originalText: ' Where is the bus stop? ',
|
||||
translation: '请问公交站在哪里?',
|
||||
sentencePattern: 'Where is + 地点',
|
||||
createdAt: DateTime.now(),
|
||||
);
|
||||
test(
|
||||
'caching and retrieving sentence analyses with query normalization',
|
||||
() {
|
||||
final state = AppState();
|
||||
final result = SentenceAnalysisResult(
|
||||
originalText: ' Where is the bus stop? ',
|
||||
translation: '请问公交站在哪里?',
|
||||
sentencePattern: 'Where is + 地点',
|
||||
createdAt: DateTime.now(),
|
||||
);
|
||||
|
||||
state.cacheSentenceAnalysis(result);
|
||||
state.cacheSentenceAnalysis(result);
|
||||
|
||||
expect(state.sentenceAnalysisFor('where is the bus stop?'), isNotNull);
|
||||
expect(state.sentenceAnalysisFor('WHERE IS THE BUS STOP? '), isNotNull);
|
||||
expect(state.sentenceAnalysisFor('where is the bus stop?')?.translation, '请问公交站在哪里?');
|
||||
expect(state.sentenceAnalysisFor('where is the bus stop?'), isNotNull);
|
||||
expect(
|
||||
state.sentenceAnalysisFor('WHERE IS THE BUS STOP? '),
|
||||
isNotNull,
|
||||
);
|
||||
expect(
|
||||
state.sentenceAnalysisFor('where is the bus stop?')?.translation,
|
||||
'请问公交站在哪里?',
|
||||
);
|
||||
|
||||
state.removeSentenceAnalysis('where is the bus stop?');
|
||||
expect(state.sentenceAnalysisFor('where is the bus stop?'), isNull);
|
||||
});
|
||||
state.removeSentenceAnalysis('where is the bus stop?');
|
||||
expect(state.sentenceAnalysisFor('where is the bus stop?'), isNull);
|
||||
},
|
||||
);
|
||||
|
||||
test('addPhraseToReview converts phrase breakdown into vocabulary item in review queue', () {
|
||||
final state = AppState();
|
||||
state.addPhraseToReview(
|
||||
phrase: 'check in',
|
||||
meaning: '办理登机或入住',
|
||||
ipa: '/tʃek ɪn/',
|
||||
usageNote: '酒店机场高频词',
|
||||
contextSentence: "I'd like to check in please.",
|
||||
);
|
||||
test(
|
||||
'addPhraseToReview converts phrase breakdown into vocabulary item in review queue',
|
||||
() {
|
||||
final state = AppState();
|
||||
state.addPhraseToReview(
|
||||
phrase: 'check in',
|
||||
meaning: '办理登机或入住',
|
||||
ipa: '/tʃek ɪn/',
|
||||
usageNote: '酒店机场高频词',
|
||||
contextSentence: "I'd like to check in please.",
|
||||
);
|
||||
|
||||
expect(state.reviewQueue.any((r) => r.target == 'check in'), isTrue);
|
||||
final saved = state.reviewQueue.firstWhere((r) => r.target == 'check in');
|
||||
|
||||
expect(saved.hint, contains('办理登机或入住'));
|
||||
expect(saved.hint, contains('酒店机场高频词'));
|
||||
expect(saved.prompt, "I'd like to check in please.");
|
||||
});
|
||||
expect(state.reviewQueue.any((r) => r.target == 'check in'), isTrue);
|
||||
final saved = state.reviewQueue.firstWhere(
|
||||
(r) => r.target == 'check in',
|
||||
);
|
||||
|
||||
expect(saved.hint, contains('办理登机或入住'));
|
||||
expect(saved.hint, contains('酒店机场高频词'));
|
||||
expect(saved.prompt, "I'd like to check in please.");
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
group('UI Lookup Sheet Sentence Analysis View', () {
|
||||
testWidgets('renders sentence analysis result cards when cached', (tester) async {
|
||||
testWidgets('renders sentence analysis result cards when cached', (
|
||||
tester,
|
||||
) async {
|
||||
final state = AppState();
|
||||
final analysis = SentenceAnalysisResult(
|
||||
originalText: 'Where is the departure gate?',
|
||||
@@ -190,18 +208,18 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) => ElevatedButton(
|
||||
onPressed: () => showLexiconLookup(
|
||||
context,
|
||||
state: state,
|
||||
initialText: 'Where is the departure gate?',
|
||||
body: Builder(
|
||||
builder: (context) => ElevatedButton(
|
||||
onPressed: () => showLexiconLookup(
|
||||
context,
|
||||
state: state,
|
||||
initialText: 'Where is the departure gate?',
|
||||
),
|
||||
child: const Text('查句'),
|
||||
),
|
||||
child: const Text('查句'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.text('查句'));
|
||||
@@ -224,7 +242,10 @@ void main() {
|
||||
await tester.tap(find.text('加复习'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(state.reviewQueue.any((r) => r.target == 'departure gate'), isTrue);
|
||||
expect(
|
||||
state.reviewQueue.any((r) => r.target == 'departure gate'),
|
||||
isTrue,
|
||||
);
|
||||
expect(find.text('已在复习'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user