feat: type schedule and auth models
This commit is contained in:
@@ -15,12 +15,14 @@ class FakeIgnisApi extends IgnisApi {
|
||||
Object? statsData;
|
||||
Object? eventLogData;
|
||||
Object? apiKeysData;
|
||||
Object? authData;
|
||||
Object? devicesError;
|
||||
Object? scenesError;
|
||||
Object? tasksError;
|
||||
Object? statsError;
|
||||
Object? eventLogError;
|
||||
Object? apiKeysError;
|
||||
Object? authError;
|
||||
Object? groupsError;
|
||||
Object? groupStatusError;
|
||||
Object? controlGroupError;
|
||||
@@ -42,8 +44,19 @@ class FakeIgnisApi extends IgnisApi {
|
||||
this.statsData,
|
||||
this.eventLogData,
|
||||
this.apiKeysData,
|
||||
this.authData,
|
||||
});
|
||||
|
||||
@override
|
||||
Future<Response> getAuthMe() async {
|
||||
final error = authError;
|
||||
if (error != null) throw error;
|
||||
return Response(
|
||||
requestOptions: RequestOptions(path: '/auth/me'),
|
||||
data: authData ?? <String, dynamic>{'is_admin': false},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> getDevices() async {
|
||||
final error = devicesError;
|
||||
@@ -278,6 +291,8 @@ void main() {
|
||||
final state = container.read(tasksProvider);
|
||||
expect(state.status, LoadStatus.data);
|
||||
expect(state.data, hasLength(1));
|
||||
expect(state.data.single.jobId, 'job-1');
|
||||
expect(state.data.single.targetId, 'kitchen');
|
||||
});
|
||||
|
||||
test('tasks load exposes empty state', () async {
|
||||
@@ -418,6 +433,20 @@ void main() {
|
||||
final state = container.read(apiKeysProvider);
|
||||
expect(state.status, LoadStatus.data);
|
||||
expect(state.data, hasLength(1));
|
||||
expect(state.data.single.key, 'secret');
|
||||
expect(state.data.single.name, 'guest');
|
||||
});
|
||||
|
||||
test('auth info load maps admin flag', () async {
|
||||
final api = FakeIgnisApi(authData: {'is_admin': 'true', 'name': 'owner'});
|
||||
final container = containerWith(api);
|
||||
|
||||
await container.read(authInfoProvider.notifier).load();
|
||||
|
||||
final state = container.read(authInfoProvider);
|
||||
expect(state?.isAdmin, isTrue);
|
||||
expect(state?.name, 'owner');
|
||||
expect(container.read(authInfoProvider.notifier).isAdmin, isTrue);
|
||||
});
|
||||
|
||||
test('api keys load exposes empty state', () async {
|
||||
@@ -434,7 +463,7 @@ void main() {
|
||||
test('api keys load error exposes message', () async {
|
||||
final api = FakeIgnisApi(
|
||||
apiKeysData: [
|
||||
{'name': 'guest'},
|
||||
{'name': 'guest', 'key': 'secret'},
|
||||
],
|
||||
);
|
||||
final container = containerWith(api);
|
||||
|
||||
Reference in New Issue
Block a user