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
76 lines
2.3 KiB
Dart
76 lines
2.3 KiB
Dart
import 'package:cutdex/features/assistant/composer_document.dart';
|
|
import 'package:cutdex/features/assistant/composer_reference_validator.dart';
|
|
import 'package:cutdex/workspace/project_state.dart';
|
|
import 'package:cutdex_core/project.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
const media = ComposerReference(
|
|
kind: ComposerReferenceKind.media,
|
|
projectId: 'project',
|
|
id: 'asset',
|
|
label: '旧名称.mp4',
|
|
);
|
|
const timeline = ComposerReference(
|
|
kind: ComposerReferenceKind.timeline,
|
|
projectId: 'project',
|
|
id: 'timeline',
|
|
label: '时间线',
|
|
);
|
|
final workspace = ProjectState(
|
|
activeProject: const RecentProject(
|
|
id: 'project',
|
|
name: '项目',
|
|
path: '/project.cutdex',
|
|
),
|
|
assets: [
|
|
AssetDocument(
|
|
id: 'asset',
|
|
name: '新名称.mp4',
|
|
storage: AssetStorage.external,
|
|
location: 'file:///tmp/asset',
|
|
),
|
|
],
|
|
timelines: const [
|
|
TimelineSummary(id: 'timeline', name: '时间线', revision: 1),
|
|
],
|
|
);
|
|
|
|
test('rename keeps the stable media ID valid, deletion invalidates it', () {
|
|
final controller = ComposerDocumentController(text: '@');
|
|
addTearDown(controller.dispose);
|
|
controller.insertReference(0, 1, media);
|
|
ComposerReferenceValidator(
|
|
workspace: workspace,
|
|
projectId: 'project',
|
|
).validate(controller);
|
|
expect(controller.hasInvalidReferences, isFalse);
|
|
expect(controller.marks.single.reference.label, '旧名称.mp4');
|
|
ComposerReferenceValidator(
|
|
workspace: workspace.copyWith(assets: const []),
|
|
projectId: 'project',
|
|
).validate(controller);
|
|
expect(controller.hasInvalidReferences, isTrue);
|
|
});
|
|
|
|
test(
|
|
'draft references follow the active project without changing their IDs',
|
|
() {
|
|
final controller = ComposerDocumentController(text: '@');
|
|
addTearDown(controller.dispose);
|
|
controller.insertReference(0, 1, timeline);
|
|
ComposerReferenceValidator(
|
|
workspace: workspace,
|
|
projectId: 'other',
|
|
).validate(controller);
|
|
expect(controller.hasInvalidReferences, isTrue);
|
|
ComposerReferenceValidator(
|
|
workspace: workspace,
|
|
projectId: 'project',
|
|
).validate(controller);
|
|
expect(controller.hasInvalidReferences, isFalse);
|
|
expect(controller.marks.single.reference.id, 'timeline');
|
|
},
|
|
);
|
|
}
|