chore: client 및 oto_console 테스트 및 surface 코드 수정

This commit is contained in:
toki 2026-07-06 09:25:16 +09:00
parent 51c5a0f74b
commit 035a2ce42c
4 changed files with 118 additions and 25 deletions

View file

@ -736,6 +736,7 @@ class _OtoClientAppState extends State<OtoClientApp> {
themeAdapter: themeAdapter,
jobCreateState: _jobCreateState,
showCreateForm: _showJobCreateForm,
createOnly: _showJobCreateForm,
onCreateJob: _submitJobCreate,
onExecutionTap: (execID) {
_loadExecutionDetail(execID);

View file

@ -1441,6 +1441,8 @@ void _registerJobCreateTests() {
await tester.tap(_newItemMenuButton());
await tester.pumpAndSettle();
expect(find.text('New Item section'), findsOneWidget);
expect(find.text('Pipelines / Jobs'), findsNothing);
expect(find.text('No pipeline jobs'), findsNothing);
expect(find.byType(TextField), findsNWidgets(2));
expect(find.text('Create'), findsOneWidget);
@ -1489,7 +1491,6 @@ void _registerJobCreateTests() {
),
findsOneWidget,
);
expect(find.textContaining('created-job-1'), findsOneWidget);
// Verify refresh fetched the created job
await tester.tap(find.byTooltip('Executions'));
@ -1497,6 +1498,7 @@ void _registerJobCreateTests() {
await tester.tap(find.byTooltip('Pipelines'));
await tester.pumpAndSettle();
expect(find.text('Created Job'), findsOneWidget);
expect(find.text('Job ID: created-job-1'), findsOneWidget);
// --- Test failed result shows error message ---
createCallCount = 0;
@ -1613,6 +1615,7 @@ void _registerJobCreateTests() {
await tester.pumpAndSettle();
expect(find.text('New Item section'), findsOneWidget);
expect(find.text('Pipelines / Jobs'), findsNothing);
expect(find.byType(TextField), findsNWidgets(2));
});
@ -1671,6 +1674,7 @@ void _registerJobCreateTests() {
await tester.pumpAndSettle();
expect(find.text('New Item section'), findsOneWidget);
expect(find.text('Pipelines / Jobs'), findsNothing);
expect(find.byType(TextField), findsNWidgets(2));
});
}

View file

@ -7,6 +7,7 @@ class OtoJobsSurface extends StatefulWidget {
final ValueChanged<String>? onExecutionTap;
final OtoActionViewState? jobCreateState;
final bool showCreateForm;
final bool createOnly;
final ValueChanged<OtoJobCreateDraft>? onCreateJob;
const OtoJobsSurface({
@ -16,6 +17,7 @@ class OtoJobsSurface extends StatefulWidget {
this.onExecutionTap,
this.jobCreateState,
this.showCreateForm = true,
this.createOnly = false,
this.onCreateJob,
});
@ -48,6 +50,12 @@ class _OtoJobsSurfaceState extends State<OtoJobsSurface> {
Widget build(BuildContext context) {
final theme = widget.themeAdapter ?? const OtoConsoleThemeAdapter();
final jobCount = widget.snapshot.data?.length ?? 0;
final showCreateForm =
widget.showCreateForm && widget.jobCreateState != null;
final title = widget.createOnly ? 'New Item' : 'Pipelines / Jobs';
final icon = widget.createOnly
? Icons.add_circle_outline
: Icons.account_tree_outlined;
return Container(
color: theme.backgroundColor,
padding: const EdgeInsets.all(24),
@ -56,15 +64,11 @@ class _OtoJobsSurfaceState extends State<OtoJobsSurface> {
children: [
Row(
children: [
Icon(
Icons.account_tree_outlined,
color: theme.primaryColor,
size: 24,
),
Icon(icon, color: theme.primaryColor, size: 24),
const SizedBox(width: 12),
Expanded(
child: Text(
'Pipelines / Jobs',
title,
style: TextStyle(
color: theme.textColor,
fontSize: 24,
@ -75,16 +79,21 @@ class _OtoJobsSurfaceState extends State<OtoJobsSurface> {
],
),
const SizedBox(height: 16),
if (!widget.createOnly) ...[
_BuildContextStrip(theme: theme, jobCount: jobCount),
const SizedBox(height: 20),
if (widget.showCreateForm && widget.jobCreateState != null) ...[
],
if (showCreateForm) ...[
_CreatePanel(
theme: theme,
child: _buildJobCreateForm(context, theme),
),
const SizedBox(height: 20),
],
Expanded(child: _buildContent(context, theme)),
if (!widget.createOnly)
Expanded(child: _buildContent(context, theme))
else if (!showCreateForm)
Expanded(child: _buildCreateUnavailableState(theme)),
],
),
);
@ -309,6 +318,43 @@ class _OtoJobsSurfaceState extends State<OtoJobsSurface> {
],
);
}
Widget _buildCreateUnavailableState(OtoConsoleThemeAdapter theme) {
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: theme.railBackgroundColor,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: theme.borderColor),
),
child: Row(
children: [
Icon(Icons.add_circle_outline, color: theme.primaryColor, size: 32),
const SizedBox(width: 16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Pipeline creation unavailable',
style: TextStyle(
color: theme.textColor,
fontSize: 18,
fontWeight: FontWeight.w800,
),
),
const SizedBox(height: 4),
Text(
'No create surface is mounted.',
style: TextStyle(color: theme.textSecondaryColor),
),
],
),
),
],
),
);
}
}
/// Build Queue / Build History context strip shown above the job table.

