Stabilize auth flow and profile images
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tdc114plus/src/features/auth/data/auth_session_store.dart';
|
||||
import 'package:tdc114plus/src/features/auth/domain/auth_models.dart';
|
||||
|
||||
void main() {
|
||||
setUp(() {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
});
|
||||
|
||||
test('saves loads and clears login session', () async {
|
||||
const store = AuthSessionStore();
|
||||
final response = PhoneLoginResponse(
|
||||
status: 'ok',
|
||||
token: 'session-token',
|
||||
expiresAt: DateTime.parse('2026-07-02T12:00:00Z'),
|
||||
user: const LoginUser(
|
||||
id: 'user-uuid',
|
||||
name: 'User One',
|
||||
phoneNumber: '+821012345678',
|
||||
tenantId: 'tenant-uuid',
|
||||
tenantName: 'Hanmac',
|
||||
tenantSlug: 'hanmac',
|
||||
),
|
||||
orgContextCredential: OrgContextCredential(
|
||||
baseUrl: 'https://sadmin.hmac.kr',
|
||||
tenantSlug: 'hanmac-family',
|
||||
keyId: 'session-key-id',
|
||||
keySecret: 'session-key-secret',
|
||||
expiresAt: DateTime.parse('2099-07-02T13:00:00Z'),
|
||||
),
|
||||
);
|
||||
|
||||
await store.save(response);
|
||||
final loaded = await store.load();
|
||||
|
||||
expect(loaded?.token, 'session-token');
|
||||
expect(loaded?.user.name, 'User One');
|
||||
expect(loaded?.orgContextCredential?.keyId, 'session-key-id');
|
||||
expect(loaded?.orgContextCredential?.keySecret, 'session-key-secret');
|
||||
|
||||
await store.clear();
|
||||
expect(await store.load(), isNull);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user