mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-28 23:49:17 +01:00
Compare commits
No commits in common. "480a8bdd82d325b23010ad90c5ea306e7f35ab6c" and "cae0870fd0b1a35e4b6be7c8878c0a6d0732652f" have entirely different histories.
480a8bdd82
...
cae0870fd0
36
.github/workflows/design-system-tests.yml
vendored
36
.github/workflows/design-system-tests.yml
vendored
@ -1,36 +0,0 @@
|
|||||||
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
|
|
||||||
@ -14,6 +14,7 @@ class EmptyState extends StatelessWidget {
|
|||||||
required this.icon,
|
required this.icon,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.message,
|
required this.message,
|
||||||
|
this.action,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -26,14 +27,15 @@ class EmptyState extends StatelessWidget {
|
|||||||
/// One line explaining what to do about it.
|
/// One line explaining what to do about it.
|
||||||
final String message;
|
final String message;
|
||||||
|
|
||||||
// Deliberately no `action` slot. No donor had one: home_inventory's three
|
/// Optional call to action below the message — usually the button that
|
||||||
// call sites are pure placeholders, and kuhylog's action-bearing `_empty`
|
/// creates the first item. Omit it where the empty state is a *filter*
|
||||||
// is a different element. Adding one here would be speculative surface --
|
/// result rather than an empty collection: there is nothing to create.
|
||||||
// the widget nobody imports, one parameter down.
|
final Widget? action;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
final action = this.action;
|
||||||
return Center(
|
return Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(AppSpacing.xl),
|
padding: const EdgeInsets.all(AppSpacing.xl),
|
||||||
@ -55,6 +57,10 @@ class EmptyState extends StatelessWidget {
|
|||||||
color: theme.colorScheme.onSurfaceVariant,
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (action != null) ...[
|
||||||
|
const SizedBox(height: AppSpacing.lg),
|
||||||
|
action,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -2,13 +2,7 @@ import 'package:design_system/design_system.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
/// Built at runtime rather than inlined as a literal, so the `EmptyState`
|
Future<void> _pumpEmptyState(WidgetTester tester, {Widget? action}) {
|
||||||
/// 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(
|
return tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: buildDarkTheme(),
|
theme: buildDarkTheme(),
|
||||||
@ -16,7 +10,8 @@ Future<void> _pumpEmptyState(WidgetTester tester) {
|
|||||||
body: EmptyState(
|
body: EmptyState(
|
||||||
icon: Icons.inbox_outlined,
|
icon: Icons.inbox_outlined,
|
||||||
title: 'Nothing here yet',
|
title: 'Nothing here yet',
|
||||||
message: _message(0),
|
message: 'Add your first item to get started.',
|
||||||
|
action: action,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -28,7 +23,7 @@ void main() {
|
|||||||
await _pumpEmptyState(tester);
|
await _pumpEmptyState(tester);
|
||||||
expect(find.byIcon(Icons.inbox_outlined), findsOneWidget);
|
expect(find.byIcon(Icons.inbox_outlined), findsOneWidget);
|
||||||
expect(find.text('Nothing here yet'), findsOneWidget);
|
expect(find.text('Nothing here yet'), findsOneWidget);
|
||||||
expect(find.text(_message(0)), findsOneWidget);
|
expect(find.text('Add your first item to get started.'), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('draws the icon at the shared size in the muted color', (
|
testWidgets('draws the icon at the shared size in the muted color', (
|
||||||
@ -45,7 +40,7 @@ void main() {
|
|||||||
final scheme = buildDarkTheme().colorScheme;
|
final scheme = buildDarkTheme().colorScheme;
|
||||||
|
|
||||||
final message = tester.widget<Text>(
|
final message = tester.widget<Text>(
|
||||||
find.text(_message(0)),
|
find.text('Add your first item to get started.'),
|
||||||
);
|
);
|
||||||
expect(message.style?.color, scheme.onSurfaceVariant);
|
expect(message.style?.color, scheme.onSurfaceVariant);
|
||||||
expect(message.textAlign, TextAlign.center);
|
expect(message.textAlign, TextAlign.center);
|
||||||
@ -54,11 +49,17 @@ void main() {
|
|||||||
expect(title.style?.color, isNot(scheme.onSurfaceVariant));
|
expect(title.style?.color, isNot(scheme.onSurfaceVariant));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('is a pure placeholder with no action', (tester) async {
|
testWidgets('omits the action slot by default', (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);
|
await _pumpEmptyState(tester);
|
||||||
expect(find.byType(ButtonStyleButton), findsNothing);
|
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);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('stays centred and shrink-wrapped', (tester) async {
|
testWidgets('stays centred and shrink-wrapped', (tester) async {
|
||||||
|
|||||||
@ -62,26 +62,6 @@ two-repo extraction criterion, which most of them currently fail.
|
|||||||
|
|
||||||
Proof consumers `todo` and `untools` are migrated, verified and pushed.
|
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
|
### Corrections to the original plan, found by measuring
|
||||||
|
|
||||||
The plan's figures were mostly right but three were not, and the difference
|
The plan's figures were mostly right but three were not, and the difference
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user