View file

@ -103,9 +103,11 @@ void main() {
);
final navigations = <OtoConsoleSection>[];
var newItemTaps = 0;
var showCreate = false;
await tester.pumpWidget(
MaterialApp(
StatefulBuilder(
builder: (context, setHostState) => MaterialApp(
home: OtoConsoleShell(
config: config,
overview: const OtoConsoleOverview(
@ -115,14 +117,25 @@ void main() {
pipelines: OtoJobsSurface(
snapshot: const OtoSurfaceSnapshot.empty(),
jobCreateState: const OtoActionViewState.idle(),
showCreateForm: showCreate,
createOnly: showCreate,
onCreateJob: (_) {},
),
onNavigate: navigations.add,
onNavigate: (section) {
navigations.add(section);
setHostState(() {
showCreate = false;
});
},
onNewItem: () {
newItemTaps++;
setHostState(() {
showCreate = true;
});
},
),
),
),
);
await tester.tap(find.text('New Item'));
@ -131,12 +144,17 @@ void main() {
expect(navigations, [OtoConsoleSection.pipelines]);
expect(newItemTaps, 1);
expect(find.text('New Item section'), findsOneWidget);
expect(find.text('Pipelines / Jobs'), findsNothing);
expect(find.text('No pipeline jobs'), findsNothing);
expect(find.byType(TextField), findsNWidgets(2));
await tester.tap(find.byTooltip('Pipelines'));
await tester.pumpAndSettle();
expect(find.text('Pipelines section'), findsOneWidget);
expect(find.text('Pipelines / Jobs'), findsOneWidget);
expect(find.text('No pipeline jobs'), findsOneWidget);
expect(find.byType(TextField), findsNothing);
});
testWidgets('renders section surfaces with empty states', (tester) async {
@ -954,4 +972,28 @@ void main() {
expect(find.text('No pipeline jobs'), findsOneWidget);
},
);
testWidgets('OtoJobsSurface renders a create-only New Item surface', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: OtoJobsSurface(
snapshot: const OtoSurfaceSnapshot.empty(),
jobCreateState: const OtoActionViewState.idle(),
showCreateForm: true,
createOnly: true,
onCreateJob: (draft) {},
),
),
),
);
expect(find.text('Pipelines / Jobs'), findsNothing);
expect(find.text('Build Queue'), findsNothing);
expect(find.text('No pipeline jobs'), findsNothing);
expect(find.byType(TextField), findsNWidgets(2));
expect(find.text('Create'), findsOneWidget);
});
}