9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
150 lines
4.1 KiB
Dart
150 lines
4.1 KiB
Dart
import 'dart:js_interop';
|
|
import 'dart:js_interop_unsafe';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:pipelines_app/core/api_gateway.dart';
|
|
import 'package:pipelines_app/core/transport/connection_state.dart';
|
|
import 'package:pipelines_app/features/templates/data/template_repository.dart';
|
|
import 'package:pipelines_app/features/templates/domain/template_entry.dart';
|
|
import 'package:pipelines_app/features/templates/ui/template_create_dialog.dart';
|
|
|
|
/// Browser capture entrypoint for the create-from-template prompt.
|
|
///
|
|
/// The fixture gateway is in-process and records every request; nothing here
|
|
/// opens a socket or contacts a real server. The state published at
|
|
/// `globalThis.templateCreateProbe` is read by the probe driver, so it can
|
|
/// prove that a validation refusal sent no submit and that an accepted create
|
|
/// was reported once.
|
|
const _source = ' name: "release"\n stages:\n - key: "añadir" 😀 \n';
|
|
|
|
class _ProbeGateway implements ApiGateway {
|
|
_ProbeGateway(this.publish);
|
|
|
|
final VoidCallback publish;
|
|
int validates = 0;
|
|
int submits = 0;
|
|
bool failNextValidate = true;
|
|
String? lastSource;
|
|
JsonMap? lastSubmit;
|
|
final List<JsonMap> created = [];
|
|
|
|
@override
|
|
Stream<JsonMap> get frames => const Stream.empty();
|
|
|
|
@override
|
|
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async {
|
|
if (type == 'validate') {
|
|
validates++;
|
|
lastSource = fields['source'] as String?;
|
|
publish();
|
|
if (failNextValidate) {
|
|
failNextValidate = false;
|
|
throw const ProtocolError(
|
|
'invalid definition: fixture stage "añadir" has no type',
|
|
);
|
|
}
|
|
return {
|
|
'graph': {'stages': []},
|
|
};
|
|
}
|
|
if (type == 'submit') {
|
|
submits++;
|
|
lastSubmit = Map<String, dynamic>.from(fields);
|
|
publish();
|
|
return {
|
|
'detail': {'id': 71, 'name': 'Probe release'},
|
|
};
|
|
}
|
|
throw StateError('The create probe does not implement $type');
|
|
}
|
|
}
|
|
|
|
void main() => runApp(const _ProbeApp());
|
|
|
|
class _ProbeApp extends StatelessWidget {
|
|
const _ProbeApp();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final params = Uri.base.queryParameters;
|
|
final scale = double.tryParse(params['scale'] ?? '') ?? 1;
|
|
Widget scaled(BuildContext context, Widget? app) => MediaQuery(
|
|
data: MediaQuery.of(
|
|
context,
|
|
).copyWith(textScaler: TextScaler.linear(scale)),
|
|
child: app!,
|
|
);
|
|
return MaterialApp(
|
|
theme: ThemeData(platform: TargetPlatform.android),
|
|
builder: scaled,
|
|
home: const _ProbeHome(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ProbeHome extends StatefulWidget {
|
|
const _ProbeHome();
|
|
|
|
@override
|
|
State<_ProbeHome> createState() => _ProbeHomeState();
|
|
}
|
|
|
|
class _ProbeHomeState extends State<_ProbeHome> {
|
|
late final _gateway = _ProbeGateway(_publish);
|
|
|
|
static const _template = TemplateEntry(
|
|
key: 'release',
|
|
name: 'Release workflow',
|
|
description: 'Fixture template',
|
|
source: _source,
|
|
scheduled: false,
|
|
raw: {},
|
|
);
|
|
|
|
void _publish() {
|
|
globalContext.setProperty(
|
|
'templateCreateProbe'.toJS,
|
|
<String, Object?>{
|
|
'validates': _gateway.validates,
|
|
'submits': _gateway.submits,
|
|
'lastSource': _gateway.lastSource,
|
|
'lastSubmit': _gateway.lastSubmit,
|
|
'created': _gateway.created,
|
|
}.jsify(),
|
|
);
|
|
}
|
|
|
|
Future<void> _open() async {
|
|
await showTemplateCreateDialog(
|
|
context: context,
|
|
template: _template,
|
|
repository: TemplateRepository(_gateway),
|
|
onCreated: (detail) {
|
|
_gateway.created.add(detail);
|
|
_publish();
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Template create probe')),
|
|
body: Center(
|
|
child: SingleChildScrollView(
|
|
padding: const EdgeInsets.all(24),
|
|
child: FilledButton(
|
|
key: const ValueKey<String>('template-probe-open'),
|
|
onPressed: _open,
|
|
child: const Text(
|
|
'Create pipeline from this template',
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|