fix(chat): remove remaining router Back interception
This commit is contained in:
@@ -15,14 +15,21 @@ AppRouterDelegate delegate(AppRoute initial, {void Function()? onChat}) =>
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
test('system Back leaves one chat session for the chat list', () async {
|
||||
var left = 0;
|
||||
final router = delegate(AppRoute.chatSession('s1'), onChat: () => left++);
|
||||
addTearDown(router.dispose);
|
||||
test(
|
||||
'router does not intercept chat Back or invoke the legacy override',
|
||||
() async {
|
||||
var left = 0;
|
||||
final router = delegate(AppRoute.chatSession('s1'), onChat: () => left++);
|
||||
addTearDown(router.dispose);
|
||||
|
||||
expect(await router.popRoute(), isTrue);
|
||||
expect(left, 1);
|
||||
});
|
||||
// With no Navigator mounted there is nothing to pop. The router must not
|
||||
// substitute a chat-specific callback or arm main-screen double-back.
|
||||
expect(await router.popRoute(), isFalse);
|
||||
expect(await router.popRoute(), isFalse);
|
||||
expect(left, 0);
|
||||
expect(router.route, AppRoute.chatSession('s1'));
|
||||
},
|
||||
);
|
||||
|
||||
test('system Back steps up one level at a time', () async {
|
||||
var runs = 0;
|
||||
|
||||
@@ -71,7 +71,7 @@ void main() {
|
||||
router = AppRouterDelegate(
|
||||
initial: AppRoute.chat,
|
||||
cupertino: false,
|
||||
onPopToChat: () => router.goTo(AppRoute.chat),
|
||||
onPopToChat: () => fail('Chat Back must not use the router override'),
|
||||
onPopToRuns: () {},
|
||||
builder: (_, route) => AdaptiveShell(
|
||||
destination: AppDestination.chat,
|
||||
@@ -115,6 +115,14 @@ void main() {
|
||||
isTrue,
|
||||
reason: 'Chat must be pushed, not swapped into the main page',
|
||||
);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(widget) => widget is PopScope && !widget.canPop,
|
||||
),
|
||||
findsNothing,
|
||||
reason:
|
||||
'The main-screen Back interceptor must not block an open chat',
|
||||
);
|
||||
expect(
|
||||
tester.widget<BackButton>(findNativeBack()).onPressed,
|
||||
isNull,
|
||||
|
||||
Reference in New Issue
Block a user