feat(flutter/track-actions): HideTrackSheet for reason + notes pick
Modal bottom sheet with five reason chips (mirroring server vocabulary bad_rip / wrong_file / wrong_tags / duplicate / other) plus an optional notes field. Returns (reason, notes) on Hide, null on Cancel. Default selection is bad_rip. Used by TrackActionsSheet's Hide action. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:minstrel/shared/widgets/track_actions/hide_track_sheet.dart';
|
||||
import 'package:minstrel/theme/theme_data.dart';
|
||||
|
||||
void main() {
|
||||
Future<({String reason, String notes})?> openAndPick(
|
||||
WidgetTester t, {
|
||||
required String chipKey,
|
||||
String notes = '',
|
||||
}) async {
|
||||
Future<({String reason, String notes})?>? future;
|
||||
await t.pumpWidget(MaterialApp(
|
||||
theme: buildThemeData(),
|
||||
home: Builder(builder: (ctx) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
future = HideTrackSheet.show(ctx);
|
||||
},
|
||||
child: const Text('open'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
));
|
||||
await t.tap(find.text('open'));
|
||||
await t.pumpAndSettle();
|
||||
if (chipKey != 'hide_reason_bad_rip') {
|
||||
await t.tap(find.byKey(Key(chipKey)));
|
||||
await t.pumpAndSettle();
|
||||
}
|
||||
if (notes.isNotEmpty) {
|
||||
await t.enterText(find.byKey(const Key('hide_notes_input')), notes);
|
||||
}
|
||||
await t.tap(find.byKey(const Key('hide_confirm')));
|
||||
await t.pumpAndSettle();
|
||||
return future;
|
||||
}
|
||||
|
||||
testWidgets('default reason is bad_rip', (t) async {
|
||||
final result = await openAndPick(t, chipKey: 'hide_reason_bad_rip');
|
||||
expect(result, isNotNull);
|
||||
expect(result!.reason, 'bad_rip');
|
||||
expect(result.notes, '');
|
||||
});
|
||||
|
||||
testWidgets('selecting wrong_tags returns wrong_tags', (t) async {
|
||||
final result = await openAndPick(t, chipKey: 'hide_reason_wrong_tags');
|
||||
expect(result?.reason, 'wrong_tags');
|
||||
});
|
||||
|
||||
testWidgets('notes get trimmed and returned', (t) async {
|
||||
final result = await openAndPick(
|
||||
t,
|
||||
chipKey: 'hide_reason_other',
|
||||
notes: ' cracks at 2:13 ',
|
||||
);
|
||||
expect(result?.reason, 'other');
|
||||
expect(result?.notes, 'cracks at 2:13');
|
||||
});
|
||||
|
||||
testWidgets('cancel returns null', (t) async {
|
||||
Future<({String reason, String notes})?>? future;
|
||||
await t.pumpWidget(MaterialApp(
|
||||
theme: buildThemeData(),
|
||||
home: Builder(builder: (ctx) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () { future = HideTrackSheet.show(ctx); },
|
||||
child: const Text('open'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
));
|
||||
await t.tap(find.text('open'));
|
||||
await t.pumpAndSettle();
|
||||
await t.tap(find.text('Cancel'));
|
||||
await t.pumpAndSettle();
|
||||
expect(await future, isNull);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user