feat(welcome): New project flow + per-repo account roadblock (T-488)
The UI half of the new-project flow (story T-486). A "New project…" welcome action opens a dialog (location + name) that dispatches project.new (T-487), opens the result, and announces it on projectCreatedChannel. The Claude extension consumes that and shows the account roadblock — the embedded per-workspace picker + accounts list, so a fresh project gets bound to an account (or Default) right at birth. The two halves stay decoupled: the welcome builtin only publishes the event (no claude import); the claude builtin owns the account dialog. Only freshly- created projects announce, so existing opens are never prompted. Closes T-488. The non-repo "initialize as a project" path (T-489) is next. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/// T-488: the new-project account roadblock dialog renders the project title,
|
||||
/// hosts the per-workspace picker + the accounts list (both already tested on
|
||||
/// their own), and dismisses on Continue / Escape.
|
||||
library;
|
||||
|
||||
import 'package:clide/builtin/claude/src/account_registry.dart';
|
||||
import 'package:clide/builtin/claude/src/account_roadblock_dialog.dart';
|
||||
import 'package:clide/builtin/claude/src/account_settings_control.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../helpers/kernel_fixture.dart';
|
||||
import '../../helpers/widget_harness.dart';
|
||||
|
||||
void main() {
|
||||
late KernelFixture f;
|
||||
setUp(() async => f = await KernelFixture.create());
|
||||
tearDown(() async => f.dispose());
|
||||
|
||||
Future<void> pump(WidgetTester tester, {required VoidCallback onClose}) async {
|
||||
await tester.runAsync(() async {
|
||||
await f.services.settings.setProjectDir(f.tempDir);
|
||||
await AccountRegistry(f.services.settings).registerAccount('work', '/home/u/.claude-work');
|
||||
});
|
||||
await tester.pumpWidget(
|
||||
harness(
|
||||
f,
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: ClaudeAccountRoadblockDialog(projectName: 'myapp', onClose: onClose),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
testWidgets('renders the title + both account controls; Continue dismisses', (tester) async {
|
||||
var closed = false;
|
||||
await pump(tester, onClose: () => closed = true);
|
||||
expect(find.text('Claude account for myapp'), findsOneWidget);
|
||||
expect(find.byType(ClaudeWorkspaceAccountControl), findsOneWidget);
|
||||
expect(find.byType(ClaudeAccountsListControl), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Continue'));
|
||||
await tester.pump();
|
||||
expect(closed, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Escape dismisses', (tester) async {
|
||||
var closed = false;
|
||||
await pump(tester, onClose: () => closed = true);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pump();
|
||||
expect(closed, isTrue);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/// T-488: the welcome New-project dialog. Tapping "New project…" opens it;
|
||||
/// filling location + name and pressing Create dispatches `project.new`, opens
|
||||
/// the result, and announces it on projectCreatedChannel (so the Claude
|
||||
/// extension can run the account roadblock). Reached through WelcomeView since
|
||||
/// the dialog is private, wrapped in a DialogHost so kernel.dialog.show renders.
|
||||
library;
|
||||
|
||||
import 'package:clide/builtin/welcome/src/welcome_view.dart';
|
||||
import 'package:clide/clide.dart';
|
||||
import 'package:clide/kernel/kernel.dart';
|
||||
import 'package:clide/src/daemon/project_commands.dart' show projectCreatedChannel;
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../helpers/kernel_fixture.dart';
|
||||
import '../../helpers/widget_harness.dart';
|
||||
|
||||
Widget _harness(KernelFixture f, Widget child) => harness(f, DialogHost(router: f.services.dialog, child: child));
|
||||
|
||||
void main() {
|
||||
late KernelFixture f;
|
||||
setUp(() async => f = await KernelFixture.create());
|
||||
tearDown(() async => f.dispose());
|
||||
|
||||
testWidgets('Create dispatches project.new, opens the result, and announces it', (tester) async {
|
||||
Map<String, Object?>? newArgs;
|
||||
f.ipc.setConnected(true);
|
||||
f.ipc.stub('project.new', (args) async {
|
||||
newArgs = args;
|
||||
return IpcResponse.ok(id: 'r', data: {'path': '/tmp/np/myapp', 'name': 'myapp'});
|
||||
});
|
||||
final announced = <Map<String, Object?>>[];
|
||||
final sub = f.services.messages.subscribe(channel: projectCreatedChannel).listen((m) => announced.add(m.data));
|
||||
addTearDown(sub.cancel);
|
||||
|
||||
tester.view.physicalSize = const Size(1200, 900);
|
||||
tester.view.devicePixelRatio = 1.0;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
await tester.pumpWidget(_harness(f, const WelcomeView()));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('New project…'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('New project'), findsOneWidget);
|
||||
|
||||
final fields = find.byType(EditableText);
|
||||
await tester.enterText(fields.at(0), '/tmp/np'); // location
|
||||
await tester.enterText(fields.at(1), 'myapp'); // name
|
||||
await tester.tap(find.text('Create'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(newArgs?['positional'], ['myapp']);
|
||||
expect((newArgs?['flags'] as Map)['dir'], '/tmp/np');
|
||||
expect(announced.single['dir'], '/tmp/np/myapp');
|
||||
});
|
||||
|
||||
testWidgets('Create with an empty name surfaces an error and does not dispatch', (tester) async {
|
||||
var called = false;
|
||||
f.ipc.setConnected(true);
|
||||
f.ipc.stub('project.new', (args) async {
|
||||
called = true;
|
||||
return IpcResponse.ok(id: 'r', data: {'path': '/x', 'name': 'x'});
|
||||
});
|
||||
|
||||
tester.view.physicalSize = const Size(1200, 900);
|
||||
tester.view.devicePixelRatio = 1.0;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
await tester.pumpWidget(_harness(f, const WelcomeView()));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('New project…'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(find.byType(EditableText).at(0), '/tmp/np'); // location only
|
||||
await tester.tap(find.text('Create'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(called, isFalse);
|
||||
expect(find.text('Enter a project name.'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user