mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-07-04 11:43:10 +02:00
Notes list & filtering: - Text-search filter plus independent date-range filters for both created and last-updated (AND-combined), a priority filter, and a new status filter. Default view hides Done/Abandoned and renders as "unfiltered" (no badge for the default state); fixed badge clipping. - NoteSort options wired into the list UI; watchCount() for the "N saved". Status & priority: - New Status enum (toDo/inProgress/Done/Abandoned) as a settable + filterable attribute on every note, with capture-screen dropdown. - Removed "None" priority: every note is Low/Medium/High, default Medium. Schema migration v2->v3 rewrites legacy priority 0 -> Medium. Export / import: - NotesMarkdown round-trippable single-file format with HTML-comment markers. - Settings "Export notes" (mobile share sheet / desktop writes ~/todo/BACKLOG.md) and "Import notes" (file picker + safe newer-wins merge by id). Structured template: - Every new note pre-fills the richer what/where/must/nice/out/done/depends/ estimate/refs scaffold. Tests: - New fast (~5s), deterministic suite via FakeNoteRepository (no DB timers) and injected http/file-selector/url-launcher fakes. 86 tests, 96.2% line coverage (note.dart & sync_service.dart at 100%, settings 98.7%). Mobile-only share branch excluded via coverage:ignore (unreachable on the Linux test host). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
70 lines
1.8 KiB
Dart
70 lines
1.8 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:todo/sync/sync_settings.dart';
|
|
|
|
void main() {
|
|
test(
|
|
'load returns the kuhyx/todo-sync defaults on a fresh install',
|
|
() async {
|
|
SharedPreferences.setMockInitialValues({});
|
|
final s = await SyncSettings.load();
|
|
expect(s.owner, 'kuhyx');
|
|
expect(s.repo, 'todo-sync');
|
|
expect(s.token, '');
|
|
expect(s.clientId, '');
|
|
},
|
|
);
|
|
|
|
test('save then load round-trips all fields', () async {
|
|
SharedPreferences.setMockInitialValues({});
|
|
await const SyncSettings(
|
|
owner: 'me',
|
|
repo: 'notes',
|
|
token: 'tok',
|
|
clientId: 'cid',
|
|
).save();
|
|
|
|
final s = await SyncSettings.load();
|
|
expect(s.owner, 'me');
|
|
expect(s.repo, 'notes');
|
|
expect(s.token, 'tok');
|
|
expect(s.clientId, 'cid');
|
|
});
|
|
|
|
test('isConfigured requires owner, repo and token', () {
|
|
expect(
|
|
const SyncSettings(owner: 'o', repo: 'r', token: 't').isConfigured,
|
|
isTrue,
|
|
);
|
|
expect(
|
|
const SyncSettings(owner: 'o', repo: 'r', token: '').isConfigured,
|
|
isFalse,
|
|
);
|
|
});
|
|
|
|
test('canUseDeviceFlow needs a client id', () {
|
|
expect(
|
|
const SyncSettings(
|
|
owner: '',
|
|
repo: '',
|
|
token: '',
|
|
clientId: 'c',
|
|
).canUseDeviceFlow,
|
|
isTrue,
|
|
);
|
|
expect(
|
|
const SyncSettings(owner: '', repo: '', token: '').canUseDeviceFlow,
|
|
isFalse,
|
|
);
|
|
});
|
|
|
|
test('copyWith overrides only the given fields', () {
|
|
const base = SyncSettings(owner: 'o', repo: 'r', token: 't', clientId: 'c');
|
|
final next = base.copyWith(token: 'new');
|
|
expect(next.owner, 'o');
|
|
expect(next.repo, 'r');
|
|
expect(next.token, 'new');
|
|
expect(next.clientId, 'c');
|
|
});
|
|
}
|