Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m47s
Gitea CI / Check code and tests (push) Successful in 7m15s
Gitea CI / Build Android APK (push) Successful in 4m6s
Gitea CI / Build Windows x64 app (push) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m29s
Gitea CI / Gitea CI passed (push) Successful in 1s
Gitea Release / Prepare draft Release (push) Failing after 8s
Gitea Release / Upload Android to draft Release (push) Skipped
Gitea Release / Upload Windows to draft Release (push) Skipped
Gitea Release / Verify and publish Release (push) Skipped
99 lines
2.7 KiB
Dart
99 lines
2.7 KiB
Dart
import 'package:cutdex/features/assistant/composer_suggestions.dart';
|
|
import 'package:cutdex_core/project.dart';
|
|
import 'package:cutdex/l10n/app_localizations_en.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
test('all triggers appear at word boundaries but not in paths or email', () {
|
|
for (final trigger in ['@', '/', r'$']) {
|
|
final value = TextEditingValue(
|
|
text: 'hello $trigger片段',
|
|
selection: TextSelection.collapsed(offset: 'hello $trigger片段'.length),
|
|
);
|
|
final query = findComposerTrigger(value, const []);
|
|
expect(query?.trigger, trigger);
|
|
expect(query?.query, '片段');
|
|
}
|
|
for (final plain in ['foo@example.com', '/Users/name', r'price$100']) {
|
|
expect(
|
|
findComposerTrigger(
|
|
TextEditingValue(
|
|
text: plain,
|
|
selection: TextSelection.collapsed(offset: plain.length),
|
|
),
|
|
const [],
|
|
),
|
|
isNull,
|
|
);
|
|
}
|
|
const chinese = '看看@片段';
|
|
expect(
|
|
findComposerTrigger(
|
|
const TextEditingValue(
|
|
text: chinese,
|
|
selection: TextSelection.collapsed(offset: 5),
|
|
),
|
|
const [],
|
|
)?.query,
|
|
'片段',
|
|
);
|
|
expect(
|
|
findComposerTrigger(
|
|
const TextEditingValue(
|
|
text: '@p',
|
|
selection: TextSelection.collapsed(offset: 2),
|
|
composing: TextRange(start: 1, end: 2),
|
|
),
|
|
const [],
|
|
),
|
|
isNull,
|
|
);
|
|
});
|
|
|
|
test(
|
|
'built-in current-project options distinguish equal names and filter',
|
|
() {
|
|
final options = ComposerOptionCatalog.forTrigger(
|
|
'@',
|
|
l10n: AppLocalizationsEn(),
|
|
projectId: 'project',
|
|
assets: [
|
|
AssetDocument(
|
|
id: 'asset',
|
|
name: '片段',
|
|
storage: AssetStorage.external,
|
|
location: 'file:///tmp/a',
|
|
),
|
|
],
|
|
timelines: [
|
|
const TimelineSummary(id: 'timeline', name: '片段', revision: 1),
|
|
],
|
|
);
|
|
expect(options.length, 2);
|
|
expect(options.map((option) => option.subtitle).toSet().length, 2);
|
|
expect(filterComposerOptions(options, '片').length, 2);
|
|
expect(
|
|
ComposerOptionCatalog.forTrigger(
|
|
'/',
|
|
l10n: AppLocalizationsEn(),
|
|
projectId: 'project',
|
|
assets: const [],
|
|
timelines: const [],
|
|
),
|
|
isEmpty,
|
|
);
|
|
expect(
|
|
ComposerOptionCatalog.forTrigger(
|
|
r'$',
|
|
l10n: AppLocalizationsEn(),
|
|
projectId: 'project',
|
|
assets: const [],
|
|
timelines: const [],
|
|
),
|
|
isEmpty,
|
|
);
|
|
},
|
|
);
|
|
}
|