mirror of
https://github.com/block/buzz.git
synced 2026-11-24 18:21:59 +00:00
Replace the signed-in mobile welcome screen with **Add a community**: QR scan first, then grey secondary actions for community links, finding saved communities, and creation. Hide **Find my communities** when none are known; refresh on entry/resume and every 30 seconds while active, retaining results on transient failure. Community switcher → Add keeps its two-action flow and uses the same grey secondary link button. Validation: Flutter analysis, full mobile suite (4,014 tests), Builderlab-enabled full suite (4,036 tests), widget interactions, and independent agent review. Draft pending native sign-in and human testing. Snapshots render the production Flutter widgets; native navigation/status bars are omitted. | Communities available | No communities | Switcher → Add | |---|---|---| |  |  |  | --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
118 lines
3.5 KiB
Dart
118 lines
3.5 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:buzz/shared/hosted/use_known_communities.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
testWidgets('discovery refreshes, retains results on error and pauses', (
|
|
tester,
|
|
) async {
|
|
var calls = 0;
|
|
var active = true;
|
|
var fail = false;
|
|
Future<bool> load() async {
|
|
calls++;
|
|
if (fail) throw StateError('offline');
|
|
return calls > 1;
|
|
}
|
|
|
|
Widget page() => MaterialApp(
|
|
home: HookBuilder(
|
|
builder: (_) {
|
|
final found = useKnownCommunities(
|
|
accountKey: 'a',
|
|
active: active,
|
|
load: load,
|
|
);
|
|
return Text(found ? 'found' : 'empty');
|
|
},
|
|
),
|
|
);
|
|
await tester.pumpWidget(page());
|
|
await tester.pump();
|
|
expect(calls, 1);
|
|
expect(find.text('empty'), findsOneWidget);
|
|
await tester.pump(const Duration(seconds: 30));
|
|
await tester.pump();
|
|
expect(find.text('found'), findsOneWidget);
|
|
fail = true;
|
|
await tester.pump(const Duration(seconds: 30));
|
|
await tester.pump();
|
|
expect(find.text('found'), findsOneWidget);
|
|
active = false;
|
|
await tester.pumpWidget(page());
|
|
final pausedCalls = calls;
|
|
await tester.pump(const Duration(minutes: 1));
|
|
expect(calls, pausedCalls);
|
|
await tester.pumpWidget(const SizedBox());
|
|
});
|
|
|
|
testWidgets('account change discards old results and in-flight responses', (
|
|
tester,
|
|
) async {
|
|
var account = 'a';
|
|
final first = Completer<bool>();
|
|
Widget page() => MaterialApp(
|
|
home: HookBuilder(
|
|
builder: (_) {
|
|
final found = useKnownCommunities(
|
|
accountKey: account,
|
|
active: true,
|
|
load: () => account == 'a' ? first.future : Future.value(false),
|
|
);
|
|
return Text(found ? 'found' : 'empty');
|
|
},
|
|
),
|
|
);
|
|
await tester.pumpWidget(page());
|
|
await tester.pump(const Duration(seconds: 30));
|
|
account = 'b';
|
|
await tester.pumpWidget(page());
|
|
await tester.pump();
|
|
first.complete(true);
|
|
await tester.pump();
|
|
expect(find.text('empty'), findsOneWidget);
|
|
await tester.pumpWidget(const SizedBox());
|
|
});
|
|
|
|
testWidgets('backgrounding stops requests and resuming refreshes', (
|
|
tester,
|
|
) async {
|
|
var calls = 0;
|
|
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: HookBuilder(
|
|
builder: (_) {
|
|
useKnownCommunities(
|
|
accountKey: 'a',
|
|
active: true,
|
|
load: () async {
|
|
calls++;
|
|
return true;
|
|
},
|
|
);
|
|
return const SizedBox();
|
|
},
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
expect(calls, 1);
|
|
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
|
|
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.hidden);
|
|
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.paused);
|
|
await tester.pump();
|
|
await tester.pump(const Duration(minutes: 1));
|
|
expect(calls, 1);
|
|
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.hidden);
|
|
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
|
|
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
|
|
await tester.pump();
|
|
expect(calls, 2);
|
|
await tester.pumpWidget(const SizedBox());
|
|
});
|
|
}
|