Skip to content

Commit

Permalink
fix(neon_framework): Correctly reload after updating account credentials
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Nov 2, 2024
1 parent 3ae067c commit 008b733
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/neon_framework/lib/src/login/view/login_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class LoginView extends StatelessWidget {
return BlocConsumer<LoginBloc, LoginState>(
listener: (context, state) {
if (state is LoginStateDone) {
const HomeRoute().go(context);
// go() will not work as the user already has to the route with the old account in the stack,
// so we need to pushReplacement() the route to have everything reload.
const HomeRoute().pushReplacement(context);
}
},
builder: (context, state) {
Expand Down
5 changes: 3 additions & 2 deletions packages/neon_framework/test/login/view/login_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ void main() {
);

router = MockGoRouter();
when(() => router.go(any())).thenAnswer((_) async {});
// ignore: discarded_futures
when(() => router.pushReplacement(any())).thenAnswer((_) async => null);

loginBloc = _MockLoginBloc();
when(() => loginBloc.state).thenReturn(
Expand Down Expand Up @@ -92,7 +93,7 @@ void main() {
);
await tester.pumpWidgetWithAccessibility(buildSubject());

verify(() => router.go('/')).called(1);
verify(() => router.pushReplacement('/')).called(1);
},
);

Expand Down

0 comments on commit 008b733

Please sign in to comment.