// SPDX-FileCopyrightText: 2026 FocusFlow contributors
// SPDX-License-Identifier: AGPL-3.0-only

/// Tests Repo Contract Smoke behavior for the Scheduler Persistence package.
library;

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

/// Entry point for this executable Dart file.
/// It wires the local command, test, or application behavior needed by this repository without exposing additional public API.
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);
    });
  });
}
