Compare commits

..

3 Commits

Author SHA1 Message Date
480a8bdd82 Stop const-folding EmptyState's constructor out of coverage
Some checks failed
design_system tests / test (push) Has been cancelled
Removing the action slot made the constructor const-invocable, so the
test's `const EmptyState(...)` was evaluated at compile time and the
constructor line never executed -- 99%, caught by the pre-push gate
rather than by review, which is the point of having it.

Building the message through a helper keeps the invocation non-const.
That is also closer to real call sites, which interpolate runtime state
into the string rather than passing a literal.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XS1m7b1piBtAL22USLW6jL
2026-08-14 23:10:43 +02:00
3dab75fde5 Record which design_system exports actually have a live consumer
An extracted component with no importer is the failure mode the audit
exists to prevent, so leaving that implicit was the wrong call.
EmptyState and AppStatusColors ship ahead of their consumers -- both have
real donors waiting, and AppStatusColors has to exist for showError to
read the danger hue off the theme -- but neither is validated, and the
table now says so rather than letting the package read as fully proven.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XS1m7b1piBtAL22USLW6jL
2026-08-14 23:09:45 +02:00
522fa1dff0 Wire design_system into CI, and drop EmptyState's speculative action slot
The pre-push coverage gate only ran for whoever had the local hook
installed, which is deployment hygiene rather than a gate. Adds the
mirrored workflow sync_settings_ui already has, so the 100% bar is
enforced on push and PR.

EmptyState.action was invented surface: no donor had it. home_inventory's
three call sites are pure placeholders, and kuhylog's action-bearing
_empty was explicitly excluded from the survey as a different element.
Shipping a parameter nobody asked for on a widget that has no consumer
yet is the failure mode this package is supposed to avoid, so it goes,
with a comment recording why rather than leaving the next reader to
rediscover it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XS1m7b1piBtAL22USLW6jL
2026-08-14 23:08:59 +02:00
4 changed files with 74 additions and 25 deletions

View File

@ -0,0 +1,36 @@
name: design_system tests
on:
push:
branches: [main]
paths: ['design_system/**']
pull_request:
branches: [main]
paths: ['design_system/**']
jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: design_system
steps:
- uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
- name: Install dependencies
run: flutter pub get
- name: Analyze
run: flutter analyze
- name: Run tests with coverage
run: flutter test --coverage
- name: Enforce 100% line coverage
run: scripts/check_coverage.sh coverage/lcov.info 100

View File

@ -14,7 +14,6 @@ class EmptyState extends StatelessWidget {
required this.icon,
required this.title,
required this.message,
this.action,
super.key,
});
@ -27,15 +26,14 @@ class EmptyState extends StatelessWidget {
/// One line explaining what to do about it.
final String message;
/// Optional call to action below the message — usually the button that
/// creates the first item. Omit it where the empty state is a *filter*
/// result rather than an empty collection: there is nothing to create.
final Widget? action;
// Deliberately no `action` slot. No donor had one: home_inventory's three
// call sites are pure placeholders, and kuhylog's action-bearing `_empty`
// is a different element. Adding one here would be speculative surface --
// the widget nobody imports, one parameter down.
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final action = this.action;
return Center(
child: Padding(
padding: const EdgeInsets.all(AppSpacing.xl),
@ -57,10 +55,6 @@ class EmptyState extends StatelessWidget {
color: theme.colorScheme.onSurfaceVariant,
),
),
if (action != null) ...[
const SizedBox(height: AppSpacing.lg),
action,
],
],
),
),

View File

@ -2,7 +2,13 @@ import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
Future<void> _pumpEmptyState(WidgetTester tester, {Widget? action}) {
/// Built at runtime rather than inlined as a literal, so the `EmptyState`
/// below cannot be const-folded: a const invocation is evaluated at compile
/// time, so the constructor never executes and coverage silently drops.
/// Real call sites interpolate runtime state into these strings anyway.
String _message(int count) => 'Add your first item to get started ($count).';
Future<void> _pumpEmptyState(WidgetTester tester) {
return tester.pumpWidget(
MaterialApp(
theme: buildDarkTheme(),
@ -10,8 +16,7 @@ Future<void> _pumpEmptyState(WidgetTester tester, {Widget? action}) {
body: EmptyState(
icon: Icons.inbox_outlined,
title: 'Nothing here yet',
message: 'Add your first item to get started.',
action: action,
message: _message(0),
),
),
),
@ -23,7 +28,7 @@ void main() {
await _pumpEmptyState(tester);
expect(find.byIcon(Icons.inbox_outlined), findsOneWidget);
expect(find.text('Nothing here yet'), findsOneWidget);
expect(find.text('Add your first item to get started.'), findsOneWidget);
expect(find.text(_message(0)), findsOneWidget);
});
testWidgets('draws the icon at the shared size in the muted color', (
@ -40,7 +45,7 @@ void main() {
final scheme = buildDarkTheme().colorScheme;
final message = tester.widget<Text>(
find.text('Add your first item to get started.'),
find.text(_message(0)),
);
expect(message.style?.color, scheme.onSurfaceVariant);
expect(message.textAlign, TextAlign.center);
@ -49,17 +54,11 @@ void main() {
expect(title.style?.color, isNot(scheme.onSurfaceVariant));
});
testWidgets('omits the action slot by default', (tester) async {
testWidgets('is a pure placeholder with no action', (tester) async {
// Deliberate: no donor had an action slot, so adding one would be
// speculative surface on a widget that has no consumer yet.
await _pumpEmptyState(tester);
expect(find.byType(ElevatedButton), findsNothing);
});
testWidgets('renders an action when one is given', (tester) async {
await _pumpEmptyState(
tester,
action: ElevatedButton(onPressed: () {}, child: const Text('Add item')),
);
expect(find.text('Add item'), findsOneWidget);
expect(find.byType(ButtonStyleButton), findsNothing);
});
testWidgets('stays centred and shrink-wrapped', (tester) async {

View File

@ -62,6 +62,26 @@ two-repo extraction criterion, which most of them currently fail.
Proof consumers `todo` and `untools` are migrated, verified and pushed.
### Which exports have a live consumer
An extracted component with no importer is the failure mode this audit
exists to prevent, so the honest status per export:
| Export | Live consumers |
|---|---|
| tokens, palette, themes | todo, untools |
| `confirmDestructive` | todo (2 sites) |
| `showToast` / `showError` | todo (3 sites) |
| `SectionHeader` | untools (2 sites) |
| `EmptyState` | **none yet** — donor is home_inventory (3 sites), unmigrated |
| `AppStatusColors` | **none yet** — 4 donors, all unmigrated |
The last two ship ahead of their consumers. That is defensible (both have
real donors waiting, and `AppStatusColors` must exist for `showError` to read
the danger hue off the theme) but it is not *validated*, and it should be
called that way until home_inventory or one of the status-color donors
migrates.
### Corrections to the original plan, found by measuring
The plan's figures were mostly right but three were not, and the difference