fix(settings): preserve server editor drafts until save succeeds
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import 'dart:js_interop';
|
||||
import 'dart:js_interop_unsafe';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pipelines_app/core/servers/server_catalog.dart';
|
||||
import 'package:pipelines_app/core/servers/server_catalog_store.dart';
|
||||
import 'package:pipelines_app/features/settings/saved_servers_section.dart';
|
||||
import 'package:pipelines_app/features/settings/server_connections.dart';
|
||||
|
||||
// Isolated, in-memory browser fixture: first write fails, retry succeeds.
|
||||
// No sockets, real storage, or production requests.
|
||||
void main() {
|
||||
final cupertino = Uri.base.queryParameters['host'] == 'cupertino';
|
||||
final connections = ServerConnections(
|
||||
store: _Store(),
|
||||
onSelected: (_) async {},
|
||||
);
|
||||
final body = SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: SavedServersSection(connections: connections),
|
||||
),
|
||||
);
|
||||
runApp(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: body))
|
||||
: MaterialApp(home: Scaffold(body: body)),
|
||||
);
|
||||
}
|
||||
|
||||
class _Store extends MemoryServerCatalogStore {
|
||||
var _attempts = 0;
|
||||
|
||||
@override
|
||||
Future<bool> save(ServerCatalog catalog) async {
|
||||
globalContext.setProperty(
|
||||
'serverEditorSaveAttempts'.toJS,
|
||||
(++_attempts).toJS,
|
||||
);
|
||||
await Future<void>.delayed(const Duration(seconds: 3));
|
||||
if (_attempts == 1) return false;
|
||||
return super.save(catalog);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user