Merge branch 'worktree-agent-a785be85dc8fbff78'
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/domain/chat_default_name.dart';
|
||||
import 'package:pipelines_app/features/chat/domain/chat_sessions.dart';
|
||||
|
||||
void main() {
|
||||
test('an operator or harness title is shown as is', () {
|
||||
expect(
|
||||
chatSessionTitle({'id': 's', 'title': 'Fix login', 'directory': '/a'}),
|
||||
'Fix login',
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'an untitled chat shows the default name until the harness names it',
|
||||
() {
|
||||
expect(
|
||||
chatSessionTitle({
|
||||
'id': 'ses_1',
|
||||
'title': '',
|
||||
'directory': '/work/pipelines',
|
||||
'backend': 'codex',
|
||||
}),
|
||||
'Pipelines Codex',
|
||||
);
|
||||
expect(
|
||||
chatSessionTitle({
|
||||
'id': 'ses_2',
|
||||
'title': 'New session - 2026-12-02T09:00:00.000Z',
|
||||
'directory': '/work/site',
|
||||
'backend': 'opencode',
|
||||
}),
|
||||
'Site OpenCode',
|
||||
);
|
||||
// No backend field: an older server's chats are OpenCode.
|
||||
expect(
|
||||
chatSessionTitle({'id': 'ses_3', 'directory': '/work/site'}),
|
||||
'Site OpenCode',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test('a row without a directory still falls back to its id', () {
|
||||
expect(chatSessionTitle({'id': 'ses_abc'}), 'ses_abc');
|
||||
expect(chatSessionTitle(const {}), 'Untitled chat');
|
||||
});
|
||||
|
||||
test('only blank titles and the placeholder count as unnamed', () {
|
||||
expect(chatHarnessTitle(' '), isNull);
|
||||
expect(chatHarnessTitle('Child session - 2026-01-01T00:00:00Z'), isNull);
|
||||
expect(chatHarnessTitle('New session notes'), 'New session notes');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/domain/chat_account_usage.dart';
|
||||
import 'package:pipelines_app/features/chat/domain/chat_send_later.dart';
|
||||
|
||||
ChatAccountUsage _usage(List<ChatQuotaWindow> windows) => ChatAccountUsage(
|
||||
harness: 'Claude Code',
|
||||
plan: 'max',
|
||||
asOf: 0,
|
||||
windows: windows,
|
||||
unsupported: false,
|
||||
);
|
||||
|
||||
void main() {
|
||||
final now = DateTime(2026, 12, 2, 14, 10);
|
||||
|
||||
test('quick times: 30 minutes, an hour, tomorrow at 9:00', () {
|
||||
final choices = chatSendLaterChoices(now);
|
||||
expect(choices.map((c) => c.kind), [
|
||||
ChatSendLaterKind.halfHour,
|
||||
ChatSendLaterKind.hour,
|
||||
ChatSendLaterKind.tomorrowMorning,
|
||||
]);
|
||||
expect(choices[0].at, DateTime(2026, 12, 2, 14, 40));
|
||||
expect(choices[1].at, DateTime(2026, 12, 2, 15, 10));
|
||||
expect(choices[2].at, DateTime(2026, 12, 3, 9));
|
||||
});
|
||||
|
||||
test('the usage reset is offered only when it is known and ahead', () {
|
||||
final reset = DateTime(2026, 12, 2, 17, 21);
|
||||
expect(chatSendLaterChoices(now, usageReset: reset).last, (
|
||||
kind: ChatSendLaterKind.usageReset,
|
||||
at: reset,
|
||||
));
|
||||
expect(
|
||||
chatSendLaterChoices(now, usageReset: now).map((c) => c.kind),
|
||||
isNot(contains(ChatSendLaterKind.usageReset)),
|
||||
);
|
||||
});
|
||||
|
||||
test('the reset: an exhausted window first, else the next reset', () {
|
||||
final soon = DateTime(2026, 12, 2, 17, 20).millisecondsSinceEpoch;
|
||||
final later = DateTime(2026, 12, 5, 9).millisecondsSinceEpoch;
|
||||
final reset = chatSendLaterUsageReset(
|
||||
_usage([
|
||||
ChatQuotaWindow(
|
||||
id: 'five_hour',
|
||||
label: '5-hour',
|
||||
usedPercent: 40,
|
||||
resetsAt: soon,
|
||||
),
|
||||
ChatQuotaWindow(
|
||||
id: 'week',
|
||||
label: 'Weekly',
|
||||
usedPercent: 100,
|
||||
resetsAt: later,
|
||||
),
|
||||
]),
|
||||
now,
|
||||
);
|
||||
expect(reset, DateTime(2026, 12, 5, 9, 1));
|
||||
expect(
|
||||
chatSendLaterUsageReset(
|
||||
_usage([
|
||||
ChatQuotaWindow(
|
||||
id: 'five_hour',
|
||||
label: '5-hour',
|
||||
usedPercent: 40,
|
||||
resetsAt: soon,
|
||||
),
|
||||
]),
|
||||
now,
|
||||
),
|
||||
DateTime(2026, 12, 2, 17, 21),
|
||||
);
|
||||
expect(chatSendLaterUsageReset(_usage(const []), now), isNull);
|
||||
expect(chatSendLaterUsageReset(null, now), isNull);
|
||||
});
|
||||
|
||||
test('a picked time is today when ahead, else tomorrow', () {
|
||||
expect(chatSendLaterAt(now, 18, 30), DateTime(2026, 12, 2, 18, 30));
|
||||
expect(chatSendLaterAt(now, 8, 0), DateTime(2026, 12, 3, 8));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user