import 'package:scheduler_core/scheduler_core.dart' as core;
import 'package:scheduler_persistence/persistence.dart';
import 'package:test/test.dart';

void main() {
  group('repository contract smoke test', () {
    test('exports required repository interfaces', () {
      expect(TaskRepository, isNotNull);
      expect(ProjectRepository, isNotNull);
      expect(LockedBlockRepository, isNotNull);
      expect(SettingsRepository, isNotNull);
      expect(ScheduleSnapshotRepository, isNotNull);
    });

    test('repo result carries typed success and failure values', () {
      const success = Right<RepositoryFailure, core.Revision>(
        core.Revision.initial,
      );
      const failure = Left<RepositoryFailure, core.Revision>(
        RepositoryNotFound(entityId: 'missing'),
      );

      expect(success.isRight, isTrue);
      expect(success.right, core.Revision.initial);
      expect(failure.isLeft, isTrue);
      expect(failure.left, isA<RepositoryNotFound>());
    });

    test('shared core value objects are available to adapters', () {
      final ownerId = core.OwnerId(' owner-1 ');
      final page = core.Page<String>(items: const ['a'], nextCursor: 'next');

      expect(ownerId.value, 'owner-1');
      expect(core.Revision.initial.next(), const core.Revision(2));
      expect(const core.PageRequest(limit: 10).limit, 10);
      expect(page.items, const ['a']);
      expect(page.hasMore, isTrue);
    });
  });
}
