feat: initial release of Oracle 999 divination app
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:words999/main.dart';
|
||||
import 'package:words999/services/words_repository.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('App smoke test - launch oracle and verify navigation', (WidgetTester tester) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
await WordsRepository().init();
|
||||
await tester.pumpWidget(const Words999App());
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
|
||||
// Verify app title and destinations
|
||||
expect(find.text('Оракул 999'), findsOneWidget);
|
||||
expect(find.text('Поиск 000..999'), findsOneWidget);
|
||||
expect(find.text('Расклады'), findsOneWidget);
|
||||
expect(find.text('Каталог 999'), findsOneWidget);
|
||||
expect(find.text('История'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:words999/models/history_entry_model.dart';
|
||||
import 'package:words999/services/words_repository.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
group('WordsRepository Oracle & Divination Tests', () {
|
||||
late WordsRepository repo;
|
||||
|
||||
setUp(() async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
repo = WordsRepository();
|
||||
await repo.init();
|
||||
});
|
||||
|
||||
test('Dataset contains exactly 1000 words with unique randomized session numbers 000 to 999', () {
|
||||
expect(repo.totalWords, equals(1000));
|
||||
expect(repo.allWords.length, equals(1000));
|
||||
|
||||
final seenSessionNumbers = <int>{};
|
||||
for (int i = 0; i <= 999; i++) {
|
||||
final item = repo.getWordBySessionNumber(i);
|
||||
expect(item, isNotNull, reason: 'Word with session number $i must exist');
|
||||
expect(item!.sessionNumber, equals(i));
|
||||
expect(item.formattedSessionNumber.length, equals(3));
|
||||
expect(item.word.isNotEmpty, isTrue, reason: 'Word cannot be empty');
|
||||
expect(item.description.isNotEmpty, isTrue, reason: 'Symbolic meaning must be present');
|
||||
expect(item.partOfSpeech.isNotEmpty, isTrue);
|
||||
seenSessionNumbers.add(item.sessionNumber);
|
||||
}
|
||||
expect(seenSessionNumbers.length, equals(1000));
|
||||
});
|
||||
|
||||
test('Reshuffling changes the order / mapping of words to session numbers', () {
|
||||
repo.reshuffleSessionNumbers();
|
||||
// Verify total count is still 1000 and all numbers 0..999 are present
|
||||
expect(repo.totalWords, equals(1000));
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
expect(repo.getWordBySessionNumber(i)?.sessionNumber, equals(i));
|
||||
}
|
||||
});
|
||||
|
||||
test('Search by number string returns correct session word', () {
|
||||
final results0 = repo.search('0');
|
||||
expect(results0.isNotEmpty, isTrue);
|
||||
expect(results0.first.sessionNumber, equals(0));
|
||||
|
||||
final results42 = repo.search('42');
|
||||
expect(results42.isNotEmpty, isTrue);
|
||||
expect(results42.first.sessionNumber, equals(42));
|
||||
|
||||
final results999 = repo.search('999');
|
||||
expect(results999.isNotEmpty, isTrue);
|
||||
expect(results999.first.sessionNumber, equals(999));
|
||||
});
|
||||
|
||||
test('Next and previous word navigation wraps around 000..999', () {
|
||||
expect(repo.getNextWord(0).sessionNumber, equals(1));
|
||||
expect(repo.getNextWord(999).sessionNumber, equals(0));
|
||||
expect(repo.getPreviousWord(1).sessionNumber, equals(0));
|
||||
expect(repo.getPreviousWord(0).sessionNumber, equals(999));
|
||||
});
|
||||
|
||||
test('History entries can be added, retrieved, and cleared', () async {
|
||||
await repo.clearHistory();
|
||||
expect(repo.history.isEmpty, isTrue);
|
||||
|
||||
final entry = HistoryEntry(
|
||||
id: '1',
|
||||
timestamp: DateTime(2026, 8, 31, 12, 0),
|
||||
word: 'огонь',
|
||||
sessionNumber: 777,
|
||||
partOfSpeech: 'существительное',
|
||||
symbolicMeaning: 'Очищающее пламя трансформации',
|
||||
readingType: 'Жребий момента',
|
||||
);
|
||||
|
||||
await repo.addHistoryEntry(entry);
|
||||
expect(repo.history.length, equals(1));
|
||||
expect(repo.history.first.word, equals('огонь'));
|
||||
expect(repo.history.first.formattedSessionNumber, equals('777'));
|
||||
expect(repo.history.first.formattedDate, contains('31.08.2026 12:00:00'));
|
||||
|
||||
await repo.clearHistory();
|
||||
expect(repo.history.isEmpty, isTrue);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user