Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

1.7 KB
Raw Blame
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness_mobile/phone/welcome/phone_welcome.dart';
import 'package:harness_mobile/swarm/parts.dart';
import 'package:harness_mobile/swarm/swarm_kept.dart';

import '../phone_edge/edge_fixture.dart';
import 'swarm_fixture.dart';

/// A phone that starts signed out (its session ended while the app was not
/// running) keeps nothing of the last Swarm Home: the signed-out screen lets
/// it go, view and key, before anyone signs in again.
void main() {
  testWidgets('the signed-out screen lets the Home kept go', (tester) async {
    final home = memoryHomeCache();
    final kept = MemorySwarmKeptStore()..held = {'drafts': <Object>[]};
    await tester.runAsync(
      () => home.write('person-me', [
        (
          id: 'a',
          name: 'Swarm a',
          view: (
            state: SuperTabParts.firstLoad(firstLoad(tabId: 'a')).state,
            partners: const <String, String>{},
          ),
        ),
      ]),
    );
    setPhone(tester, largePhone);
    final app = edgeApp(noMachines: true);

    // On the real clock: the clear the screen starts is real file work.
    await tester.runAsync(() async {
      await tester.pumpWidget(
        phoneApp(PhoneWelcome(notifier: app, swarmHome: home, swarmKept: kept)),
      );
      await home.read('person-me');
    });

    expect(home.file.existsSync(), isFalse);
    expect(kept.held, isNull, reason: 'drafts and unsent posts go too');
    expect((home.key as MemorySwarmHomeKey).value, isNull);

    await tester.pumpWidget(const SizedBox());
    await tester.pump(const Duration(seconds: 3));
    app.dispose();
    await tester.pump(const Duration(seconds: 30));
  });
}