Keep browser chat server connections together in saved-server settings
This commit is contained in:
@@ -2,6 +2,10 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.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/server_connections.dart';
|
||||
import 'package:pipelines_app/features/settings/saved_servers_section.dart';
|
||||
import 'package:pipelines_app/features/settings/saved_server_row.dart';
|
||||
import 'package:pipelines_app/features/settings/saved_server_editor.dart';
|
||||
import 'package:pipelines_app/features/onboarding/discovery/browser_server_discovery.dart';
|
||||
import 'package:pipelines_app/features/onboarding/onboarding_flow.dart';
|
||||
@@ -20,6 +24,49 @@ BrowserServerDiscovery discovery() => BrowserServerDiscovery(
|
||||
);
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'browser server rows cannot navigate away by selecting one machine',
|
||||
(tester) async {
|
||||
final home = SavedServer.validated(
|
||||
id: 'home',
|
||||
name: 'Home',
|
||||
endpoints: ['wss://home.test/connect'],
|
||||
);
|
||||
final other = SavedServer.validated(
|
||||
id: 'other',
|
||||
name: 'Other',
|
||||
endpoints: ['wss://other.test/connect'],
|
||||
);
|
||||
final connections = ServerConnections(
|
||||
store: MemoryServerCatalogStore(
|
||||
catalog: ServerCatalog(servers: [home, other], selectedId: home.id),
|
||||
),
|
||||
onSelected: (_) async =>
|
||||
fail('Browser must keep all chat connections in this page'),
|
||||
);
|
||||
addTearDown(connections.dispose);
|
||||
await connections.load();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SavedServersSection(
|
||||
connections: connections,
|
||||
allowPrimarySelection: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text('Other'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(connections.catalog.active!.id, 'home');
|
||||
await tester.tap(find.byKey(savedServerMenuKey('other')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('Use Other'), findsNothing);
|
||||
expect(find.text('Edit Other'), findsOneWidget);
|
||||
expect(find.text('Remove Other'), findsOneWidget);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'choosing a discovered machine prefills editable name and address',
|
||||
(tester) async {
|
||||
|
||||
@@ -181,7 +181,7 @@ void main() {
|
||||
);
|
||||
|
||||
expect(find.byType(SavedServerRow), findsNWidgets(2));
|
||||
expect(find.text('Selected server'), findsOneWidget);
|
||||
expect(find.text('Pipelines and runs server'), findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(widget) => widget is Icon && widget.semanticLabel == 'Selected',
|
||||
|
||||
Reference in New Issue
Block a user