style(app): format the lifecycle and settings tests

This commit is contained in:
2026-10-22 15:55:11 +01:00
parent 8b9a298dd1
commit 3f4c8cb00c
2 changed files with 42 additions and 48 deletions
@@ -56,10 +56,7 @@ void main() {
}); });
test('only a dropped socket is reopened on foreground', () { test('only a dropped socket is reopened on foreground', () {
expect( expect(shouldReconnectOnForeground(ConnectionKind.disconnected), isTrue);
shouldReconnectOnForeground(ConnectionKind.disconnected),
isTrue,
);
// A deliberate Disconnect reaches idle and must stay disconnected. // A deliberate Disconnect reaches idle and must stay disconnected.
expect(shouldReconnectOnForeground(ConnectionKind.idle), isFalse); expect(shouldReconnectOnForeground(ConnectionKind.idle), isFalse);
// These states already have their own answer; foregrounding does not churn // These states already have their own answer; foregrounding does not churn
@@ -406,53 +406,50 @@ void main() {
await client.dispose(); await client.dispose();
}); });
test( test('a mismatched protocol warns and the warning survives a drop', () async {
'a mismatched protocol warns and the warning survives a drop', final factory = FakeChannelFactory();
() async { final client = transport.PipelinesClient(channelFactory: factory.call);
final factory = FakeChannelFactory(); final controller = SettingsController(
final client = transport.PipelinesClient(channelFactory: factory.call); client: client,
final controller = SettingsController( store: MemorySettingsStore(),
client: client, );
store: MemorySettingsStore(), await controller.initialize();
); controller.updateServerUrl('ws://example.test:8123');
await controller.initialize(); final connecting = controller.connect();
controller.updateServerUrl('ws://example.test:8123'); await settle();
final connecting = controller.connect(); factory.last.markReady();
await settle(); await connecting;
factory.last.markReady(); await settle();
await connecting; expect(controller.protocolWarning, isNull);
await settle();
expect(controller.protocolWarning, isNull);
factory.last.reply(<String, dynamic>{ factory.last.reply(<String, dynamic>{
'id': factory.last.decodedOutgoing.single['id'], 'id': factory.last.decodedOutgoing.single['id'],
'type': 'pong', 'type': 'pong',
// The server sends an integer, but the comparison is numeric, like the // The server sends an integer, but the comparison is numeric, like the
// web page's Number() rule. // web page's Number() rule.
'protocol': '2', 'protocol': '2',
}); });
await settle(); await settle();
expect( expect(
controller.protocolWarning, controller.protocolWarning,
'Protocol mismatch: this page speaks protocol 1, ' 'Protocol mismatch: this page speaks protocol 1, '
'the server reports 2.', 'the server reports 2.',
); );
factory.last.fail('socket gone'); factory.last.fail('socket gone');
await settle(); await settle();
expect(controller.connection.kind, transport.ConnectionKind.disconnected); expect(controller.connection.kind, transport.ConnectionKind.disconnected);
expect( expect(
controller.protocolWarning, controller.protocolWarning,
isNotNull, isNotNull,
reason: 'a known mismatch stays visible while the socket reconnects', reason: 'a known mismatch stays visible while the socket reconnects',
); );
// Cancel the client's scheduled retry before the test ends. // Cancel the client's scheduled retry before the test ends.
await client.disconnect(); await client.disconnect();
controller.dispose(); controller.dispose();
await client.dispose(); await client.dispose();
}, });
);
test('protocolMismatchWarning ignores matching and absent protocols', () { test('protocolMismatchWarning ignores matching and absent protocols', () {
expect(protocolMismatchWarning(null), isNull); expect(protocolMismatchWarning(null), isNull);