feat(workspace): refresh desktop editing experience and prepare 0.1.2
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
This commit is contained in:
1 parent
aa5255d1e4
commit
2e0033ce2d
260 files changed
+43963
-5591
No files matched your search
@@ -0,0 +1,178 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cutdex/errors/app_failure.dart';
|
||||
import 'package:cutdex/integrations/platform/device_experience.dart';
|
||||
import 'package:cutdex/persistence/app_settings_repositories.dart';
|
||||
import 'package:cutdex/workspace/persistence/recent_projects.dart';
|
||||
import 'package:cutdex/workspace/projects.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../support/memory_app_settings.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
group('project creation collisions', () {
|
||||
late Directory root;
|
||||
late ProviderContainer container;
|
||||
late Projects projects;
|
||||
|
||||
setUp(() async {
|
||||
root = await Directory.systemTemp.createTemp('cutdex-name-conflict-');
|
||||
container = ProviderContainer(
|
||||
overrides: [
|
||||
deviceExperienceProvider.overrideWithValue(DeviceExperience.desktop),
|
||||
recentProjectsProvider.overrideWithValue(
|
||||
MemoryRecentProjectsRepository(),
|
||||
),
|
||||
projectLocationSettingsRepositoryProvider.overrideWithValue(
|
||||
DefaultingProjectLocationSettingsRepository(
|
||||
MemoryProjectLocationSettingsRepository(root.path),
|
||||
),
|
||||
),
|
||||
resourceLocationSettingsRepositoryProvider.overrideWithValue(
|
||||
MemoryResourceLocationSettingsRepository(root.path),
|
||||
),
|
||||
],
|
||||
);
|
||||
projects = container.read(projectsProvider.notifier);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await projects.prepareToQuit();
|
||||
container.dispose();
|
||||
await root.delete(recursive: true);
|
||||
});
|
||||
|
||||
test(
|
||||
'duplicate creation preserves the existing project and session',
|
||||
() async {
|
||||
expect(
|
||||
await projects.createProject('One', initialTimelineName: 'Timeline'),
|
||||
isTrue,
|
||||
);
|
||||
final before = container.read(projectsProvider).requireValue;
|
||||
final project = before.activeProject!;
|
||||
final session = await projects.openTimelineSession(
|
||||
project.id,
|
||||
before.timeline!.id,
|
||||
);
|
||||
final manifest = File('${project.path}/manifest.json');
|
||||
final contents = await manifest.readAsString();
|
||||
expect(
|
||||
(await projects.validateNewProjectName(' One '))?.code,
|
||||
AppErrorCode.projectAlreadyExists,
|
||||
);
|
||||
expect(container.read(projectsProvider).requireValue.error, isNull);
|
||||
|
||||
expect(
|
||||
await projects.createProject(
|
||||
' One ',
|
||||
initialTimelineName: 'Replacement',
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
final after = container.read(projectsProvider).requireValue;
|
||||
expect(after.error?.code, AppErrorCode.projectAlreadyExists);
|
||||
expect(after.activeProject?.id, project.id);
|
||||
expect(after.timeline?.id, before.timeline?.id);
|
||||
expect(after.recent, before.recent);
|
||||
expect(await manifest.readAsString(), contents);
|
||||
expect(
|
||||
await projects.openTimelineSession(project.id, before.timeline!.id),
|
||||
same(session),
|
||||
);
|
||||
|
||||
expect(await projects.validateNewProjectName('Two'), isNull);
|
||||
expect(
|
||||
await projects.createProject('Two', initialTimelineName: 'Timeline'),
|
||||
isTrue,
|
||||
);
|
||||
expect(container.read(projectsProvider).requireValue.error, isNull);
|
||||
expect(
|
||||
container.read(projectsProvider).requireValue.activeProject?.name,
|
||||
'Two',
|
||||
);
|
||||
expect(await manifest.readAsString(), contents);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'creation detects a destination occupied after name validation',
|
||||
() async {
|
||||
expect(await projects.validateNewProjectName('Racing'), isNull);
|
||||
final destination = File('${root.path}/Racing.cutdex');
|
||||
await destination.writeAsString('created by another operation');
|
||||
expect(
|
||||
await projects.createProject(
|
||||
'Racing',
|
||||
initialTimelineName: 'Timeline',
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
container.read(projectsProvider).requireValue.error?.code,
|
||||
AppErrorCode.projectAlreadyExists,
|
||||
);
|
||||
expect(
|
||||
await destination.readAsString(),
|
||||
'created by another operation',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
for (final type in ['file', 'directory', 'broken link']) {
|
||||
test('occupied $type is reported without replacing it', () async {
|
||||
final destination = '${root.path}/Occupied.cutdex';
|
||||
switch (type) {
|
||||
case 'file':
|
||||
await File(destination).writeAsString('keep this file');
|
||||
case 'directory':
|
||||
await Directory(destination).create();
|
||||
await File('$destination/keep.txt')
|
||||
.writeAsString('keep this directory');
|
||||
case 'broken link':
|
||||
await Link(destination).create('${root.path}/missing-target');
|
||||
}
|
||||
final before = await FileSystemEntity.type(
|
||||
destination,
|
||||
followLinks: false,
|
||||
);
|
||||
expect(
|
||||
(await projects.validateNewProjectName('Occupied'))?.code,
|
||||
AppErrorCode.projectAlreadyExists,
|
||||
);
|
||||
expect(
|
||||
await projects.createProject(
|
||||
'Occupied',
|
||||
initialTimelineName: 'Timeline',
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
final state = container.read(projectsProvider).requireValue;
|
||||
expect(state.error?.code, AppErrorCode.projectAlreadyExists);
|
||||
expect(state.activeProject, isNull);
|
||||
expect(state.recent, isEmpty);
|
||||
expect(
|
||||
await FileSystemEntity.type(destination, followLinks: false),
|
||||
before,
|
||||
);
|
||||
switch (type) {
|
||||
case 'file':
|
||||
expect(await File(destination).readAsString(), 'keep this file');
|
||||
case 'directory':
|
||||
expect(
|
||||
await File('$destination/keep.txt').readAsString(),
|
||||
'keep this directory',
|
||||
);
|
||||
case 'broken link':
|
||||
expect(
|
||||
await Link(destination).target(),
|
||||
'${root.path}/missing-target',
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user