feat(workspace): add workflow navigation and resizable desktop panels
This commit is contained in:
1 parent
02413383d8
commit
1acfe4a005
17 files changed
+2008
-277
No files matched your search
@@ -61,8 +61,8 @@ Future<void> floatOrDockChat(WidgetTester tester) async {
|
||||
|
||||
void main() {
|
||||
test('space classes and two-pane decisions do not depend on workflow', () {
|
||||
expect(WorkspaceLayoutPolicy.desktopNavigationFits(545), isFalse);
|
||||
expect(WorkspaceLayoutPolicy.desktopNavigationFits(546), isTrue);
|
||||
expect(WorkspaceLayoutPolicy.desktopNavigationFits(541), isFalse);
|
||||
expect(WorkspaceLayoutPolicy.desktopNavigationFits(542), isTrue);
|
||||
expect(WorkspaceLayoutPolicy.showAgentBesideEditor(839), isFalse);
|
||||
expect(WorkspaceLayoutPolicy.showAgentBesideEditor(840), isTrue);
|
||||
});
|
||||
@@ -178,7 +178,7 @@ void main() {
|
||||
expect(header.contains(tester.getCenter(projectTab)), isTrue);
|
||||
expect(find.byKey(const Key('sidebar-tab-chat')), findsNothing);
|
||||
expect(find.byKey(const Key('sidebar-tab-resources')), findsNothing);
|
||||
expect(find.byKey(const Key('desktop-navigation-rail')), findsNothing);
|
||||
expect(find.byKey(const Key('desktop-navigation-rail')), findsOneWidget);
|
||||
expect(find.byKey(const Key('media-project-button')), findsNothing);
|
||||
expect(find.byKey(const Key('media-panel-close')), findsNothing);
|
||||
final mediaHeader = find.byKey(const Key('media-panel-header'));
|
||||
@@ -202,12 +202,49 @@ void main() {
|
||||
find.byKey(const Key('editor-timeline-card')),
|
||||
);
|
||||
final chatRect = tester.getRect(find.byKey(const Key('desktop-chat-card')));
|
||||
expect(media.left - chatRect.right, 6);
|
||||
expect(preview.left - media.right, 6);
|
||||
expect(media.left - chatRect.right, 2);
|
||||
expect(preview.left - media.right, 2);
|
||||
expect(timeline.top - media.bottom, 2);
|
||||
final content = tester.getRect(
|
||||
find.byKey(const Key('desktop-content-container')),
|
||||
);
|
||||
expect(content.left, 46);
|
||||
expect(content.right, 1198);
|
||||
expect(content.bottom, 798);
|
||||
expect(media.top, preview.top);
|
||||
expect(timeline.left, media.left);
|
||||
expect(timeline.right, preview.right);
|
||||
final previewElement = tester.element(find.byType(EditorPreviewPanel));
|
||||
await tester.drag(
|
||||
find.byKey(const Key('editor-media-resize')),
|
||||
const Offset(60, 0),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('editor-media-card'))).width,
|
||||
media.width + 60,
|
||||
);
|
||||
await tester.drag(
|
||||
find.byKey(const Key('editor-media-timeline-junction')),
|
||||
const Offset(40, -30),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final resizedSettings = mounted.container
|
||||
.read(projectViewSettingsProvider(mounted.projectId))
|
||||
.requireValue;
|
||||
expect(resizedSettings.mediaWidth, media.width + 100);
|
||||
expect(resizedSettings.timelineHeight, closeTo(timeline.height + 30, .01));
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('editor-timeline-card'))).height,
|
||||
closeTo(timeline.height + 30, .01),
|
||||
);
|
||||
expect(
|
||||
mounted.container
|
||||
.read(projectViewSettingsProvider(mounted.projectId))
|
||||
.requireValue
|
||||
.mediaWidth,
|
||||
media.width + 100,
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('editor-media-button')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(MediaPanel), findsNothing);
|
||||
@@ -218,6 +255,10 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('editor-media-button')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(MediaPanel), findsOneWidget);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('editor-media-card'))).width,
|
||||
media.width + 100,
|
||||
);
|
||||
expect(tester.element(find.byType(AgentChatPanel)), same(chat));
|
||||
expect(tester.element(find.byType(EditorWorkspace)), same(editor));
|
||||
expect(
|
||||
@@ -228,6 +269,319 @@ void main() {
|
||||
await mounted.close();
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'chat/timeline junction resizes both axes, persists and follows docking',
|
||||
(tester) async {
|
||||
final mounted = await mount(tester, const Size(1800, 800));
|
||||
final junction = find.byKey(const Key('desktop-chat-timeline-junction'));
|
||||
Rect card(String name) => tester.getRect(find.byKey(Key(name)));
|
||||
final chat = card('desktop-chat-card');
|
||||
final media = card('editor-media-card');
|
||||
final timeline = card('editor-timeline-card');
|
||||
final center = tester.getCenter(junction);
|
||||
expect(center.dx, (chat.right + media.left) / 2);
|
||||
expect(center.dy, (media.bottom + timeline.top) / 2);
|
||||
final editorElement = tester.element(find.byType(EditorWorkspace));
|
||||
final mediaElement = tester.element(find.byType(MediaPanel));
|
||||
final input = find.descendant(
|
||||
of: find.byType(AgentChatPanel),
|
||||
matching: find.byType(TextField),
|
||||
);
|
||||
await tester.enterText(input, 'Keep draft while resizing the junction');
|
||||
|
||||
await tester.drag(junction, const Offset(60, -50));
|
||||
await tester.pumpAndSettle();
|
||||
expect(card('desktop-chat-card').width, chat.width + 60);
|
||||
expect(
|
||||
card('editor-timeline-card').height,
|
||||
closeTo(timeline.height + 50, .01),
|
||||
);
|
||||
expect(card('editor-media-card').width, media.width);
|
||||
expect(
|
||||
mounted.container
|
||||
.read(workspaceViewSettingsProvider)
|
||||
.requireValue
|
||||
.sidebarWidth,
|
||||
chat.width + 60,
|
||||
);
|
||||
expect(
|
||||
mounted.container
|
||||
.read(projectViewSettingsProvider(mounted.projectId))
|
||||
.requireValue
|
||||
.timelineHeight,
|
||||
closeTo(timeline.height + 50, .01),
|
||||
);
|
||||
final savedWorkspace = await tester.runAsync(
|
||||
mounted.container.read(workspaceViewSettingsRepositoryProvider).load,
|
||||
);
|
||||
final savedProject = await tester.runAsync(
|
||||
() => mounted.container
|
||||
.read(projectViewSettingsRepositoryProvider)
|
||||
.load(mounted.projectId),
|
||||
);
|
||||
expect(savedWorkspace!.sidebarWidth, chat.width + 60);
|
||||
expect(savedProject!.timelineHeight, closeTo(timeline.height + 50, .01));
|
||||
|
||||
await tester.drag(junction, const Offset(-40, 30));
|
||||
await tester.pumpAndSettle();
|
||||
expect(card('desktop-chat-card').width, chat.width + 20);
|
||||
expect(
|
||||
card('editor-timeline-card').height,
|
||||
closeTo(timeline.height + 20, .01),
|
||||
);
|
||||
await tester.drag(junction, const Offset(-100, -2000));
|
||||
await tester.pumpAndSettle();
|
||||
expect(card('desktop-chat-card').width, 220);
|
||||
expect(card('editor-preview-card').height, 180);
|
||||
await tester.drag(junction, const Offset(40, -60));
|
||||
await tester.pumpAndSettle();
|
||||
expect(card('desktop-chat-card').width, 260);
|
||||
expect(card('editor-preview-card').height, 180);
|
||||
await tester.drag(junction, const Offset(2000, 2000));
|
||||
await tester.pumpAndSettle();
|
||||
expect(card('desktop-chat-card').width, 320);
|
||||
expect(card('editor-timeline-card').height, 220);
|
||||
expect(tester.element(find.byType(EditorWorkspace)), same(editorElement));
|
||||
expect(tester.element(find.byType(MediaPanel)), same(mediaElement));
|
||||
expect(
|
||||
tester.widget<TextField>(input).controller!.text,
|
||||
'Keep draft while resizing the junction',
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('project-sidebar-toggle')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(junction, findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('project-sidebar-toggle')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(junction, findsOneWidget);
|
||||
expect(card('desktop-chat-card').width, 320);
|
||||
expect(card('editor-timeline-card').height, 220);
|
||||
await floatOrDockChat(tester);
|
||||
await tester.pumpAndSettle();
|
||||
expect(junction, findsNothing);
|
||||
await floatOrDockChat(tester);
|
||||
await tester.pumpAndSettle();
|
||||
expect(junction, findsOneWidget);
|
||||
|
||||
// The same T remains between chat, preview and timeline with media hidden.
|
||||
await tester.tap(find.byKey(const Key('editor-media-button')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(junction, findsOneWidget);
|
||||
await tester.drag(junction, const Offset(-40, -30));
|
||||
await tester.pumpAndSettle();
|
||||
expect(card('desktop-chat-card').width, 280);
|
||||
expect(card('editor-timeline-card').height, 250);
|
||||
tester.view.physicalSize = const Size(600, 360);
|
||||
await tester.pumpAndSettle();
|
||||
final narrowCenter = tester.getCenter(junction);
|
||||
expect(
|
||||
narrowCenter.dy,
|
||||
(card('editor-preview-card').bottom +
|
||||
card('editor-timeline-card').top) /
|
||||
2,
|
||||
);
|
||||
await tester.drag(junction, const Offset(2000, -2000));
|
||||
await tester.pumpAndSettle();
|
||||
expect(card('editor-preview-card').height, 180);
|
||||
expect(card('desktop-editor-card').width, 320);
|
||||
expect(tester.takeException(), isNull);
|
||||
await mounted.close();
|
||||
},
|
||||
);
|
||||
|
||||
for (final junctionDrag in [false, true]) {
|
||||
testWidgets(
|
||||
'${junctionDrag ? 'junction' : 'sidebar'} persists resize only when the gesture ends',
|
||||
(tester) async {
|
||||
final mounted = await mount(tester, const Size(1800, 800));
|
||||
final repository = mounted.container.read(
|
||||
workspaceViewSettingsRepositoryProvider,
|
||||
);
|
||||
final savedBefore = (await tester.runAsync(repository.load))!;
|
||||
final sidebar = find.byKey(const Key('desktop-chat-card'));
|
||||
final initialWidth = tester.getSize(sidebar).width;
|
||||
final handle = find.byKey(
|
||||
Key(
|
||||
junctionDrag
|
||||
? 'desktop-chat-timeline-junction'
|
||||
: 'project-sidebar-resize',
|
||||
),
|
||||
);
|
||||
final drag = await tester.startGesture(
|
||||
tester.getCenter(handle),
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
for (var i = 0; i < 5; i++) {
|
||||
await drag.moveBy(Offset(10, junctionDrag ? -10 : 0));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
expect(tester.getSize(sidebar).width, initialWidth + 50);
|
||||
final savedDuring = (await tester.runAsync(repository.load))!;
|
||||
expect(savedDuring.sidebarWidth, savedBefore.sidebarWidth);
|
||||
// Cancellation also commits the last visible size.
|
||||
if (junctionDrag) {
|
||||
await drag.cancel();
|
||||
} else {
|
||||
await drag.up();
|
||||
}
|
||||
await tester.pumpAndSettle();
|
||||
final savedAfter = (await tester.runAsync(repository.load))!;
|
||||
expect(savedAfter.sidebarWidth, initialWidth + 50);
|
||||
await mounted.close();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
for (final junctionDrag in [false, true]) {
|
||||
testWidgets(
|
||||
'${junctionDrag ? 'junction' : 'sidebar'} drag snaps closed and can drag back open',
|
||||
(tester) async {
|
||||
final mounted = await mount(tester, const Size(1800, 800));
|
||||
final sidebar = find.byKey(const Key('desktop-chat-card'));
|
||||
final resize = find.byKey(const Key('project-sidebar-resize'));
|
||||
final junction = find.byKey(
|
||||
const Key('desktop-chat-timeline-junction'),
|
||||
);
|
||||
final initialWidth = tester.getSize(sidebar).width;
|
||||
final initialTimeline = tester
|
||||
.getSize(find.byKey(const Key('editor-timeline-card')))
|
||||
.height;
|
||||
final editor = tester.element(find.byType(EditorWorkspace));
|
||||
final input = find.descendant(
|
||||
of: find.byType(AgentChatPanel),
|
||||
matching: find.byType(TextField),
|
||||
);
|
||||
await tester.enterText(input, 'Draft survives sidebar snapping');
|
||||
final start = tester.getCenter(junctionDrag ? junction : resize);
|
||||
final drag = await tester.startGesture(
|
||||
start,
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
await drag.moveTo(
|
||||
start + Offset(115 - initialWidth, junctionDrag ? -30 : 0),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.getSize(sidebar).width, 220);
|
||||
await drag.moveBy(Offset(-6, junctionDrag ? -20 : 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(sidebar, findsNothing);
|
||||
expect(resize, findsOneWidget);
|
||||
expect(
|
||||
mounted.container
|
||||
.read(workspaceViewSettingsProvider)
|
||||
.requireValue
|
||||
.sidebarCollapsed,
|
||||
isTrue,
|
||||
);
|
||||
// Crossing back over the threshold within the same gesture restores it.
|
||||
await drag.moveBy(const Offset(16, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.getSize(sidebar).width, 220);
|
||||
await drag.moveBy(Offset(-16, junctionDrag ? -20 : 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(sidebar, findsNothing);
|
||||
if (junctionDrag) {
|
||||
expect(junction, findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.getSize(find.byKey(const Key('editor-timeline-card')))
|
||||
.height,
|
||||
closeTo(initialTimeline + 70, .01),
|
||||
);
|
||||
await drag.cancel();
|
||||
} else {
|
||||
await drag.up();
|
||||
}
|
||||
await tester.pumpAndSettle();
|
||||
expect(junction, findsOneWidget);
|
||||
final saved = await tester.runAsync(
|
||||
mounted.container.read(workspaceViewSettingsRepositoryProvider).load,
|
||||
);
|
||||
expect(saved!.sidebarCollapsed, isTrue);
|
||||
expect(saved.sidebarWidth, initialWidth);
|
||||
if (junctionDrag) {
|
||||
final savedProject = await tester.runAsync(
|
||||
() => mounted.container
|
||||
.read(projectViewSettingsRepositoryProvider)
|
||||
.load(mounted.projectId),
|
||||
);
|
||||
expect(
|
||||
savedProject!.timelineHeight,
|
||||
closeTo(initialTimeline + 70, .01),
|
||||
);
|
||||
}
|
||||
|
||||
await tester.tap(find.byKey(const Key('project-sidebar-toggle')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.getSize(sidebar).width, initialWidth);
|
||||
expect(tester.element(find.byType(EditorWorkspace)), same(editor));
|
||||
expect(
|
||||
tester.widget<TextField>(input).controller!.text,
|
||||
'Draft survives sidebar snapping',
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('project-sidebar-toggle')));
|
||||
await tester.pumpAndSettle();
|
||||
// A fresh edge or junction drag starts from the collapsed width of zero.
|
||||
final edgeTimeline = tester
|
||||
.getSize(find.byKey(const Key('editor-timeline-card')))
|
||||
.height;
|
||||
expect(junction, findsOneWidget);
|
||||
final edge = await tester.startGesture(
|
||||
tester.getCenter(junctionDrag ? junction : resize),
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
await edge.moveBy(Offset(109, junctionDrag ? -25 : 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(sidebar, findsNothing);
|
||||
if (junctionDrag) {
|
||||
expect(
|
||||
tester
|
||||
.getSize(find.byKey(const Key('editor-timeline-card')))
|
||||
.height,
|
||||
closeTo(edgeTimeline + 25, .01),
|
||||
);
|
||||
}
|
||||
await edge.moveBy(const Offset(1, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.getSize(sidebar).width, 220);
|
||||
await edge.moveBy(const Offset(140, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.getSize(sidebar).width, 250);
|
||||
await edge.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
mounted.container
|
||||
.read(workspaceViewSettingsProvider)
|
||||
.requireValue
|
||||
.sidebarCollapsed,
|
||||
isFalse,
|
||||
);
|
||||
final reopened = await tester.runAsync(
|
||||
mounted.container.read(workspaceViewSettingsRepositoryProvider).load,
|
||||
);
|
||||
expect(reopened!.sidebarCollapsed, isFalse);
|
||||
expect(reopened.sidebarWidth, 250);
|
||||
if (junctionDrag) {
|
||||
final reopenedProject = await tester.runAsync(
|
||||
() => mounted.container
|
||||
.read(projectViewSettingsRepositoryProvider)
|
||||
.load(mounted.projectId),
|
||||
);
|
||||
expect(
|
||||
reopenedProject!.timelineHeight,
|
||||
closeTo(edgeTimeline + 25, .01),
|
||||
);
|
||||
}
|
||||
expect(
|
||||
tester.widget<TextField>(input).controller!.text,
|
||||
'Draft survives sidebar snapping',
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
await mounted.close();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('project tabs switch scoped drafts and preserve failed close', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -504,9 +858,9 @@ void main() {
|
||||
);
|
||||
expect(preview.top, properties.top);
|
||||
expect(preview.bottom, properties.bottom);
|
||||
expect(properties.left - preview.right, 6);
|
||||
expect(properties.left - preview.right, 2);
|
||||
expect(playback.bottom, preview.bottom - 1);
|
||||
expect(playback.height, 36);
|
||||
expect(playback.height, 32);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('timeline-tabs-bar'))).height,
|
||||
32,
|
||||
@@ -527,7 +881,7 @@ void main() {
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('timeline-toolbar'))).height,
|
||||
36,
|
||||
32,
|
||||
);
|
||||
expect(tester.element(find.byType(EditorWorkspace)), same(editor));
|
||||
expect(AppColors.of(Theme.of(editor)).family, palette);
|
||||
@@ -839,9 +1193,9 @@ void main() {
|
||||
contentRect.top,
|
||||
tester.getRect(find.byKey(const Key('desktop-window-header'))).bottom,
|
||||
);
|
||||
expect(contentRect.left, 6);
|
||||
expect(contentRect.right, 1194);
|
||||
expect(contentRect.bottom, 794);
|
||||
expect(contentRect.left, 46);
|
||||
expect(contentRect.right, 1198);
|
||||
expect(contentRect.bottom, 798);
|
||||
expect(
|
||||
tester.getRect(find.byKey(const Key('window-minimize'))).left -
|
||||
tester
|
||||
@@ -1022,8 +1376,14 @@ void main() {
|
||||
expect(left.left - headerRect.left, AppSidebarMetrics.outerPadding);
|
||||
expect(headerRect.right - right.right, AppSidebarMetrics.outerPadding);
|
||||
expect(middle.center.dx, closeTo(headerRect.center.dx, 0.01));
|
||||
expect(middle.left, greaterThanOrEqualTo(left.right));
|
||||
expect(middle.right, lessThanOrEqualTo(right.left));
|
||||
expect(
|
||||
middle.left - left.right,
|
||||
greaterThanOrEqualTo(AppSpacing.small),
|
||||
);
|
||||
expect(
|
||||
right.left - middle.right,
|
||||
greaterThanOrEqualTo(AppSpacing.small),
|
||||
);
|
||||
expect(left.center.dy, right.center.dy);
|
||||
expect(tester.widget<Text>(title).overflow, TextOverflow.ellipsis);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
Reference in new issue
Block a user