.cursor/skills/integration-test-patterns/SKILL.md
--- name: integration-test-patterns description: Guides integration test patterns: end-to-end workflows, cross-layer testing, real dependencies, no mocks unless approved. Use when writing integration tests, testing complete features, or validating system integration. --- # Integration Test Patterns ## Core Principle **Integration tests verify complete features work in the system.** Use real dependencies whenever possible. ## Integration Test Types ### End-to-End Workflows Test complete user
npx skillsauth add avra-cadavra/avrai .cursor/skills/integration-test-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Integration tests verify complete features work in the system. Use real dependencies whenever possible.
Test complete user journeys from UI to data layer:
/// Complete user workflow: Sign up → Create spot → Add to list
testWidgets('complete user workflow', (tester) async {
// Initialize app
await tester.pumpWidget(MyApp());
// Step 1: Sign up
await tester.enterText(find.byKey(Key('email')), '[email protected]');
await tester.enterText(find.byKey(Key('password')), 'password123');
await tester.tap(find.byKey(Key('signup_button')));
await tester.pumpAndSettle();
// Step 2: Create spot
await tester.tap(find.byKey(Key('create_spot_button')));
await tester.enterText(find.byKey(Key('spot_name')), 'Test Spot');
await tester.tap(find.byKey(Key('save_button')));
await tester.pumpAndSettle();
// Step 3: Add to list
await tester.tap(find.byKey(Key('add_to_list_button')));
await tester.pumpAndSettle();
// Verify: Spot appears in list
expect(find.text('Test Spot'), findsOneWidget);
});
Test integration between layers:
/// Integration test: UI → BLoC → Use Case → Repository → Data Source
test('complete data flow integration', () async {
// Arrange: Real dependencies (use test storage)
await TestStorageHelper.initTestStorage();
final repository = SpotsRepositoryImpl();
final useCase = GetSpotsUseCase(repository: repository);
final bloc = SpotsBloc(getSpotsUseCase: useCase);
// Act: Load spots
bloc.add(LoadSpots());
await bloc.stream.first;
// Assert: Verify state
expect(bloc.state, isA<SpotsLoaded>());
// Cleanup
await TestStorageHelper.clearTestStorage();
});
✅ Prefer real dependencies:
/// Integration test with real storage
test('save and retrieve spot from storage', () async {
// Use real GetStorage (in-memory for tests)
await TestStorageHelper.initTestStorage();
final storageService = StorageService();
// Save spot
final spot = Spot(id: '1', name: 'Test Spot');
await storageService.saveSpot(spot);
// Retrieve spot
final retrieved = await storageService.getSpot('1');
// Verify
expect(retrieved, equals(spot));
// Cleanup
await TestStorageHelper.clearTestStorage();
});
⚠️ Mocks require explicit approval and justification:
/// Example: External API that charges per request
test('payment processing integration', () async {
// Mock external payment API (can't call real API in tests)
final mockPaymentAPI = MockPaymentAPI();
when(() => mockPaymentAPI.processPayment(any()))
.thenAnswer((_) async => PaymentResult.success());
// Test with mocked external dependency
final paymentService = PaymentService(
paymentAPI: mockPaymentAPI, // Mock required here
);
// Test payment flow
final result = await paymentService.processPayment(amount: 100);
expect(result.isSuccess, isTrue);
});
Justification required:
Test services working together:
/// Integration test: Multiple services working together
test('reservation creation workflow', () async {
// Arrange: Real services
final reservationService = ReservationService(...);
final paymentService = PaymentService(...);
final eventService = EventService(...);
// Act: Complete workflow
final reservation = await reservationService.createReservation(
eventId: 'event1',
ticketCount: 2,
);
// Assert: Verify all services updated correctly
final event = await eventService.getEvent('event1');
expect(event.availableTickets, equals(8)); // Was 10, now 8
final payment = await paymentService.getPayment(reservation.paymentId);
expect(payment.status, equals(PaymentStatus.completed));
});
test/integration/
├── ai/
│ └── ai2ai_complete_integration_test.dart
├── auth/
│ └── auth_flow_integration_test.dart
└── spots/
└── spot_creation_integration_test.dart
Integration Tests:
Target: <2000ms average
Acceptable: <5000ms average
Poor: >10000ms average
Always clean up test data:
tearDown(() async {
// Clean up test storage
await TestStorageHelper.clearTestStorage();
// Clean up test files
await cleanupTestFiles();
});
test/integration/ai/ai2ai_complete_integration_test.dart - Complete integration exampletest/helpers/test_storage_helper.dart - Test storage initialization helperdocs/plans/test_refactoring/TEST_WRITING_GUIDE.md - Test quality guidedevelopment
--- name: world-model-development description: Guides world model development patterns: state/action encoders, ONNX inference, feature extraction pipeline, latency budgets. Use when implementing world model components, state encoders, action encoders, feature extractors, or ONNX models. Core skill for Phases 3-6. --- # World Model Development Patterns ## Core Principle All world model components follow LeCun's autonomous machine intelligence framework. State observations flow through a percep
tools
Implements base workflow controller patterns for multi-step processes. Use when creating complex workflows that require orchestration of multiple steps with error handling and rollback.
testing
--- name: widget-test-patterns description: Guides widget test patterns: BLoC testing, user interactions, state changes, material app setup. Use when writing widget tests, testing UI components, or validating widget behavior. --- # Widget Test Patterns ## Core Pattern Widget tests verify UI behavior: user interactions, state changes, and visual display. ## Basic Widget Test Setup ```dart testWidgets('widget displays correctly', (WidgetTester tester) async { // Arrange: Create widget awa
testing
--- name: test-template-generation description: Generates test templates: unit, widget, integration, service tests following project patterns. Use when creating new tests or ensuring tests follow project standards. --- # Test Template Generation ## Available Templates Test templates are located in `test/templates/`: - `unit_test_template.dart` - `widget_test_template.dart` - `integration_test_template.dart` - `service_test_template.dart` ## Unit Test Template ```dart /// SPOTS Component Uni