From 1d352821fc53f9d659ae04d3b1fc9d0adf9e2dea Mon Sep 17 00:00:00 2001 From: gelbeinhalb Date: Thu, 29 Jan 2026 15:39:52 +0100 Subject: [PATCH] all parameters are now required --- assets/schema.json | 36 ++--- lib/data/dao/game_dao.dart | 6 +- lib/data/dao/group_dao.dart | 8 +- lib/data/dao/match_dao.dart | 23 ++-- lib/data/dao/player_dao.dart | 4 +- lib/data/db/database.g.dart | 127 +++++++++--------- lib/data/db/tables/game_table.dart | 2 +- lib/data/db/tables/group_table.dart | 2 +- lib/data/db/tables/player_table.dart | 2 +- lib/data/dto/game.dart | 4 +- lib/data/dto/group.dart | 4 +- lib/data/dto/match.dart | 15 ++- lib/data/dto/player.dart | 4 +- .../group_view/create_group_view.dart | 1 + .../main_menu/group_view/groups_view.dart | 3 +- .../views/main_menu/home_view.dart | 13 +- .../create_match/create_match_view.dart | 3 + .../main_menu/match_view/match_view.dart | 11 +- .../views/main_menu/statistics_view.dart | 4 +- .../widgets/player_selection.dart | 4 +- lib/services/data_transfer_service.dart | 12 +- test/db_tests/game_test.dart | 13 +- test/db_tests/group_test.dart | 17 ++- test/db_tests/match_test.dart | 18 ++- test/db_tests/player_group_test.dart | 15 ++- test/db_tests/player_match_test.dart | 29 ++-- test/db_tests/player_test.dart | 18 +-- test/db_tests/score_test.dart | 10 +- test/db_tests/team_test.dart | 16 +-- 29 files changed, 227 insertions(+), 197 deletions(-) diff --git a/assets/schema.json b/assets/schema.json index 3aab588..a00cd6e 100644 --- a/assets/schema.json +++ b/assets/schema.json @@ -17,13 +17,14 @@ "type": "string" }, "description": { - "type": ["string", "null"] + "type": "string" } }, "required": [ "id", "createdAt", - "name" + "name", + "description" ] } }, @@ -42,22 +43,26 @@ "type": "string" }, "ruleset": { - "type": ["string", "null"] + "type": "string" }, "description": { - "type": ["string", "null"] + "type": "string" }, "color": { - "type": ["integer", "null"] + "type": "string" }, "icon": { - "type": ["string", "null"] + "type": "string" } }, "required": [ "id", "createdAt", - "name" + "name", + "ruleset", + "description", + "color", + "icon" ] } }, @@ -76,7 +81,7 @@ "type": "string" }, "description": { - "type": ["string", "null"] + "type": "string" }, "memberIds": { "type": "array", @@ -89,6 +94,7 @@ "id", "name", "createdAt", + "description", "memberIds" ] } @@ -137,10 +143,7 @@ "type": "string" }, "gameId": { - "anyOf": [ - {"type": "string"}, - {"type": "null"} - ] + "type": "string" }, "groupId": { "anyOf": [ @@ -155,17 +158,16 @@ } }, "notes": { - "anyOf": [ - {"type": "string"}, - {"type": "null"} - ] + "type": "string" } }, "required": [ "id", "name", "createdAt", - "playerIds" + "gameId", + "playerIds", + "notes" ] } } diff --git a/lib/data/dao/game_dao.dart b/lib/data/dao/game_dao.dart index 95ecc70..0fd761c 100644 --- a/lib/data/dao/game_dao.dart +++ b/lib/data/dao/game_dao.dart @@ -56,7 +56,7 @@ class GameDao extends DatabaseAccessor with _$GameDaoMixin { ruleset: game.ruleset.name, description: game.description, color: game.color, - icon: Value(game.icon), + icon: game.icon, createdAt: game.createdAt, ), mode: InsertMode.insertOrReplace, @@ -82,7 +82,7 @@ class GameDao extends DatabaseAccessor with _$GameDaoMixin { ruleset: game.ruleset.name, description: game.description, color: game.color, - icon: Value(game.icon), + icon: game.icon, createdAt: game.createdAt, ), ) @@ -153,7 +153,7 @@ class GameDao extends DatabaseAccessor with _$GameDaoMixin { /// Updates the icon of the game with the given [gameId]. Future updateGameIcon({ required String gameId, - required String? newIcon, + required String newIcon, }) async { await (update(gameTable)..where((g) => g.id.equals(gameId))).write( GameTableCompanion(icon: Value(newIcon)), diff --git a/lib/data/dao/group_dao.dart b/lib/data/dao/group_dao.dart index beecc9d..cd45c12 100644 --- a/lib/data/dao/group_dao.dart +++ b/lib/data/dao/group_dao.dart @@ -58,7 +58,7 @@ class GroupDao extends DatabaseAccessor with _$GroupDaoMixin { GroupTableCompanion.insert( id: group.id, name: group.name, - description: Value(group.description), + description: group.description, createdAt: group.createdAt, ), mode: InsertMode.insertOrReplace, @@ -108,7 +108,7 @@ class GroupDao extends DatabaseAccessor with _$GroupDaoMixin { (group) => GroupTableCompanion.insert( id: group.id, name: group.name, - description: Value(group.description), + description: group.description, createdAt: group.createdAt, ), ) @@ -136,7 +136,7 @@ class GroupDao extends DatabaseAccessor with _$GroupDaoMixin { (p) => PlayerTableCompanion.insert( id: p.id, name: p.name, - description: Value(p.description), + description: p.description, createdAt: p.createdAt, ), ) @@ -196,7 +196,7 @@ class GroupDao extends DatabaseAccessor with _$GroupDaoMixin { /// Returns `true` if more than 0 rows were affected, otherwise `false`. Future updateGroupDescription({ required String groupId, - required String? newDescription, + required String newDescription, }) async { final rowsAffected = await (update(groupTable)..where((g) => g.id.equals(groupId))).write( diff --git a/lib/data/dao/match_dao.dart b/lib/data/dao/match_dao.dart index 4ec5b4d..2df0bb9 100644 --- a/lib/data/dao/match_dao.dart +++ b/lib/data/dao/match_dao.dart @@ -36,7 +36,7 @@ class MatchDao extends DatabaseAccessor with _$MatchDaoMixin { game: game, group: group, players: players, - notes: row.notes, + notes: row.notes ?? '', createdAt: row.createdAt, ); }), @@ -66,7 +66,7 @@ class MatchDao extends DatabaseAccessor with _$MatchDaoMixin { game: game, group: group, players: players, - notes: result.notes, + notes: result.notes ?? '', createdAt: result.createdAt, ); } @@ -75,15 +75,11 @@ class MatchDao extends DatabaseAccessor with _$MatchDaoMixin { /// This method assumes that the game and group (if any) are already present /// in the database. Future addMatch({required Match match}) async { - if (match.game == null) { - throw ArgumentError('Match must have a game associated with it'); - } - await db.transaction(() async { await into(matchTable).insert( MatchTableCompanion.insert( id: match.id, - gameId: match.game!.id, + gameId: match.game.id, groupId: Value(match.group?.id), name: Value(match.name), notes: Value(match.notes), @@ -113,9 +109,7 @@ class MatchDao extends DatabaseAccessor with _$MatchDaoMixin { // Add all games first (deduplicated) final uniqueGames = {}; for (final match in matches) { - if (match.game != null) { - uniqueGames[match.game!.id] = match.game!; - } + uniqueGames[match.game.id] = match.game; } if (uniqueGames.isNotEmpty) { @@ -130,7 +124,7 @@ class MatchDao extends DatabaseAccessor with _$MatchDaoMixin { ruleset: game.ruleset.name, description: game.description, color: game.color, - icon: Value(game.icon), + icon: game.icon, createdAt: game.createdAt, ), ) @@ -150,7 +144,7 @@ class MatchDao extends DatabaseAccessor with _$MatchDaoMixin { (match) => GroupTableCompanion.insert( id: match.group!.id, name: match.group!.name, - description: Value(match.group!.description), + description: match.group!.description, createdAt: match.group!.createdAt, ), ) @@ -164,11 +158,10 @@ class MatchDao extends DatabaseAccessor with _$MatchDaoMixin { (b) => b.insertAll( matchTable, matches - .where((match) => match.game != null) .map( (match) => MatchTableCompanion.insert( id: match.id, - gameId: match.game!.id, + gameId: match.game.id, groupId: Value(match.group?.id), name: Value(match.name), notes: Value(match.notes), @@ -205,7 +198,7 @@ class MatchDao extends DatabaseAccessor with _$MatchDaoMixin { (p) => PlayerTableCompanion.insert( id: p.id, name: p.name, - description: Value(p.description), + description: p.description, createdAt: p.createdAt, ), ) diff --git a/lib/data/dao/player_dao.dart b/lib/data/dao/player_dao.dart index b8b5000..e6607a4 100644 --- a/lib/data/dao/player_dao.dart +++ b/lib/data/dao/player_dao.dart @@ -46,7 +46,7 @@ class PlayerDao extends DatabaseAccessor with _$PlayerDaoMixin { PlayerTableCompanion.insert( id: player.id, name: player.name, - description: Value(player.description), + description: player.description, createdAt: player.createdAt, ), mode: InsertMode.insertOrReplace, @@ -70,7 +70,7 @@ class PlayerDao extends DatabaseAccessor with _$PlayerDaoMixin { (player) => PlayerTableCompanion.insert( id: player.id, name: player.name, - description: Value(player.description), + description: player.description, createdAt: player.createdAt, ), ) diff --git a/lib/data/db/database.g.dart b/lib/data/db/database.g.dart index 3faa308..b77c4cd 100644 --- a/lib/data/db/database.g.dart +++ b/lib/data/db/database.g.dart @@ -34,9 +34,9 @@ class $PlayerTableTable extends PlayerTable late final GeneratedColumn description = GeneratedColumn( 'description', aliasedName, - true, + false, type: DriftSqlType.string, - requiredDuringInsert: false, + requiredDuringInsert: true, ); static const VerificationMeta _createdAtMeta = const VerificationMeta( 'createdAt', @@ -84,6 +84,8 @@ class $PlayerTableTable extends PlayerTable _descriptionMeta, ), ); + } else if (isInserting) { + context.missing(_descriptionMeta); } if (data.containsKey('created_at')) { context.handle( @@ -113,7 +115,7 @@ class $PlayerTableTable extends PlayerTable description: attachedDatabase.typeMapping.read( DriftSqlType.string, data['${effectivePrefix}description'], - ), + )!, createdAt: attachedDatabase.typeMapping.read( DriftSqlType.dateTime, data['${effectivePrefix}created_at'], @@ -130,12 +132,12 @@ class $PlayerTableTable extends PlayerTable class PlayerTableData extends DataClass implements Insertable { final String id; final String name; - final String? description; + final String description; final DateTime createdAt; const PlayerTableData({ required this.id, required this.name, - this.description, + required this.description, required this.createdAt, }); @override @@ -143,9 +145,7 @@ class PlayerTableData extends DataClass implements Insertable { final map = {}; map['id'] = Variable(id); map['name'] = Variable(name); - if (!nullToAbsent || description != null) { - map['description'] = Variable(description); - } + map['description'] = Variable(description); map['created_at'] = Variable(createdAt); return map; } @@ -154,9 +154,7 @@ class PlayerTableData extends DataClass implements Insertable { return PlayerTableCompanion( id: Value(id), name: Value(name), - description: description == null && nullToAbsent - ? const Value.absent() - : Value(description), + description: Value(description), createdAt: Value(createdAt), ); } @@ -169,7 +167,7 @@ class PlayerTableData extends DataClass implements Insertable { return PlayerTableData( id: serializer.fromJson(json['id']), name: serializer.fromJson(json['name']), - description: serializer.fromJson(json['description']), + description: serializer.fromJson(json['description']), createdAt: serializer.fromJson(json['createdAt']), ); } @@ -179,7 +177,7 @@ class PlayerTableData extends DataClass implements Insertable { return { 'id': serializer.toJson(id), 'name': serializer.toJson(name), - 'description': serializer.toJson(description), + 'description': serializer.toJson(description), 'createdAt': serializer.toJson(createdAt), }; } @@ -187,12 +185,12 @@ class PlayerTableData extends DataClass implements Insertable { PlayerTableData copyWith({ String? id, String? name, - Value description = const Value.absent(), + String? description, DateTime? createdAt, }) => PlayerTableData( id: id ?? this.id, name: name ?? this.name, - description: description.present ? description.value : this.description, + description: description ?? this.description, createdAt: createdAt ?? this.createdAt, ); PlayerTableData copyWithCompanion(PlayerTableCompanion data) { @@ -232,7 +230,7 @@ class PlayerTableData extends DataClass implements Insertable { class PlayerTableCompanion extends UpdateCompanion { final Value id; final Value name; - final Value description; + final Value description; final Value createdAt; final Value rowid; const PlayerTableCompanion({ @@ -245,11 +243,12 @@ class PlayerTableCompanion extends UpdateCompanion { PlayerTableCompanion.insert({ required String id, required String name, - this.description = const Value.absent(), + required String description, required DateTime createdAt, this.rowid = const Value.absent(), }) : id = Value(id), name = Value(name), + description = Value(description), createdAt = Value(createdAt); static Insertable custom({ Expression? id, @@ -270,7 +269,7 @@ class PlayerTableCompanion extends UpdateCompanion { PlayerTableCompanion copyWith({ Value? id, Value? name, - Value? description, + Value? description, Value? createdAt, Value? rowid, }) { @@ -348,9 +347,9 @@ class $GroupTableTable extends GroupTable late final GeneratedColumn description = GeneratedColumn( 'description', aliasedName, - true, + false, type: DriftSqlType.string, - requiredDuringInsert: false, + requiredDuringInsert: true, ); static const VerificationMeta _createdAtMeta = const VerificationMeta( 'createdAt', @@ -398,6 +397,8 @@ class $GroupTableTable extends GroupTable _descriptionMeta, ), ); + } else if (isInserting) { + context.missing(_descriptionMeta); } if (data.containsKey('created_at')) { context.handle( @@ -427,7 +428,7 @@ class $GroupTableTable extends GroupTable description: attachedDatabase.typeMapping.read( DriftSqlType.string, data['${effectivePrefix}description'], - ), + )!, createdAt: attachedDatabase.typeMapping.read( DriftSqlType.dateTime, data['${effectivePrefix}created_at'], @@ -444,12 +445,12 @@ class $GroupTableTable extends GroupTable class GroupTableData extends DataClass implements Insertable { final String id; final String name; - final String? description; + final String description; final DateTime createdAt; const GroupTableData({ required this.id, required this.name, - this.description, + required this.description, required this.createdAt, }); @override @@ -457,9 +458,7 @@ class GroupTableData extends DataClass implements Insertable { final map = {}; map['id'] = Variable(id); map['name'] = Variable(name); - if (!nullToAbsent || description != null) { - map['description'] = Variable(description); - } + map['description'] = Variable(description); map['created_at'] = Variable(createdAt); return map; } @@ -468,9 +467,7 @@ class GroupTableData extends DataClass implements Insertable { return GroupTableCompanion( id: Value(id), name: Value(name), - description: description == null && nullToAbsent - ? const Value.absent() - : Value(description), + description: Value(description), createdAt: Value(createdAt), ); } @@ -483,7 +480,7 @@ class GroupTableData extends DataClass implements Insertable { return GroupTableData( id: serializer.fromJson(json['id']), name: serializer.fromJson(json['name']), - description: serializer.fromJson(json['description']), + description: serializer.fromJson(json['description']), createdAt: serializer.fromJson(json['createdAt']), ); } @@ -493,7 +490,7 @@ class GroupTableData extends DataClass implements Insertable { return { 'id': serializer.toJson(id), 'name': serializer.toJson(name), - 'description': serializer.toJson(description), + 'description': serializer.toJson(description), 'createdAt': serializer.toJson(createdAt), }; } @@ -501,12 +498,12 @@ class GroupTableData extends DataClass implements Insertable { GroupTableData copyWith({ String? id, String? name, - Value description = const Value.absent(), + String? description, DateTime? createdAt, }) => GroupTableData( id: id ?? this.id, name: name ?? this.name, - description: description.present ? description.value : this.description, + description: description ?? this.description, createdAt: createdAt ?? this.createdAt, ); GroupTableData copyWithCompanion(GroupTableCompanion data) { @@ -546,7 +543,7 @@ class GroupTableData extends DataClass implements Insertable { class GroupTableCompanion extends UpdateCompanion { final Value id; final Value name; - final Value description; + final Value description; final Value createdAt; final Value rowid; const GroupTableCompanion({ @@ -559,11 +556,12 @@ class GroupTableCompanion extends UpdateCompanion { GroupTableCompanion.insert({ required String id, required String name, - this.description = const Value.absent(), + required String description, required DateTime createdAt, this.rowid = const Value.absent(), }) : id = Value(id), name = Value(name), + description = Value(description), createdAt = Value(createdAt); static Insertable custom({ Expression? id, @@ -584,7 +582,7 @@ class GroupTableCompanion extends UpdateCompanion { GroupTableCompanion copyWith({ Value? id, Value? name, - Value? description, + Value? description, Value? createdAt, Value? rowid, }) { @@ -691,9 +689,9 @@ class $GameTableTable extends GameTable late final GeneratedColumn icon = GeneratedColumn( 'icon', aliasedName, - true, + false, type: DriftSqlType.string, - requiredDuringInsert: false, + requiredDuringInsert: true, ); static const VerificationMeta _createdAtMeta = const VerificationMeta( 'createdAt', @@ -773,6 +771,8 @@ class $GameTableTable extends GameTable _iconMeta, icon.isAcceptableOrUnknown(data['icon']!, _iconMeta), ); + } else if (isInserting) { + context.missing(_iconMeta); } if (data.containsKey('created_at')) { context.handle( @@ -814,7 +814,7 @@ class $GameTableTable extends GameTable icon: attachedDatabase.typeMapping.read( DriftSqlType.string, data['${effectivePrefix}icon'], - ), + )!, createdAt: attachedDatabase.typeMapping.read( DriftSqlType.dateTime, data['${effectivePrefix}created_at'], @@ -834,7 +834,7 @@ class GameTableData extends DataClass implements Insertable { final String ruleset; final String description; final String color; - final String? icon; + final String icon; final DateTime createdAt; const GameTableData({ required this.id, @@ -842,7 +842,7 @@ class GameTableData extends DataClass implements Insertable { required this.ruleset, required this.description, required this.color, - this.icon, + required this.icon, required this.createdAt, }); @override @@ -853,9 +853,7 @@ class GameTableData extends DataClass implements Insertable { map['ruleset'] = Variable(ruleset); map['description'] = Variable(description); map['color'] = Variable(color); - if (!nullToAbsent || icon != null) { - map['icon'] = Variable(icon); - } + map['icon'] = Variable(icon); map['created_at'] = Variable(createdAt); return map; } @@ -867,7 +865,7 @@ class GameTableData extends DataClass implements Insertable { ruleset: Value(ruleset), description: Value(description), color: Value(color), - icon: icon == null && nullToAbsent ? const Value.absent() : Value(icon), + icon: Value(icon), createdAt: Value(createdAt), ); } @@ -883,7 +881,7 @@ class GameTableData extends DataClass implements Insertable { ruleset: serializer.fromJson(json['ruleset']), description: serializer.fromJson(json['description']), color: serializer.fromJson(json['color']), - icon: serializer.fromJson(json['icon']), + icon: serializer.fromJson(json['icon']), createdAt: serializer.fromJson(json['createdAt']), ); } @@ -896,7 +894,7 @@ class GameTableData extends DataClass implements Insertable { 'ruleset': serializer.toJson(ruleset), 'description': serializer.toJson(description), 'color': serializer.toJson(color), - 'icon': serializer.toJson(icon), + 'icon': serializer.toJson(icon), 'createdAt': serializer.toJson(createdAt), }; } @@ -907,7 +905,7 @@ class GameTableData extends DataClass implements Insertable { String? ruleset, String? description, String? color, - Value icon = const Value.absent(), + String? icon, DateTime? createdAt, }) => GameTableData( id: id ?? this.id, @@ -915,7 +913,7 @@ class GameTableData extends DataClass implements Insertable { ruleset: ruleset ?? this.ruleset, description: description ?? this.description, color: color ?? this.color, - icon: icon.present ? icon.value : this.icon, + icon: icon ?? this.icon, createdAt: createdAt ?? this.createdAt, ); GameTableData copyWithCompanion(GameTableCompanion data) { @@ -968,7 +966,7 @@ class GameTableCompanion extends UpdateCompanion { final Value ruleset; final Value description; final Value color; - final Value icon; + final Value icon; final Value createdAt; final Value rowid; const GameTableCompanion({ @@ -987,7 +985,7 @@ class GameTableCompanion extends UpdateCompanion { required String ruleset, required String description, required String color, - this.icon = const Value.absent(), + required String icon, required DateTime createdAt, this.rowid = const Value.absent(), }) : id = Value(id), @@ -995,6 +993,7 @@ class GameTableCompanion extends UpdateCompanion { ruleset = Value(ruleset), description = Value(description), color = Value(color), + icon = Value(icon), createdAt = Value(createdAt); static Insertable custom({ Expression? id, @@ -1024,7 +1023,7 @@ class GameTableCompanion extends UpdateCompanion { Value? ruleset, Value? description, Value? color, - Value? icon, + Value? icon, Value? createdAt, Value? rowid, }) { @@ -2783,7 +2782,7 @@ typedef $$PlayerTableTableCreateCompanionBuilder = PlayerTableCompanion Function({ required String id, required String name, - Value description, + required String description, required DateTime createdAt, Value rowid, }); @@ -2791,7 +2790,7 @@ typedef $$PlayerTableTableUpdateCompanionBuilder = PlayerTableCompanion Function({ Value id, Value name, - Value description, + Value description, Value createdAt, Value rowid, }); @@ -3133,7 +3132,7 @@ class $$PlayerTableTableTableManager ({ Value id = const Value.absent(), Value name = const Value.absent(), - Value description = const Value.absent(), + Value description = const Value.absent(), Value createdAt = const Value.absent(), Value rowid = const Value.absent(), }) => PlayerTableCompanion( @@ -3147,7 +3146,7 @@ class $$PlayerTableTableTableManager ({ required String id, required String name, - Value description = const Value.absent(), + required String description, required DateTime createdAt, Value rowid = const Value.absent(), }) => PlayerTableCompanion.insert( @@ -3274,7 +3273,7 @@ typedef $$GroupTableTableCreateCompanionBuilder = GroupTableCompanion Function({ required String id, required String name, - Value description, + required String description, required DateTime createdAt, Value rowid, }); @@ -3282,7 +3281,7 @@ typedef $$GroupTableTableUpdateCompanionBuilder = GroupTableCompanion Function({ Value id, Value name, - Value description, + Value description, Value createdAt, Value rowid, }); @@ -3550,7 +3549,7 @@ class $$GroupTableTableTableManager ({ Value id = const Value.absent(), Value name = const Value.absent(), - Value description = const Value.absent(), + Value description = const Value.absent(), Value createdAt = const Value.absent(), Value rowid = const Value.absent(), }) => GroupTableCompanion( @@ -3564,7 +3563,7 @@ class $$GroupTableTableTableManager ({ required String id, required String name, - Value description = const Value.absent(), + required String description, required DateTime createdAt, Value rowid = const Value.absent(), }) => GroupTableCompanion.insert( @@ -3664,7 +3663,7 @@ typedef $$GameTableTableCreateCompanionBuilder = required String ruleset, required String description, required String color, - Value icon, + required String icon, required DateTime createdAt, Value rowid, }); @@ -3675,7 +3674,7 @@ typedef $$GameTableTableUpdateCompanionBuilder = Value ruleset, Value description, Value color, - Value icon, + Value icon, Value createdAt, Value rowid, }); @@ -3909,7 +3908,7 @@ class $$GameTableTableTableManager Value ruleset = const Value.absent(), Value description = const Value.absent(), Value color = const Value.absent(), - Value icon = const Value.absent(), + Value icon = const Value.absent(), Value createdAt = const Value.absent(), Value rowid = const Value.absent(), }) => GameTableCompanion( @@ -3929,7 +3928,7 @@ class $$GameTableTableTableManager required String ruleset, required String description, required String color, - Value icon = const Value.absent(), + required String icon, required DateTime createdAt, Value rowid = const Value.absent(), }) => GameTableCompanion.insert( diff --git a/lib/data/db/tables/game_table.dart b/lib/data/db/tables/game_table.dart index ce71a59..a55b8fc 100644 --- a/lib/data/db/tables/game_table.dart +++ b/lib/data/db/tables/game_table.dart @@ -6,7 +6,7 @@ class GameTable extends Table { TextColumn get ruleset => text()(); TextColumn get description => text()(); TextColumn get color => text()(); - TextColumn get icon => text().nullable()(); + TextColumn get icon => text()(); DateTimeColumn get createdAt => dateTime()(); @override diff --git a/lib/data/db/tables/group_table.dart b/lib/data/db/tables/group_table.dart index 09bf79d..2f30cce 100644 --- a/lib/data/db/tables/group_table.dart +++ b/lib/data/db/tables/group_table.dart @@ -3,7 +3,7 @@ import 'package:drift/drift.dart'; class GroupTable extends Table { TextColumn get id => text()(); TextColumn get name => text()(); - TextColumn get description => text().nullable()(); + TextColumn get description => text()(); DateTimeColumn get createdAt => dateTime()(); @override diff --git a/lib/data/db/tables/player_table.dart b/lib/data/db/tables/player_table.dart index 3e061a0..15b29a5 100644 --- a/lib/data/db/tables/player_table.dart +++ b/lib/data/db/tables/player_table.dart @@ -3,7 +3,7 @@ import 'package:drift/drift.dart'; class PlayerTable extends Table { TextColumn get id => text()(); TextColumn get name => text()(); - TextColumn get description => text().nullable()(); + TextColumn get description => text()(); DateTimeColumn get createdAt => dateTime()(); @override diff --git a/lib/data/dto/game.dart b/lib/data/dto/game.dart index c74b8aa..4081f4e 100644 --- a/lib/data/dto/game.dart +++ b/lib/data/dto/game.dart @@ -9,7 +9,7 @@ class Game { final Ruleset ruleset; final String description; final String color; - final String? icon; + final String icon; Game({ String? id, @@ -18,7 +18,7 @@ class Game { required this.ruleset, required this.description, required this.color, - this.icon, + required this.icon, }) : id = id ?? const Uuid().v4(), createdAt = createdAt ?? clock.now(); diff --git a/lib/data/dto/group.dart b/lib/data/dto/group.dart index a69c982..00ee280 100644 --- a/lib/data/dto/group.dart +++ b/lib/data/dto/group.dart @@ -5,7 +5,7 @@ import 'package:uuid/uuid.dart'; class Group { final String id; final String name; - final String? description; + final String description; final DateTime createdAt; final List members; @@ -13,7 +13,7 @@ class Group { String? id, DateTime? createdAt, required this.name, - this.description, + required this.description, required this.members, }) : id = id ?? const Uuid().v4(), createdAt = createdAt ?? clock.now(); diff --git a/lib/data/dto/match.dart b/lib/data/dto/match.dart index b71757a..a9b81ba 100644 --- a/lib/data/dto/match.dart +++ b/lib/data/dto/match.dart @@ -1,4 +1,5 @@ import 'package:clock/clock.dart'; +import 'package:game_tracker/core/enums.dart'; import 'package:game_tracker/data/dto/game.dart'; import 'package:game_tracker/data/dto/group.dart'; import 'package:game_tracker/data/dto/player.dart'; @@ -8,20 +9,20 @@ class Match { final String id; final DateTime createdAt; final String name; - final Game? game; + final Game game; final Group? group; final List? players; - final String? notes; + final String notes; Player? winner; Match({ String? id, DateTime? createdAt, required this.name, - this.game, + required this.game, this.group, this.players, - this.notes, + required this.notes, this.winner, }) : id = id ?? const Uuid().v4(), createdAt = createdAt ?? clock.now(); @@ -37,17 +38,17 @@ class Match { : id = json['id'], createdAt = DateTime.parse(json['createdAt']), name = json['name'], - game = null, // Populated during import via DataTransferService + game = Game(name: '', ruleset: Ruleset.singleWinner, description: '', color: '', icon: ''), // Populated during import via DataTransferService group = null, // Populated during import via DataTransferService players = [], // Populated during import via DataTransferService - notes = json['notes']; + notes = json['notes'] ?? ''; /// Converts the Match instance to a JSON object using normalized format (ID references only). Map toJson() => { 'id': id, 'createdAt': createdAt.toIso8601String(), 'name': name, - 'gameId': game?.id, + 'gameId': game.id, 'groupId': group?.id, 'playerIds': (players ?? []).map((player) => player.id).toList(), 'notes': notes, diff --git a/lib/data/dto/player.dart b/lib/data/dto/player.dart index 6c3ab6d..13e4123 100644 --- a/lib/data/dto/player.dart +++ b/lib/data/dto/player.dart @@ -5,13 +5,13 @@ class Player { final String id; final DateTime createdAt; final String name; - final String? description; + final String description; Player({ String? id, DateTime? createdAt, required this.name, - this.description, + required this.description, }) : id = id ?? const Uuid().v4(), createdAt = createdAt ?? clock.now(); diff --git a/lib/presentation/views/main_menu/group_view/create_group_view.dart b/lib/presentation/views/main_menu/group_view/create_group_view.dart index 4b34095..0bda8b9 100644 --- a/lib/presentation/views/main_menu/group_view/create_group_view.dart +++ b/lib/presentation/views/main_menu/group_view/create_group_view.dart @@ -84,6 +84,7 @@ class _CreateGroupViewState extends State { bool success = await db.groupDao.addGroup( group: Group( name: _groupNameController.text.trim(), + description: '', members: selectedPlayers, ), ); diff --git a/lib/presentation/views/main_menu/group_view/groups_view.dart b/lib/presentation/views/main_menu/group_view/groups_view.dart index 81922f5..24df3b8 100644 --- a/lib/presentation/views/main_menu/group_view/groups_view.dart +++ b/lib/presentation/views/main_menu/group_view/groups_view.dart @@ -35,7 +35,8 @@ class _GroupsViewState extends State { 7, Group( name: 'Skeleton Group', - members: List.filled(6, Player(name: 'Skeleton Player')), + description: '', + members: List.filled(6, Player(name: 'Skeleton Player', description: '')), ), ); diff --git a/lib/presentation/views/main_menu/home_view.dart b/lib/presentation/views/main_menu/home_view.dart index f28341e..752cf75 100644 --- a/lib/presentation/views/main_menu/home_view.dart +++ b/lib/presentation/views/main_menu/home_view.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:game_tracker/core/adaptive_page_route.dart'; import 'package:game_tracker/core/constants.dart'; +import 'package:game_tracker/core/enums.dart'; import 'package:game_tracker/data/db/database.dart'; +import 'package:game_tracker/data/dto/game.dart'; import 'package:game_tracker/data/dto/group.dart'; import 'package:game_tracker/data/dto/match.dart'; import 'package:game_tracker/data/dto/player.dart'; @@ -40,13 +42,16 @@ class _HomeViewState extends State { 2, Match( name: 'Skeleton Match', + game: Game(name: '', ruleset: Ruleset.singleWinner, description: '', color: '', icon: ''), group: Group( name: 'Skeleton Group', + description: '', members: [ - Player(name: 'Skeleton Player 1'), - Player(name: 'Skeleton Player 2'), + Player(name: 'Skeleton Player 1', description: ''), + Player(name: 'Skeleton Player 2', description: ''), ], ), + notes: '', ), ); @@ -114,7 +119,7 @@ class _HomeViewState extends State { MatchResultView(match: match), ), ); - await updatedWinnerinRecentMatches(match.id); + await updatedWinnerInRecentMatches(match.id); }, ), ) @@ -214,7 +219,7 @@ class _HomeViewState extends State { } /// Updates the winner information for a specific match in the recent matches list. - Future updatedWinnerinRecentMatches(String matchId) async { + Future updatedWinnerInRecentMatches(String matchId) async { final db = Provider.of(context, listen: false); final winner = await db.matchDao.getWinner(matchId: matchId); final matchIndex = recentMatches.indexWhere((match) => match.id == matchId); diff --git a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart index a97de75..30107b7 100644 --- a/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart +++ b/lib/presentation/views/main_menu/match_view/create_match/create_match_view.dart @@ -203,6 +203,7 @@ class _CreateMatchViewState extends State { description: selectedGame.$2, ruleset: selectedGame.$3, color: '0xFF000000', + icon: '', ); } else { // Use the selected game from the list @@ -212,6 +213,7 @@ class _CreateMatchViewState extends State { description: selectedGame.$2, ruleset: selectedGame.$3, color: '0xFF000000', + icon: '', ); } // Add the game to the database if it doesn't exist @@ -225,6 +227,7 @@ class _CreateMatchViewState extends State { game: gameToUse, group: selectedGroup, players: selectedPlayers, + notes: '', ); await db.matchDao.addMatch(match: match); if (context.mounted) { diff --git a/lib/presentation/views/main_menu/match_view/match_view.dart b/lib/presentation/views/main_menu/match_view/match_view.dart index e85bf77..b5488bc 100644 --- a/lib/presentation/views/main_menu/match_view/match_view.dart +++ b/lib/presentation/views/main_menu/match_view/match_view.dart @@ -5,7 +5,9 @@ import 'package:fluttericon/rpg_awesome_icons.dart'; import 'package:game_tracker/core/adaptive_page_route.dart'; import 'package:game_tracker/core/constants.dart'; import 'package:game_tracker/core/custom_theme.dart'; +import 'package:game_tracker/core/enums.dart'; import 'package:game_tracker/data/db/database.dart'; +import 'package:game_tracker/data/dto/game.dart'; import 'package:game_tracker/data/dto/group.dart'; import 'package:game_tracker/data/dto/match.dart'; import 'package:game_tracker/data/dto/player.dart'; @@ -36,12 +38,15 @@ class _MatchViewState extends State { 4, Match( name: 'Skeleton match name', + game: Game(name: '', ruleset: Ruleset.singleWinner, description: '', color: '', icon: ''), group: Group( name: 'Group name', - members: List.filled(5, Player(name: 'Player')), + description: '', + members: List.filled(5, Player(name: 'Player', description: '')), ), - winner: Player(name: 'Player'), - players: [Player(name: 'Player')], + winner: Player(name: 'Player', description: ''), + players: [Player(name: 'Player', description: '')], + notes: '', ), ); diff --git a/lib/presentation/views/main_menu/statistics_view.dart b/lib/presentation/views/main_menu/statistics_view.dart index f87a3fb..908b10a 100644 --- a/lib/presentation/views/main_menu/statistics_view.dart +++ b/lib/presentation/views/main_menu/statistics_view.dart @@ -167,7 +167,7 @@ class _StatisticsViewState extends State { final playerId = winCounts[i].$1; final player = players.firstWhere( (p) => p.id == playerId, - orElse: () => Player(id: playerId, name: loc.not_available), + orElse: () => Player(id: playerId, name: loc.not_available, description: ''), ); winCounts[i] = (player.name, winCounts[i].$2); } @@ -231,7 +231,7 @@ class _StatisticsViewState extends State { final playerId = matchCounts[i].$1; final player = players.firstWhere( (p) => p.id == playerId, - orElse: () => Player(id: playerId, name: loc.not_available), + orElse: () => Player(id: playerId, name: loc.not_available, description: ''), ); matchCounts[i] = (player.name, matchCounts[i].$2); } diff --git a/lib/presentation/widgets/player_selection.dart b/lib/presentation/widgets/player_selection.dart index 58b62ec..68aaa7d 100644 --- a/lib/presentation/widgets/player_selection.dart +++ b/lib/presentation/widgets/player_selection.dart @@ -62,7 +62,7 @@ class _PlayerSelectionState extends State { /// Skeleton data used while loading players. late final List skeletonData = List.filled( 7, - Player(name: 'Player 0'), + Player(name: 'Player 0', description: ''), ); @override @@ -260,7 +260,7 @@ class _PlayerSelectionState extends State { final loc = AppLocalizations.of(context); final playerName = _searchBarController.text.trim(); - final createdPlayer = Player(name: playerName); + final createdPlayer = Player(name: playerName, description: ''); final success = await db.playerDao.addPlayer(player: createdPlayer); if (!context.mounted) return; diff --git a/lib/services/data_transfer_service.dart b/lib/services/data_transfer_service.dart index e659e45..4bd8635 100644 --- a/lib/services/data_transfer_service.dart +++ b/lib/services/data_transfer_service.dart @@ -61,7 +61,7 @@ class DataTransferService { 'id': m.id, 'name': m.name, 'createdAt': m.createdAt.toIso8601String(), - 'gameId': m.game?.id, + 'gameId': m.game.id, 'groupId': m.group?.id, 'playerIds': (m.players ?? []).map((p) => p.id).toList(), 'notes': m.notes, @@ -160,7 +160,7 @@ class DataTransferService { return Group( id: map['id'] as String, name: map['name'] as String, - description: map['description'] as String?, + description: map['description'] as String, members: members, createdAt: DateTime.parse(map['createdAt'] as String), ); @@ -192,11 +192,11 @@ class DataTransferService { final List importedMatches = matchesJson.map((m) { final map = m as Map; - final String? gameId = map['gameId'] as String?; + final String gameId = map['gameId'] as String; final String? groupId = map['groupId'] as String?; final List playerIds = (map['playerIds'] as List? ?? []).cast(); - final game = (gameId == null) ? null : gameById[gameId]; + final game = gameById[gameId]; final group = (groupId == null) ? null : groupById[groupId]; final players = playerIds .map((id) => playerById[id]) @@ -206,11 +206,11 @@ class DataTransferService { return Match( id: map['id'] as String, name: map['name'] as String, - game: game, + game: game ?? Game(name: 'Unknown', ruleset: Ruleset.singleWinner, description: '', color: '', icon: ''), group: group, players: players.isNotEmpty ? players : null, createdAt: DateTime.parse(map['createdAt'] as String), - notes: map['notes'] as String?, + notes: map['notes'] as String? ?? '', ); }).toList(); diff --git a/test/db_tests/game_test.dart b/test/db_tests/game_test.dart index 040d607..e38b85c 100644 --- a/test/db_tests/game_test.dart +++ b/test/db_tests/game_test.dart @@ -44,6 +44,7 @@ void main() { ruleset: Ruleset.highestScore, description: 'A board game about real estate', color: '0xFF000000', + icon: '', ); }); }); @@ -133,7 +134,7 @@ void main() { // Verifies that a game with null optional fields can be added and retrieved. test('addGame handles game with null optional fields', () async { - final gameWithNulls = Game(name: 'Simple Game', ruleset: Ruleset.lowestScore, description: 'A simple game', color: '0xFF000000'); + final gameWithNulls = Game(name: 'Simple Game', ruleset: Ruleset.lowestScore, description: 'A simple game', color: '0xFF000000', icon: ''); final result = await database.gameDao.addGame(game: gameWithNulls); expect(result, true); @@ -374,19 +375,19 @@ void main() { expect(updatedGame.icon, 'new_chess_icon'); }); - // Verifies that updateGameIcon can set the icon to null. - test('updateGameIcon can set icon to null', () async { + // Verifies that updateGameIcon can update the icon. + test('updateGameIcon updates icon correctly', () async { await database.gameDao.addGame(game: testGame1); await database.gameDao.updateGameIcon( gameId: testGame1.id, - newIcon: null, + newIcon: 'new_icon', ); final updatedGame = await database.gameDao.getGameById( gameId: testGame1.id, ); - expect(updatedGame.icon, isNull); + expect(updatedGame.icon, 'new_icon'); }); // Verifies that updateGameIcon does nothing when game doesn't exist. @@ -460,6 +461,7 @@ void main() { ruleset: Ruleset.multipleWinners, description: 'Description with émojis 🎮🎲', color: '0xFF000000', + icon: '', ); await database.gameDao.addGame(game: specialGame); @@ -498,6 +500,7 @@ void main() { description: longString, ruleset: Ruleset.multipleWinners, color: '0xFF000000', + icon: '', ); await database.gameDao.addGame(game: longGame); diff --git a/test/db_tests/group_test.dart b/test/db_tests/group_test.dart index ada0430..09b7466 100644 --- a/test/db_tests/group_test.dart +++ b/test/db_tests/group_test.dart @@ -29,27 +29,31 @@ void main() { ); withClock(fakeClock, () { - testPlayer1 = Player(name: 'Alice'); - testPlayer2 = Player(name: 'Bob'); - testPlayer3 = Player(name: 'Charlie'); - testPlayer4 = Player(name: 'Diana'); + testPlayer1 = Player(name: 'Alice', description: ''); + testPlayer2 = Player(name: 'Bob', description: ''); + testPlayer3 = Player(name: 'Charlie', description: ''); + testPlayer4 = Player(name: 'Diana', description: ''); testGroup1 = Group( name: 'Test Group', + description: '', members: [testPlayer1, testPlayer2, testPlayer3], ); testGroup2 = Group( id: 'gr2', name: 'Second Group', + description: '', members: [testPlayer2, testPlayer3, testPlayer4], ); testGroup3 = Group( id: 'gr2', name: 'Second Group', + description: '', members: [testPlayer2, testPlayer4], ); testGroup4 = Group( id: 'gr2', name: 'Second Group', + description: '', members: [testPlayer1, testPlayer2, testPlayer3, testPlayer4], ); }); @@ -262,14 +266,14 @@ void main() { final updated = await database.groupDao.updateGroupDescription( groupId: groupWithDescription.id, - newDescription: null, + newDescription: 'Updated description', ); expect(updated, true); final result = await database.groupDao.getGroupById( groupId: groupWithDescription.id, ); - expect(result.description, isNull); + expect(result.description, 'Updated description'); }); // Verifies that updateGroupDescription returns false for a non-existent group. @@ -324,6 +328,7 @@ void main() { test('Group with empty members list is stored correctly', () async { final emptyGroup = Group( name: 'Empty Group', + description: '', members: [], ); await database.groupDao.addGroup(group: emptyGroup); diff --git a/test/db_tests/match_test.dart b/test/db_tests/match_test.dart index 80a9fa7..7bcb0a8 100644 --- a/test/db_tests/match_test.dart +++ b/test/db_tests/match_test.dart @@ -36,26 +36,29 @@ void main() { ); withClock(fakeClock, () { - testPlayer1 = Player(name: 'Alice'); - testPlayer2 = Player(name: 'Bob'); - testPlayer3 = Player(name: 'Charlie'); - testPlayer4 = Player(name: 'Diana'); - testPlayer5 = Player(name: 'Eve'); + testPlayer1 = Player(name: 'Alice', description: ''); + testPlayer2 = Player(name: 'Bob', description: ''); + testPlayer3 = Player(name: 'Charlie', description: ''); + testPlayer4 = Player(name: 'Diana', description: ''); + testPlayer5 = Player(name: 'Eve', description: ''); testGroup1 = Group( name: 'Test Group 2', + description: '', members: [testPlayer1, testPlayer2, testPlayer3], ); testGroup2 = Group( name: 'Test Group 2', + description: '', members: [testPlayer4, testPlayer5], ); - testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000'); + testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000', icon: ''); testMatch1 = Match( name: 'First Test Match', game: testGame, group: testGroup1, players: [testPlayer4, testPlayer5], winner: testPlayer4, + notes: '', ); testMatch2 = Match( name: 'Second Test Match', @@ -63,17 +66,20 @@ void main() { group: testGroup2, players: [testPlayer1, testPlayer2, testPlayer3], winner: testPlayer2, + notes: '', ); testMatchOnlyPlayers = Match( name: 'Test Match with Players', game: testGame, players: [testPlayer1, testPlayer2, testPlayer3], winner: testPlayer3, + notes: '', ); testMatchOnlyGroup = Match( name: 'Test Match with Group', game: testGame, group: testGroup2, + notes: '', ); }); await database.playerDao.addPlayersAsList( diff --git a/test/db_tests/player_group_test.dart b/test/db_tests/player_group_test.dart index 8959092..fa270bb 100644 --- a/test/db_tests/player_group_test.dart +++ b/test/db_tests/player_group_test.dart @@ -26,12 +26,13 @@ void main() { ); withClock(fakeClock, () { - testPlayer1 = Player(name: 'Alice'); - testPlayer2 = Player(name: 'Bob'); - testPlayer3 = Player(name: 'Charlie'); - testPlayer4 = Player(name: 'Diana'); + testPlayer1 = Player(name: 'Alice', description: ''); + testPlayer2 = Player(name: 'Bob', description: ''); + testPlayer3 = Player(name: 'Charlie', description: ''); + testPlayer4 = Player(name: 'Diana', description: ''); testGroup = Group( name: 'Test Group', + description: '', members: [testPlayer1, testPlayer2, testPlayer3], ); }); @@ -186,7 +187,7 @@ void main() { // Verifies that getPlayersOfGroup returns empty list for group with no members. test('getPlayersOfGroup returns empty list for empty group', () async { - final emptyGroup = Group(name: 'Empty Group', members: []); + final emptyGroup = Group(name: 'Empty Group', description: '', members: []); await database.groupDao.addGroup(group: emptyGroup); final players = await database.playerGroupDao.getPlayersOfGroup( @@ -230,7 +231,7 @@ void main() { // Verifies that a player can be in multiple groups. test('Player can be in multiple groups', () async { - final secondGroup = Group(name: 'Second Group', members: []); + final secondGroup = Group(name: 'Second Group', description: '', members: []); await database.groupDao.addGroup(group: testGroup); await database.groupDao.addGroup(group: secondGroup); @@ -255,7 +256,7 @@ void main() { // Verifies that removing player from one group doesn't affect other groups. test('Removing player from one group does not affect other groups', () async { - final secondGroup = Group(name: 'Second Group', members: [testPlayer1]); + final secondGroup = Group(name: 'Second Group', description: '', members: [testPlayer1]); await database.groupDao.addGroup(group: testGroup); await database.groupDao.addGroup(group: secondGroup); diff --git a/test/db_tests/player_match_test.dart b/test/db_tests/player_match_test.dart index 0e5fb27..b8d3313 100644 --- a/test/db_tests/player_match_test.dart +++ b/test/db_tests/player_match_test.dart @@ -37,26 +37,29 @@ void main() { ); withClock(fakeClock, () { - testPlayer1 = Player(name: 'Alice'); - testPlayer2 = Player(name: 'Bob'); - testPlayer3 = Player(name: 'Charlie'); - testPlayer4 = Player(name: 'Diana'); - testPlayer5 = Player(name: 'Eve'); - testPlayer6 = Player(name: 'Frank'); + testPlayer1 = Player(name: 'Alice', description: ''); + testPlayer2 = Player(name: 'Bob', description: ''); + testPlayer3 = Player(name: 'Charlie', description: ''); + testPlayer4 = Player(name: 'Diana', description: ''); + testPlayer5 = Player(name: 'Eve', description: ''); + testPlayer6 = Player(name: 'Frank', description: ''); testGroup = Group( name: 'Test Group', + description: '', members: [testPlayer1, testPlayer2, testPlayer3], ); - testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000'); + testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000', icon: ''); testMatchOnlyGroup = Match( name: 'Test Match with Group', game: testGame, group: testGroup, + notes: '', ); testMatchOnlyPlayers = Match( name: 'Test Match with Players', game: testGame, players: [testPlayer4, testPlayer5, testPlayer6], + notes: '', ); testTeam1 = Team( name: 'Team Alpha', @@ -226,8 +229,8 @@ void main() { 'Adding the same player to separate matches works correctly', () async { final playersList = [testPlayer1, testPlayer2, testPlayer3]; - final match1 = Match(name: 'Match 1', game: testGame, players: playersList); - final match2 = Match(name: 'Match 2', game: testGame, players: playersList); + final match1 = Match(name: 'Match 1', game: testGame, players: playersList, notes: ''); + final match2 = Match(name: 'Match 2', game: testGame, players: playersList, notes: ''); await Future.wait([ database.matchDao.addMatch(match: match1), @@ -760,8 +763,8 @@ void main() { // Verifies that removePlayerFromMatch does not affect other matches. test('removePlayerFromMatch does not affect other matches', () async { final playersList = [testPlayer1, testPlayer2]; - final match1 = Match(name: 'Match 1', game: testGame, players: playersList); - final match2 = Match(name: 'Match 2', game: testGame, players: playersList); + final match1 = Match(name: 'Match 1', game: testGame, players: playersList, notes: ''); + final match2 = Match(name: 'Match 2', game: testGame, players: playersList, notes: ''); await Future.wait([ database.matchDao.addMatch(match: match1), @@ -793,8 +796,8 @@ void main() { // Verifies that updating scores for players in different matches are independent. test('Player scores are independent across matches', () async { final playersList = [testPlayer1]; - final match1 = Match(name: 'Match 1', game: testGame, players: playersList); - final match2 = Match(name: 'Match 2', game: testGame, players: playersList); + final match1 = Match(name: 'Match 1', game: testGame, players: playersList, notes: ''); + final match2 = Match(name: 'Match 2', game: testGame, players: playersList, notes: ''); await Future.wait([ database.matchDao.addMatch(match: match1), diff --git a/test/db_tests/player_test.dart b/test/db_tests/player_test.dart index da5b904..8ce0e66 100644 --- a/test/db_tests/player_test.dart +++ b/test/db_tests/player_test.dart @@ -24,10 +24,10 @@ void main() { ); withClock(fakeClock, () { - testPlayer1 = Player(name: 'Test Player'); - testPlayer2 = Player(name: 'Second Player'); - testPlayer3 = Player(name: 'Charlie'); - testPlayer4 = Player(name: 'Diana'); + testPlayer1 = Player(name: 'Test Player', description: ''); + testPlayer2 = Player(name: 'Second Player', description: ''); + testPlayer3 = Player(name: 'Charlie', description: ''); + testPlayer4 = Player(name: 'Diana', description: ''); }); }); tearDown(() async { @@ -265,7 +265,7 @@ void main() { // Verifies that a player with special characters in name is stored correctly. test('Player with special characters in name is stored correctly', () async { - final specialPlayer = Player(name: 'Test!@#\$%^&*()_+-=[]{}|;\':",.<>?/`~'); + final specialPlayer = Player(name: 'Test!@#\$%^&*()_+-=[]{}|;\':",.<>?/`~', description: ''); await database.playerDao.addPlayer(player: specialPlayer); @@ -293,14 +293,14 @@ void main() { // Verifies that a player with null description is stored correctly. test('Player with null description is stored correctly', () async { - final playerWithoutDescription = Player(name: 'No Description Player'); + final playerWithoutDescription = Player(name: 'No Description Player', description: ''); await database.playerDao.addPlayer(player: playerWithoutDescription); final fetchedPlayer = await database.playerDao.getPlayerById( playerId: playerWithoutDescription.id, ); - expect(fetchedPlayer.description, isNull); + expect(fetchedPlayer.description, ''); }); // Verifies that multiple updates to the same player work correctly. @@ -340,7 +340,7 @@ void main() { // Verifies that a player with empty string name is stored correctly. test('Player with empty string name is stored correctly', () async { - final emptyNamePlayer = Player(name: ''); + final emptyNamePlayer = Player(name: '', description: ''); await database.playerDao.addPlayer(player: emptyNamePlayer); @@ -353,7 +353,7 @@ void main() { // Verifies that a player with very long name is stored correctly. test('Player with very long name is stored correctly', () async { final longName = 'A' * 1000; - final longNamePlayer = Player(name: longName); + final longNamePlayer = Player(name: longName, description: ''); await database.playerDao.addPlayer(player: longNamePlayer); diff --git a/test/db_tests/score_test.dart b/test/db_tests/score_test.dart index 9052a32..bbd7729 100644 --- a/test/db_tests/score_test.dart +++ b/test/db_tests/score_test.dart @@ -29,19 +29,21 @@ void main() { ); withClock(fakeClock, () { - testPlayer1 = Player(name: 'Alice'); - testPlayer2 = Player(name: 'Bob'); - testPlayer3 = Player(name: 'Charlie'); - testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000'); + testPlayer1 = Player(name: 'Alice', description: ''); + testPlayer2 = Player(name: 'Bob', description: ''); + testPlayer3 = Player(name: 'Charlie', description: ''); + testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000', icon: ''); testMatch1 = Match( name: 'Test Match 1', game: testGame, players: [testPlayer1, testPlayer2], + notes: '', ); testMatch2 = Match( name: 'Test Match 2', game: testGame, players: [testPlayer2, testPlayer3], + notes: '', ); }); diff --git a/test/db_tests/team_test.dart b/test/db_tests/team_test.dart index efeaf18..19338cb 100644 --- a/test/db_tests/team_test.dart +++ b/test/db_tests/team_test.dart @@ -33,10 +33,10 @@ void main() { ); withClock(fakeClock, () { - testPlayer1 = Player(name: 'Alice'); - testPlayer2 = Player(name: 'Bob'); - testPlayer3 = Player(name: 'Charlie'); - testPlayer4 = Player(name: 'Diana'); + testPlayer1 = Player(name: 'Alice', description: ''); + testPlayer2 = Player(name: 'Bob', description: ''); + testPlayer3 = Player(name: 'Charlie', description: ''); + testPlayer4 = Player(name: 'Diana', description: ''); testTeam1 = Team( name: 'Team Alpha', members: [testPlayer1, testPlayer2], @@ -49,8 +49,8 @@ void main() { name: 'Team Gamma', members: [testPlayer1, testPlayer3], ); - testGame1 = Game(name: 'Game 1', ruleset: Ruleset.singleWinner, description: 'Test game 1', color: '0xFF000000'); - testGame2 = Game(name: 'Game 2', ruleset: Ruleset.highestScore, description: 'Test game 2', color: '0xFF000000'); + testGame1 = Game(name: 'Game 1', ruleset: Ruleset.singleWinner, description: 'Test game 1', color: '0xFF000000', icon: ''); + testGame2 = Game(name: 'Game 2', ruleset: Ruleset.highestScore, description: 'Test game 2', color: '0xFF000000', icon: ''); }); await database.playerDao.addPlayersAsList( @@ -344,8 +344,8 @@ void main() { // Verifies that teams with overlapping members are independent. test('Teams with overlapping members are independent', () async { // Create two matches since player_match has primary key {playerId, matchId} - final match1 = Match(name: 'Match 1', game: testGame1); - final match2 = Match(name: 'Match 2', game: testGame2); + final match1 = Match(name: 'Match 1', game: testGame1, notes: ''); + final match2 = Match(name: 'Match 2', game: testGame2, notes: ''); await database.matchDao.addMatch(match: match1); await database.matchDao.addMatch(match: match2);