import 'package:flutter_test/flutter_test.dart'; import 'package:ignis_app/features/groups/group_form_logic.dart'; import 'package:ignis_app/models/ignis_group.dart'; void main() { test('slugify transliterates russian names into stable ids', () { expect(slugifyGroupId('Спальня родителей'), 'spalnya-roditeley'); expect(slugifyGroupId(' Kitchen + Hall '), 'kitchen-hall'); }); test('group id validation rejects duplicates and invalid chars', () { const existing = [IgnisGroup(id: 'bedroom', name: 'Спальня')]; expect(validateGroupId('', existing), 'Укажите ID группы'); expect( validateGroupId('спальня', existing), 'Только латиница, цифры, "-" и "_"', ); expect( validateGroupId('bedroom', existing), 'Группа с таким ID уже существует', ); expect(validateGroupId('hall_way', existing), isNull); }); test('membership conflicts are detected by device ids', () { const groups = [ IgnisGroup(id: 'bedroom', name: 'Спальня', macs: ['AA:BB', 'CC:DD']), IgnisGroup(id: 'kitchen', name: 'Кухня', macs: ['EE:FF']), ]; final conflicts = findGroupMembershipConflicts({'EE:FF', '11:22'}, groups); expect(conflicts, hasLength(1)); expect(conflicts.single.id, 'kitchen'); }); }