feat(block1): inventory walking skeleton + first quick-add slice

Stand up the Tanemaki monorepo and the first end-to-end vertical slice of
Block 1 (offline, encrypted inventory): add a seed → see it in a categorized,
searchable list → it persists → reopen and it's still there.

Architecture (state management like G1nkgo, adapted to Tane's reality):
- flutter_bloc (Cubit-first), but the encrypted Drift DB is the single source
  of truth; cubits stream from repositories (no hydrated_bloc/Hive, which would
  write plaintext at rest).
- get_it composition root; go_router; slang i18n (ES/EN, Weblate-friendly JSON).

Workspace & core:
- pub workspace: packages/commons_core (pure Dart) + apps/app_seeds (Flutter).
- commons_core primitives: UUIDv7 IdGen, Hybrid Logical Clock, Quantity value
  type (+ plant-aware QuantityKind), IdentityService root-seed stub.

Data & security:
- Drift schemaVersion=1 with all 10 Block-1 tables + common CRDT columns
  (HLC updated_at, last_author, tombstones); Movement append-only.
- SQLCipher via an injectable executor that refuses to open a plaintext DB;
  DB key + root seed in the OS keystore (separate secrets).
- Exported drift_schema_v1.json + migration scaffold.

Tests (near-TDD; nothing merges without tests):
- commons_core units (24), Drift migration test, "no plaintext at rest"
  security guard (runs where SQLCipher is present, skips otherwise),
  repository, widget, full quick-add flow, file-reopen persistence, and a
  no-hardcoded-strings i18n guard. GitLab CI: format + analyze + test + coverage.

Follow-on Block-1 stories (item detail/edit, species catalog, germination UI)
and all of Block 2 remain out of scope.
This commit is contained in:
vjrj 2026-07-07 15:16:14 +02:00
parent 57c0eeadaf
commit 040f15a898
131 changed files with 19855 additions and 20 deletions

View file

@ -0,0 +1,78 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:tane/db/database.dart';
import 'package:tane/i18n/strings.g.dart';
import 'package:tane/ui/inventory_list_screen.dart';
import '../support/test_support.dart';
void main() {
late AppDatabase db;
setUp(() => db = newTestDatabase());
tearDown(() => db.close());
testWidgets('shows the empty state when there are no seeds', (tester) async {
final repo = newTestRepository(db);
await tester.pumpWidget(
wrapScreen(repository: repo, child: const InventoryListScreen()),
);
await tester.pumpAndSettle();
expect(find.text('No seeds yet. Tap + to add your first.'), findsOneWidget);
await disposeTree(tester);
});
testWidgets(
'renders seeds from the repository grouped under their category',
(tester) async {
final repo = newTestRepository(db);
await repo.addQuickVariety(
label: 'Grandma tomato',
category: 'Solanaceae',
);
await tester.pumpWidget(
wrapScreen(repository: repo, child: const InventoryListScreen()),
);
await tester.pumpAndSettle();
expect(find.text('Grandma tomato'), findsOneWidget);
expect(find.text('Solanaceae'), findsOneWidget); // category header
await disposeTree(tester);
},
);
testWidgets('search filters the visible list', (tester) async {
final repo = newTestRepository(db);
await repo.addQuickVariety(label: 'Tomato');
await repo.addQuickVariety(label: 'Bean');
await tester.pumpWidget(
wrapScreen(repository: repo, child: const InventoryListScreen()),
);
await tester.pumpAndSettle();
await tester.enterText(find.byKey(const Key('inventory.search')), 'bea');
await tester.pumpAndSettle();
expect(find.text('Bean'), findsOneWidget);
expect(find.text('Tomato'), findsNothing);
await disposeTree(tester);
});
testWidgets('renders in Spanish when the locale is es', (tester) async {
final repo = newTestRepository(db);
await tester.pumpWidget(
wrapScreen(
repository: repo,
child: const InventoryListScreen(),
locale: AppLocale.es,
),
);
await tester.pumpAndSettle();
expect(find.text('Inventario'), findsOneWidget);
await disposeTree(tester);
});
}

View file

@ -0,0 +1,51 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:tane/app.dart';
import 'package:tane/i18n/strings.g.dart';
import '../support/test_support.dart';
void main() {
testWidgets(
'quick-add: empty label errors; filling it saves and lists the seed',
(tester) async {
LocaleSettings.setLocaleSync(AppLocale.en);
final db = newTestDatabase();
addTearDown(db.close);
final repo = newTestRepository(db);
await tester.pumpWidget(
TranslationProvider(child: TaneApp(repository: repo)),
);
await tester.pumpAndSettle();
// Starts empty.
expect(
find.text('No seeds yet. Tap + to add your first.'),
findsOneWidget,
);
// Open the quick-add sheet.
await tester.tap(find.byKey(const Key('inventory.addFab')));
await tester.pumpAndSettle();
// Saving with an empty label surfaces the validation message.
await tester.tap(find.byKey(const Key('quickAdd.save')));
await tester.pumpAndSettle();
expect(find.text('Give it a name'), findsOneWidget);
// Enter a name and save.
await tester.enterText(
find.byKey(const Key('quickAdd.labelField')),
'Grandma tomato',
);
await tester.tap(find.byKey(const Key('quickAdd.save')));
await tester.pumpAndSettle();
// Sheet closed and the seed shows in the list.
expect(find.byKey(const Key('quickAdd.labelField')), findsNothing);
expect(find.text('Grandma tomato'), findsOneWidget);
await disposeTree(tester);
},
);
}