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,122 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cutdex/persistence/app_database.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:cutdex/workspace/view_settings.dart';
|
||||
import 'package:drift/native.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();
|
||||
for (final superseded in [false, true]) {
|
||||
test(
|
||||
'project layout is prepared before publication (superseded: $superseded)',
|
||||
() async {
|
||||
final root = await Directory.systemTemp.createTemp(
|
||||
'cutdex-project-layout-',
|
||||
);
|
||||
final database = AppDatabase(NativeDatabase.memory());
|
||||
final layouts = _DelayedLayouts();
|
||||
final container = ProviderContainer(
|
||||
overrides: [
|
||||
appDatabaseProvider.overrideWithValue(database),
|
||||
recentProjectsProvider.overrideWithValue(
|
||||
MemoryRecentProjectsRepository(),
|
||||
),
|
||||
resourceLocationSettingsRepositoryProvider.overrideWithValue(
|
||||
MemoryResourceLocationSettingsRepository(root.path),
|
||||
),
|
||||
projectViewSettingsRepositoryProvider.overrideWithValue(layouts),
|
||||
],
|
||||
);
|
||||
try {
|
||||
final projects = container.read(projectsProvider.notifier);
|
||||
expect(
|
||||
await projects.open('${root.path}/First.cutdex', name: 'First'),
|
||||
isTrue,
|
||||
);
|
||||
final initial = container.read(projectsProvider).requireValue;
|
||||
var current = true;
|
||||
final opening = projects.open(
|
||||
'${root.path}/Second.cutdex',
|
||||
name: 'Second',
|
||||
isCurrent: () => current,
|
||||
);
|
||||
final targetId = await layouts.requested.future;
|
||||
expect(
|
||||
container.read(projectsProvider).requireValue.activeProject,
|
||||
initial.activeProject,
|
||||
);
|
||||
expect(
|
||||
container.read(projectsProvider).requireValue.timeline,
|
||||
initial.timeline,
|
||||
);
|
||||
expect(
|
||||
container.read(projectsProvider).requireValue.projectBusy,
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
container.read(projectViewSettingsProvider(targetId)).isLoading,
|
||||
isTrue,
|
||||
);
|
||||
current = !superseded;
|
||||
layouts.prepared.complete(
|
||||
const ProjectViewSettingsData(
|
||||
propertiesOpen: true,
|
||||
timelineHeight: 320,
|
||||
),
|
||||
);
|
||||
expect(await opening, !superseded);
|
||||
final published = container.read(projectsProvider).requireValue;
|
||||
expect(
|
||||
published.activeProject?.id,
|
||||
superseded ? initial.activeProject!.id : targetId,
|
||||
);
|
||||
expect(published.projectBusy, isFalse);
|
||||
expect(published.error, isNull);
|
||||
expect(
|
||||
container
|
||||
.read(projectViewSettingsProvider(targetId))
|
||||
.requireValue
|
||||
.propertiesOpen,
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
container
|
||||
.read(projectViewSettingsProvider(targetId))
|
||||
.requireValue
|
||||
.timelineHeight,
|
||||
320,
|
||||
);
|
||||
} finally {
|
||||
await container.read(projectsProvider.notifier).prepareToQuit();
|
||||
container.dispose();
|
||||
await database.close();
|
||||
await root.delete(recursive: true);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _DelayedLayouts implements ProjectViewSettingsRepository {
|
||||
String? _firstProjectId;
|
||||
final requested = Completer<String>();
|
||||
final prepared = Completer<ProjectViewSettingsData>();
|
||||
@override
|
||||
Future<ProjectViewSettingsData> load(String projectId) async {
|
||||
_firstProjectId ??= projectId;
|
||||
if (projectId == _firstProjectId) return const ProjectViewSettingsData();
|
||||
requested.complete(projectId);
|
||||
return prepared.future;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> save(String projectId, ProjectViewSettingsData settings) async {}
|
||||
}
|
||||
Reference in new issue
Block a user