Implementado:
No se puede marcar “vista” sin revelar la palabra antes. Se puede volver a ver la palabra durante debate/votación/resultado. Notas online privadas por partida y jugador. Tests añadidos para notas scoped. Ajusté roomId en el payload de inicio para que las notas no se mezclen entre partidas.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import 'package:farolero/servicios/servicio_notas.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
setUp(() {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
});
|
||||
|
||||
test('guarda y carga notas scoped por partida y autor', () async {
|
||||
await ServicioNotas.guardarNotasPartida(
|
||||
partidaId: 'sala-1',
|
||||
autorJugadorId: 'jugador-a',
|
||||
notasPorJugador: {'jugador-b': 'Dijo perro demasiado rápido'},
|
||||
notaLibre: 'Sospecho de B',
|
||||
);
|
||||
|
||||
final datos = await ServicioNotas.cargarNotasPartida(
|
||||
partidaId: 'sala-1',
|
||||
autorJugadorId: 'jugador-a',
|
||||
);
|
||||
|
||||
expect(datos['notas'], {'jugador-b': 'Dijo perro demasiado rápido'});
|
||||
expect(datos['notaLibre'], 'Sospecho de B');
|
||||
});
|
||||
|
||||
test('no mezcla notas entre partidas ni autores', () async {
|
||||
await ServicioNotas.guardarNotasPartida(
|
||||
partidaId: 'sala-1',
|
||||
autorJugadorId: 'jugador-a',
|
||||
notasPorJugador: {'jugador-b': 'nota sala 1'},
|
||||
notaLibre: 'libre 1',
|
||||
);
|
||||
await ServicioNotas.guardarNotasPartida(
|
||||
partidaId: 'sala-2',
|
||||
autorJugadorId: 'jugador-a',
|
||||
notasPorJugador: {'jugador-b': 'nota sala 2'},
|
||||
notaLibre: 'libre 2',
|
||||
);
|
||||
|
||||
final otraPartida = await ServicioNotas.cargarNotasPartida(
|
||||
partidaId: 'sala-2',
|
||||
autorJugadorId: 'jugador-a',
|
||||
);
|
||||
final otroAutor = await ServicioNotas.cargarNotasPartida(
|
||||
partidaId: 'sala-1',
|
||||
autorJugadorId: 'jugador-c',
|
||||
);
|
||||
|
||||
expect(otraPartida['notas'], {'jugador-b': 'nota sala 2'});
|
||||
expect(otraPartida['notaLibre'], 'libre 2');
|
||||
expect(otroAutor['notas'], isEmpty);
|
||||
expect(otroAutor['notaLibre'], isEmpty);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user