fix(trakt): persist refreshed auth sessions

close #1347
This commit is contained in:
edde746
2026-06-15 14:42:24 +02:00
parent 1aecb9d2d2
commit f602925896
2 changed files with 88 additions and 14 deletions
@@ -90,6 +90,32 @@ void main() {
p.dispose();
});
test('late refresh update after disconnect does not restore session', () async {
const uuid = 'profile-1';
await traktAccountStore.save(uuid, _session(username: 'alice'));
BaseSharedPreferencesService.resetForTesting();
final p = TraktAccountProvider();
await p.onActiveProfileChanged(uuid);
final staleGeneration = p.debugBindingGenerationForTesting;
await p.disconnect();
expect(p.isConnected, isFalse);
expect(await traktAccountStore.load(uuid), isNull);
p.debugHandleSessionUpdatedForTesting(
uuid,
staleGeneration,
_session(accessToken: 'late-at', refreshToken: 'late-rt', username: 'alice'),
);
await Future<void>.delayed(Duration.zero);
expect(p.isConnected, isFalse);
expect(await traktAccountStore.load(uuid), isNull);
p.dispose();
});
test('cancelConnect is a no-op when not connecting', () {
final p = TraktAccountProvider();
// Should not throw when no completer exists.