Harden geofence automation and home editing
This commit is contained in:
64
test/home_connection_change_test.dart
Normal file
64
test/home_connection_change_test.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:ignis_app/features/homes/services/home_connection_change.dart';
|
||||
import 'package:ignis_app/models/home_config.dart';
|
||||
|
||||
void main() {
|
||||
test('new home always requires connection validation', () {
|
||||
expect(
|
||||
hasHomeConnectionChanges(
|
||||
originalHome: null,
|
||||
normalizedUrl: 'https://ignis.akokos.ru',
|
||||
apiKey: 'secret-key',
|
||||
originalApiKey: '',
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
|
||||
test('local-only home edits do not require connection validation', () {
|
||||
final originalHome = HomeConfig(
|
||||
id: 'home-1',
|
||||
name: 'Квартира',
|
||||
url: 'https://ignis.akokos.ru',
|
||||
latitude: 55.75,
|
||||
longitude: 37.61,
|
||||
);
|
||||
|
||||
expect(
|
||||
hasHomeConnectionChanges(
|
||||
originalHome: originalHome,
|
||||
normalizedUrl: originalHome.url,
|
||||
apiKey: 'saved-key',
|
||||
originalApiKey: 'saved-key',
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
test('url or api key changes still require connection validation', () {
|
||||
final originalHome = HomeConfig(
|
||||
id: 'home-1',
|
||||
name: 'Квартира',
|
||||
url: 'https://ignis.akokos.ru',
|
||||
);
|
||||
|
||||
expect(
|
||||
hasHomeConnectionChanges(
|
||||
originalHome: originalHome,
|
||||
normalizedUrl: 'https://new.ignis.akokos.ru',
|
||||
apiKey: 'saved-key',
|
||||
originalApiKey: 'saved-key',
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
hasHomeConnectionChanges(
|
||||
originalHome: originalHome,
|
||||
normalizedUrl: originalHome.url,
|
||||
apiKey: 'new-key',
|
||||
originalApiKey: 'saved-key',
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user