refactor: finalize agent schemas and profile model

- Remove deprecated calendar UI tests
- Update profile model with phone field support
- Update agent schemas with runtime_models and forwarded_props
- Update system_agent with new agent configuration
This commit is contained in:
qzl
2026-03-19 18:43:35 +08:00
parent 524b91f454
commit 7fd536e976
11 changed files with 195 additions and 324 deletions
@@ -1,51 +0,0 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:social_app/features/calendar/ui/calendar_time_utils.dart';
void main() {
group('calendar_time_utils', () {
test('returns week start on sunday', () {
final date = DateTime(2026, 2, 11);
final weekStart = weekStartFor(date);
expect(weekStart.year, 2026);
expect(weekStart.month, 2);
expect(weekStart.day, 8);
});
test('shows current marker only for selected today', () {
final now = DateTime(2026, 2, 11, 15, 28);
expect(shouldShowCurrentMarker(DateTime(2026, 2, 11), now), isTrue);
expect(shouldShowCurrentMarker(DateTime(2026, 2, 10), now), isFalse);
});
test('formats hour minute with zero pad', () {
expect(formatHm(DateTime(2026, 2, 11, 7, 5)), '07:05');
expect(formatHm(DateTime(2026, 2, 11, 15, 28)), '15:28');
});
test('parses and formats ymd date string', () {
final parsed = parseYmd('2026-02-11');
expect(parsed, isNotNull);
expect(parsed!.year, 2026);
expect(parsed.month, 2);
expect(parsed.day, 11);
expect(formatYmd(parsed), '2026-02-11');
});
test('returns null for invalid ymd date string', () {
expect(parseYmd('2026/02/11'), isNull);
expect(parseYmd('bad-input'), isNull);
expect(parseYmd(null), isNull);
});
test('builds all dates for month', () {
final dates = monthDatesFor(DateTime(2026, 2, 9));
expect(dates.length, 28);
expect(formatYmd(dates.first), '2026-02-01');
expect(formatYmd(dates.last), '2026-02-28');
});
});
}
@@ -1,29 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:social_app/features/calendar/data/models/schedule_item_model.dart';
import 'package:social_app/features/calendar/ui/widgets/create_event_sheet.dart';
void main() {
testWidgets('编辑日程时支持非默认提醒值', (tester) async {
final event = ScheduleItemModel(
id: 'evt_1',
ownerId: 'user_1',
title: '测试日程',
startAt: DateTime(2026, 3, 18, 10, 0),
endAt: DateTime(2026, 3, 18, 11, 0),
metadata: ScheduleMetadata(reminderMinutes: 20),
);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(body: CreateEventSheet(editingEvent: event)),
),
);
await tester.pumpAndSettle();
await tester.tap(find.text('进阶'));
await tester.pumpAndSettle();
expect(find.text('开始前20分钟'), findsOneWidget);
});
}
@@ -1,47 +0,0 @@
import 'package:flutter_test/flutter_test.dart';
void main() {
group('时间自动对齐逻辑', () {
test('开始时间改变后,结束时间早于开始时间应自动对齐', () {
DateTime startTime = DateTime(2026, 3, 11, 10, 0);
DateTime endTime = DateTime(2026, 3, 11, 9, 0);
final newStartTime = DateTime(2026, 3, 11, 14, 30);
if (endTime.isBefore(newStartTime)) {
endTime = newStartTime;
}
expect(endTime.hour, 14);
expect(endTime.minute, 30);
});
test('结束时间晚于开始时间则不需要对齐', () {
DateTime startTime = DateTime(2026, 3, 11, 10, 0);
DateTime endTime = DateTime(2026, 3, 11, 12, 0);
final newStartTime = DateTime(2026, 3, 11, 14, 30);
if (endTime.isBefore(newStartTime)) {
endTime = newStartTime;
}
expect(endTime.hour, 14);
expect(endTime.minute, 30);
});
test('结束时间等于开始时间也需要对齐', () {
DateTime startTime = DateTime(2026, 3, 11, 10, 0);
DateTime endTime = DateTime(2026, 3, 11, 10, 0);
final newStartTime = DateTime(2026, 3, 11, 14, 30);
if (endTime.isBefore(newStartTime)) {
endTime = newStartTime;
}
expect(endTime.hour, 14);
expect(endTime.minute, 30);
});
});
}
@@ -1,104 +0,0 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:social_app/features/calendar/data/models/schedule_item_model.dart';
import 'package:social_app/features/calendar/ui/dayweek/day_event_layout_engine.dart';
import 'package:social_app/features/calendar/ui/dayweek/day_timeline_metrics.dart';
import 'package:social_app/features/calendar/ui/dayweek/day_view_scale.dart';
void main() {
group('DayEventLayoutEngine', () {
const engine = DayEventLayoutEngine();
const scale = DayViewScale(hourHeight: 60);
test('maps event top and height by exact minutes', () {
final event = _event(
id: 'a',
start: DateTime(2026, 3, 18, 10, 15),
end: DateTime(2026, 3, 18, 11, 45),
);
final layouts = engine.layout(
events: [event],
scale: scale,
eventAreaLeft: DayTimelineMetrics.eventAreaLeft(),
eventAreaWidth: 200,
);
expect(layouts, hasLength(1));
expect(layouts.first.startMinutes, 615);
expect(layouts.first.endMinutes, 705);
expect(layouts.first.top, 615);
expect(layouts.first.geometryHeight, 90);
expect(layouts.first.visualHeight, 90);
});
test('splits overlapped events into columns', () {
final e1 = _event(
id: 'a',
start: DateTime(2026, 3, 18, 9, 0),
end: DateTime(2026, 3, 18, 10, 0),
);
final e2 = _event(
id: 'b',
start: DateTime(2026, 3, 18, 9, 30),
end: DateTime(2026, 3, 18, 10, 30),
);
final layouts = engine.layout(
events: [e1, e2],
scale: scale,
eventAreaLeft: DayTimelineMetrics.eventAreaLeft(),
eventAreaWidth: 200,
);
expect(layouts, hasLength(2));
expect(layouts[0].columnCount, 2);
expect(layouts[1].columnCount, 2);
expect(layouts[0].width, closeTo(98, 0.001));
expect(layouts[1].width, closeTo(98, 0.001));
expect(layouts[0].left, DayTimelineMetrics.eventAreaLeft());
expect(
layouts[1].left,
closeTo(DayTimelineMetrics.eventAreaLeft() + 102, 0.001),
);
});
test('uses 1 pixel minimum visual height but preserves geometry', () {
final event = _event(
id: 'a',
start: DateTime(2026, 3, 18, 9, 0),
end: DateTime(2026, 3, 18, 9, 1),
);
final tinyScale = const DayViewScale(
hourHeight: DayViewScale.minHourHeight,
);
final layouts = engine.layout(
events: [event],
scale: tinyScale,
eventAreaLeft: DayTimelineMetrics.eventAreaLeft(),
eventAreaWidth: 200,
);
expect(layouts, hasLength(1));
expect(
layouts.first.geometryHeight,
closeTo(tinyScale.pixelsForMinutes(1), 0.001),
);
expect(layouts.first.visualHeight, greaterThanOrEqualTo(1));
});
});
}
ScheduleItemModel _event({
required String id,
required DateTime start,
required DateTime end,
}) {
return ScheduleItemModel(
id: id,
ownerId: 'owner',
title: 'event-$id',
startAt: start,
endAt: end,
);
}
@@ -1,31 +0,0 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:social_app/features/calendar/ui/dayweek/day_view_scale.dart';
void main() {
group('DayViewScale', () {
test('maps minutes to pixels and back', () {
const scale = DayViewScale(hourHeight: 60);
expect(scale.pixelsForMinutes(30), 30);
expect(scale.pixelsForMinutes(75), 75);
expect(scale.minutesForPixels(90), 90);
});
test('clamps zoom height at boundaries', () {
const scale = DayViewScale(hourHeight: 34);
final zoomIn = scale.zoomByFactor(20);
final zoomOut = scale.zoomByFactor(0.01);
expect(zoomIn.hourHeight, DayViewScale.maxHourHeight);
expect(zoomOut.hourHeight, DayViewScale.minHourHeight);
});
test('ignores invalid zoom factor', () {
const scale = DayViewScale(hourHeight: 34);
expect(scale.zoomByFactor(0).hourHeight, 34);
expect(scale.zoomByFactor(-1).hourHeight, 34);
});
});
}
@@ -1,25 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:social_app/core/theme/design_tokens.dart';
import 'package:social_app/features/calendar/data/models/schedule_item_model.dart';
import 'package:social_app/features/calendar/ui/utils/event_color_resolver.dart';
void main() {
test('returns gray for archived status regardless of custom color', () {
final color = resolveEventColor(
status: ScheduleStatus.archived,
colorHex: '#EF4444',
);
expect(color, AppColors.slate400);
});
test('returns parsed color for active status', () {
final color = resolveEventColor(
status: ScheduleStatus.active,
colorHex: '#3B82F6',
);
expect(color.value, const Color(0xFF3B82F6).value);
});
}