.cursor/skills/widget-test-patterns/SKILL.md
--- 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
npx skillsauth add avra-cadavra/avrai .cursor/skills/widget-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.
Widget tests verify UI behavior: user interactions, state changes, and visual display.
testWidgets('widget displays correctly', (WidgetTester tester) async {
// Arrange: Create widget
await tester.pumpWidget(
MaterialApp(
home: MyWidget(),
),
);
// Assert: Verify UI elements
expect(find.text('Hello'), findsOneWidget);
expect(find.byType(Button), findsOneWidget);
});
testWidgets('widget reacts to BLoC state changes', (tester) async {
// Arrange: Create BLoC
final bloc = MyBloc(useCase: mockUseCase);
// Create widget with BLoC
await tester.pumpWidget(
MaterialApp(
home: BlocProvider(
create: (_) => bloc,
child: MyWidget(),
),
),
);
// Act: Emit state change
bloc.add(LoadData());
await tester.pumpAndSettle();
// Assert: Verify UI updated
expect(find.text('Data loaded'), findsOneWidget);
});
testWidgets('widget handles user interactions', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: MyWidget(),
),
);
// Act: Tap button
await tester.tap(find.byKey(Key('submit_button')));
await tester.pump();
// Assert: Verify interaction result
expect(find.text('Submitted'), findsOneWidget);
});
testWidgets('form validates and submits correctly', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: MyForm(),
),
);
// Act: Enter text
await tester.enterText(find.byKey(Key('email_field')), '[email protected]');
await tester.enterText(find.byKey(Key('password_field')), 'password123');
// Tap submit
await tester.tap(find.byKey(Key('submit_button')));
await tester.pumpAndSettle();
// Assert: Verify submission
expect(find.text('Success'), findsOneWidget);
});
testWidgets('widget updates on state change', (tester) async {
final bloc = MyBloc();
await tester.pumpWidget(
MaterialApp(
home: BlocProvider(
create: (_) => bloc,
child: MyWidget(),
),
),
);
// Initial state
expect(find.text('Loading'), findsOneWidget);
// Change state
bloc.add(DataLoadedEvent(data: 'Test Data'));
await tester.pumpAndSettle();
// Updated state
expect(find.text('Test Data'), findsOneWidget);
expect(find.text('Loading'), findsNothing);
});
testWidgets('widget displays error state correctly', (tester) async {
final bloc = MyBloc();
await tester.pumpWidget(
MaterialApp(
home: BlocProvider(
create: (_) => bloc,
child: MyWidget(),
),
),
);
// Emit error state
bloc.add(ErrorEvent(message: 'Error message'));
await tester.pumpAndSettle();
// Assert: Error displayed
expect(find.text('Error message'), findsOneWidget);
expect(find.byIcon(Icons.error), findsOneWidget);
});
test/widget/pages/auth/login_page_test.dart - Widget test exampletest/helpers/widget_test_helpers.dart - Test helpersdevelopment
--- 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: 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
development
--- name: test-quality-enforcement description: Enforces test quality standards: behavior-focused tests, no property-only tests, round-trip JSON, comprehensive test blocks. Use when writing tests, reviewing test code, or ensuring test quality. --- # Test Quality Enforcement ## Core Principle **Test what the code DOES, not what it IS.** ## ✅ DO Test - **Behavior** - What happens when you call a method? - **Business Logic** - Calculations, validation, transformations - **Error Handling** - Ho