Revert "Merge branch 'feature/193-statisticsview-rework' into development"
All checks were successful
Push Pipeline / update_version (push) Successful in 6s
Push Pipeline / generate_licenses (push) Successful in 38s
Push Pipeline / generate_localizations (push) Successful in 29s
Push Pipeline / test (push) Successful in 1m35s
Push Pipeline / sort_arb_files (push) Successful in 31s
Push Pipeline / format (push) Successful in 55s
Push Pipeline / build (push) Successful in 4m58s
All checks were successful
Push Pipeline / update_version (push) Successful in 6s
Push Pipeline / generate_licenses (push) Successful in 38s
Push Pipeline / generate_localizations (push) Successful in 29s
Push Pipeline / test (push) Successful in 1m35s
Push Pipeline / sort_arb_files (push) Successful in 31s
Push Pipeline / format (push) Successful in 55s
Push Pipeline / build (push) Successful in 4m58s
This reverts commit24f49e17b9, reversing changes made todba6c218d6. # Conflicts: # pubspec.yaml
This commit is contained in:
@@ -28,7 +28,7 @@ void main() {
|
||||
name: 'Chess',
|
||||
ruleset: Ruleset.singleWinner,
|
||||
description: 'A classic strategy game',
|
||||
color: AppColor.blue,
|
||||
color: GameColor.blue,
|
||||
icon: 'chess_icon',
|
||||
);
|
||||
testGame2 = Game(
|
||||
@@ -36,7 +36,7 @@ void main() {
|
||||
name: 'Poker',
|
||||
ruleset: Ruleset.multipleWinners,
|
||||
description: 'Card game with multiple winners',
|
||||
color: AppColor.red,
|
||||
color: GameColor.red,
|
||||
icon: 'poker_icon',
|
||||
);
|
||||
testGame3 = Game(
|
||||
@@ -44,7 +44,7 @@ void main() {
|
||||
name: 'Monopoly',
|
||||
ruleset: Ruleset.highestScore,
|
||||
description: 'A board game about real estate',
|
||||
color: AppColor.orange,
|
||||
color: GameColor.orange,
|
||||
icon: '',
|
||||
);
|
||||
});
|
||||
@@ -124,7 +124,7 @@ void main() {
|
||||
name: 'Game\'s & "Special" <Name>',
|
||||
ruleset: Ruleset.multipleWinners,
|
||||
description: 'Description with émojis 🎮🎲',
|
||||
color: AppColor.purple,
|
||||
color: GameColor.purple,
|
||||
icon: '',
|
||||
);
|
||||
await database.gameDao.addGame(game: specialGame);
|
||||
@@ -280,19 +280,19 @@ void main() {
|
||||
|
||||
await database.gameDao.updateGameColor(
|
||||
gameId: testGame1.id,
|
||||
color: AppColor.green,
|
||||
color: GameColor.green,
|
||||
);
|
||||
|
||||
final updatedGame = await database.gameDao.getGameById(
|
||||
gameId: testGame1.id,
|
||||
);
|
||||
expect(updatedGame.color, AppColor.green);
|
||||
expect(updatedGame.color, GameColor.green);
|
||||
});
|
||||
|
||||
test('updateGameColor() does nothing for non-existent game', () async {
|
||||
final updated = await database.gameDao.updateGameColor(
|
||||
gameId: 'non-existent-id',
|
||||
color: AppColor.green,
|
||||
color: GameColor.green,
|
||||
);
|
||||
expect(updated, isFalse);
|
||||
|
||||
@@ -336,7 +336,7 @@ void main() {
|
||||
name: newName,
|
||||
);
|
||||
|
||||
const newGameColor = AppColor.teal;
|
||||
const newGameColor = GameColor.teal;
|
||||
await database.gameDao.updateGameColor(
|
||||
gameId: testGame1.id,
|
||||
color: newGameColor,
|
||||
|
||||
@@ -233,95 +233,6 @@ void main() {
|
||||
expect(allPlayers, isEmpty);
|
||||
});
|
||||
|
||||
test('updatePlayerName() sets correct nameCount with 2 player', () async {
|
||||
await database.playerDao.addPlayer(player: testPlayer1);
|
||||
await database.playerDao.addPlayer(player: testPlayer2);
|
||||
|
||||
final newName = testPlayer1.name;
|
||||
await database.playerDao.updatePlayerName(
|
||||
playerId: testPlayer2.id,
|
||||
name: newName,
|
||||
);
|
||||
|
||||
var player = await database.playerDao.getPlayerById(
|
||||
playerId: testPlayer1.id,
|
||||
);
|
||||
expect(player.nameCount, 1);
|
||||
|
||||
player = await database.playerDao.getPlayerById(
|
||||
playerId: testPlayer2.id,
|
||||
);
|
||||
expect(player.nameCount, 2);
|
||||
|
||||
await database.playerDao.updatePlayerName(
|
||||
playerId: testPlayer1.id,
|
||||
name: 'different name',
|
||||
);
|
||||
|
||||
player = await database.playerDao.getPlayerById(
|
||||
playerId: testPlayer1.id,
|
||||
);
|
||||
expect(player.nameCount, 0);
|
||||
|
||||
player = await database.playerDao.getPlayerById(
|
||||
playerId: testPlayer2.id,
|
||||
);
|
||||
expect(player.nameCount, 0);
|
||||
});
|
||||
|
||||
test('updatePlayerName() sets correct nameCount with 3 player', () async {
|
||||
await database.playerDao.addPlayersAsList(
|
||||
players: [testPlayer1, testPlayer2, testPlayer3],
|
||||
);
|
||||
|
||||
// Changing both names to player 1's name
|
||||
final newName = testPlayer1.name;
|
||||
await database.playerDao.updatePlayerName(
|
||||
playerId: testPlayer2.id,
|
||||
name: newName,
|
||||
);
|
||||
await database.playerDao.updatePlayerName(
|
||||
playerId: testPlayer3.id,
|
||||
name: newName,
|
||||
);
|
||||
|
||||
var player = await database.playerDao.getPlayerById(
|
||||
playerId: testPlayer1.id,
|
||||
);
|
||||
expect(player.nameCount, 1);
|
||||
|
||||
player = await database.playerDao.getPlayerById(
|
||||
playerId: testPlayer2.id,
|
||||
);
|
||||
expect(player.nameCount, 2);
|
||||
|
||||
player = await database.playerDao.getPlayerById(
|
||||
playerId: testPlayer3.id,
|
||||
);
|
||||
expect(player.nameCount, 3);
|
||||
|
||||
// Changing the middle players name
|
||||
await database.playerDao.updatePlayerName(
|
||||
playerId: testPlayer2.id,
|
||||
name: 'different name',
|
||||
);
|
||||
|
||||
player = await database.playerDao.getPlayerById(
|
||||
playerId: testPlayer1.id,
|
||||
);
|
||||
expect(player.nameCount, 1);
|
||||
|
||||
player = await database.playerDao.getPlayerById(
|
||||
playerId: testPlayer2.id,
|
||||
);
|
||||
expect(player.nameCount, 0);
|
||||
|
||||
player = await database.playerDao.getPlayerById(
|
||||
playerId: testPlayer3.id,
|
||||
);
|
||||
expect(player.nameCount, 2);
|
||||
});
|
||||
|
||||
test('updatePlayerDescription() works correctly', () async {
|
||||
await database.playerDao.addPlayer(player: testPlayer1);
|
||||
|
||||
@@ -461,22 +372,14 @@ void main() {
|
||||
final player1 = Player(name: testPlayer1.name, description: '');
|
||||
await database.playerDao.addPlayer(player: player1);
|
||||
|
||||
final player2 = Player(name: testPlayer1.name, description: '');
|
||||
await database.playerDao.addPlayer(player: player2);
|
||||
|
||||
var players = await database.playerDao.getAllPlayers();
|
||||
|
||||
expect(players.length, 3);
|
||||
expect(players.length, 2);
|
||||
players.sort((a, b) => a.nameCount.compareTo(b.nameCount));
|
||||
|
||||
for (int i = 0; i < players.length - 1; i++) {
|
||||
expect(players[i].nameCount, i + 1);
|
||||
}
|
||||
|
||||
// ids are correct in the right order
|
||||
expect(players[0].id, testPlayer1.id);
|
||||
expect(players[1].id, player1.id);
|
||||
expect(players[2].id, player2.id);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -501,62 +404,24 @@ void main() {
|
||||
for (int i = 0; i < players.length - 1; i++) {
|
||||
expect(players[i].nameCount, i + 1);
|
||||
}
|
||||
|
||||
// ids are correct in the right order
|
||||
expect(players[0].id, testPlayer1.id);
|
||||
expect(players[1].id, player1.id);
|
||||
expect(players[2].id, player2.id);
|
||||
expect(players[3].id, player3.id);
|
||||
},
|
||||
);
|
||||
|
||||
test('getNameCount works correctly', () async {
|
||||
final player1 = Player(name: testPlayer1.name);
|
||||
test('getNameCount works correctly', () async {
|
||||
final player2 = Player(name: testPlayer1.name);
|
||||
final player3 = Player(name: testPlayer1.name);
|
||||
|
||||
await database.playerDao.addPlayer(player: testPlayer1);
|
||||
|
||||
var nameCount = await database.playerDao.getNameCount(
|
||||
name: testPlayer1.name,
|
||||
await database.playerDao.addPlayersAsList(
|
||||
players: [testPlayer1, player2, player3],
|
||||
);
|
||||
|
||||
expect(nameCount, 1);
|
||||
|
||||
await database.playerDao.addPlayersAsList(players: [player1, player2]);
|
||||
|
||||
nameCount = await database.playerDao.getNameCount(
|
||||
final nameCount = await database.playerDao.getNameCount(
|
||||
name: testPlayer1.name,
|
||||
);
|
||||
|
||||
expect(nameCount, 3);
|
||||
});
|
||||
|
||||
test('calculateNameCount works correctly', () async {
|
||||
final player1 = Player(name: testPlayer1.name);
|
||||
final player2 = Player(name: testPlayer1.name);
|
||||
|
||||
// Case 1: No existing players with the name
|
||||
var nameCount = await database.playerDao.calculateNameCount(
|
||||
name: testPlayer1.name,
|
||||
);
|
||||
expect(nameCount, 0);
|
||||
|
||||
// Case 2: One existing player with the name. Should return 2 for
|
||||
// the new player
|
||||
await database.playerDao.addPlayer(player: testPlayer1);
|
||||
nameCount = await database.playerDao.calculateNameCount(
|
||||
name: testPlayer1.name,
|
||||
);
|
||||
expect(nameCount, 2);
|
||||
|
||||
// Case 3: Multiple existing players with the name. Should return count + 1
|
||||
await database.playerDao.addPlayersAsList(players: [player1, player2]);
|
||||
nameCount = await database.playerDao.calculateNameCount(
|
||||
name: testPlayer1.name,
|
||||
);
|
||||
expect(nameCount, 4);
|
||||
});
|
||||
|
||||
test('updateNameCount works correctly', () async {
|
||||
await database.playerDao.addPlayer(player: testPlayer1);
|
||||
|
||||
@@ -576,24 +441,14 @@ void main() {
|
||||
final player2 = Player(name: testPlayer1.name, description: '');
|
||||
final player3 = Player(name: testPlayer1.name, description: '');
|
||||
|
||||
await database.playerDao.addPlayer(player: testPlayer1);
|
||||
var player = await database.playerDao.getPlayerWithHighestNameCount(
|
||||
name: testPlayer1.name,
|
||||
await database.playerDao.addPlayersAsList(
|
||||
players: [testPlayer1, player2, player3],
|
||||
);
|
||||
expect(player, isNotNull);
|
||||
expect(player!.nameCount, 0);
|
||||
|
||||
await database.playerDao.addPlayer(player: player2);
|
||||
player = await database.playerDao.getPlayerWithHighestNameCount(
|
||||
final player = await database.playerDao.getPlayerWithHighestNameCount(
|
||||
name: testPlayer1.name,
|
||||
);
|
||||
expect(player, isNotNull);
|
||||
expect(player!.nameCount, 2);
|
||||
|
||||
await database.playerDao.addPlayer(player: player3);
|
||||
player = await database.playerDao.getPlayerWithHighestNameCount(
|
||||
name: testPlayer1.name,
|
||||
);
|
||||
expect(player, isNotNull);
|
||||
expect(player!.nameCount, 3);
|
||||
});
|
||||
@@ -605,6 +460,32 @@ void main() {
|
||||
expect(player, isNull);
|
||||
});
|
||||
|
||||
test('calculateNameCount works correctly', () async {
|
||||
// Case 1: No existing players with the name
|
||||
var count = await database.playerDao.calculateNameCount(
|
||||
name: testPlayer1.name,
|
||||
);
|
||||
expect(count, 0);
|
||||
|
||||
// Case 2: One existing player with the name. Should update that
|
||||
// player's nameCount to 1 and return 2 for the new player
|
||||
await database.playerDao.addPlayer(player: testPlayer1);
|
||||
|
||||
count = await database.playerDao.calculateNameCount(
|
||||
name: testPlayer1.name,
|
||||
);
|
||||
expect(count, 2);
|
||||
|
||||
// Case 3: Multiple existing players with the name.
|
||||
final player2 = Player(name: testPlayer1.name, nameCount: count);
|
||||
await database.playerDao.addPlayer(player: player2);
|
||||
|
||||
count = await database.playerDao.calculateNameCount(
|
||||
name: testPlayer1.name,
|
||||
);
|
||||
expect(count, 3);
|
||||
});
|
||||
|
||||
test('getPlayerWithHighestNameCount with non existing player', () async {
|
||||
await database.playerDao.addPlayer(player: testPlayer1);
|
||||
await database.playerDao.initializeNameCount(name: testPlayer1.name);
|
||||
|
||||
Reference in New Issue
Block a user