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.

2.5 KB
Raw Blame
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/super_tabs/message_row.dart';

import 'super_tab_mentions_test.dart' show runsOf, showView;
import 'support/super_tab_fixture.dart';

void main() {
  testWidgets(
    'a person is named in message headers and replies, never by their address',
    (tester) async {
      final server = ConversationServer();
      server.state['people'] = [
        {'id': 'owner', 'email': '[email protected]', 'role': 'owner'},
        {'id': 'ivy', 'email': '[email protected]', 'role': 'collaborator'},
      ];
      server.append('Love the generated faces');
      server.messages.last['author'] = {
        'kind': 'person',
        'id': 'ivy',
        'name': '[email protected]',
      };
      server.append('Thanks!');
      server.messages.last['replyTo'] = 'message-1';
      // Someone who has left keeps the name their address gives.
      server.append('Old note');
      server.messages.last['author'] = {
        'kind': 'person',
        'id': 'gone',
        'name': '[email protected]',
      };
      await showView(tester, server);
      expect(find.textContaining('@example.com'), findsNothing);
      expect(
        find.descendant(
          of: find.byKey(const ValueKey('super-message-message-1')),
          matching: find.text('ivy'),
        ),
        findsOneWidget,
      );
      expect(
        find.descendant(
          of: find.byType(SuperTabReplyPreview),
          matching: find.text('ivy'),
        ),
        findsOneWidget,
      );
      expect(find.text('sam'), findsOneWidget);
    },
  );

  testWidgets('a person who chose a username is shown and tagged by it', (
    tester,
  ) async {
    final server = ConversationServer();
    server.state['people'] = [
      {'id': 'owner', 'email': '[email protected]', 'role': 'owner'},
      {
        'id': 'ivy',
        'email': '[email protected]',
        'role': 'collaborator',
        'username': 'ivy.k',
      },
    ];
    server.append('Over to @ivy.k for the copy.');
    server.messages.last['author'] = {
      'kind': 'person',
      'id': 'ivy',
      'name': '[email protected]',
    };
    server.messages.last['mentions'] = ['ivy'];
    await showView(tester, server);
    expect(
      find.descendant(
        of: find.byKey(const ValueKey('super-message-message-1')),
        matching: find.text('ivy.k'),
      ),
      findsOneWidget,
    );
    expect(runsOf(tester, '@ivy.k').single?.backgroundColor, isNotNull);
    expect(find.textContaining('@example.com'), findsNothing);
  });
}