Files
Docwell/Phone-App/test/journal_events_test.dart
T
tajniak81andClaude Opus 5.5 6984c7d162 Connect Google Calendar, import OneNote notebooks, sync Readwise, and package the clipper
Phase F follow-ups (ADR-16):

- Calendars: events are now stored in calendar_events by a
  calendars.sync job (every 15 minutes per account, 90 days back and
  400 ahead), so journals open at once and keep showing events while a
  source is down. Google accounts connect with OAuth (calendar.readonly)
  through DOCWELL_GOOGLE_CLIENT_ID/SECRET; reconnecting renews access.
- OneNote: whole notebooks import through Microsoft Graph (Notes.Read,
  DOCWELL_MICROSOFT_CLIENT_ID/SECRET/TENANT) in the background, with
  section groups, sections, subpages, pictures and attached files. The
  Microsoft sign-in lives in memory for an hour and is never stored.
- Readwise: an hourly sync with the person's sealed access token; new
  books get a page under "Readwise", new highlights are appended once.
  New readwise_syncs collection.
- internal/oauth: signed states and one callback route per provider,
  routed by purpose. directory gains ImportConverted and CallerOf.
- Phone app: "Today's journal" on the home screen and calendar events
  on journal pages.
- Web clipper: `npm run package` builds Chrome/Edge, Firefox and source
  zips; store/ holds listing texts, permission notes and a privacy
  policy.
- OpenAPI, generated clients, translations, compose and .env examples,
  and user docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 14:59:34 +01:00

50 lines
1.3 KiB
Dart

// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:docwell_mobile/api/docwell_api.dart';
import 'package:docwell_mobile/screens/journal_events.dart';
import 'package:flutter_test/flutter_test.dart';
CalendarEvent ev(
String title,
String start,
String end, {
bool allDay = false,
}) => CalendarEvent.fromJson({
'id': title,
'calendar': 'c',
'title': title,
'location': '',
'url': '',
'start': start,
'end': end,
'allDay': allDay,
'color': 'blue',
});
String local(int day, int hour) =>
DateTime(2026, 11, day, hour).toUtc().toIso8601String();
void main() {
test('keeps the events of the day in the phone zone, all-day first', () {
final events = [
ev('Late', local(16, 22), local(16, 23)),
ev('Holiday', '2026-11-16', '2026-11-17', allDay: true),
ev(
'Trip',
'2026-11-14',
'2026-11-16',
allDay: true,
), // ends the day before
ev('Morning', local(16, 9), local(16, 10)),
ev('Yesterday', local(15, 9), local(15, 10)),
ev('Overnight', local(15, 23), local(16, 1)),
ev('Tomorrow', local(17, 0), local(17, 1)),
];
final got = eventsOn(
events,
DateTime(2026, 11, 16),
).map((e) => e.title).toList();
expect(got, ['Holiday', 'Overnight', 'Morning', 'Late']);
});
}