feat: added test for exported json
Some checks failed
Pull Request Pipeline / lint (pull_request) Successful in 51s
Pull Request Pipeline / test (pull_request) Failing after 10m46s

This commit is contained in:
2026-05-11 12:23:48 +02:00
parent 881382b399
commit badf5ea311
2 changed files with 22 additions and 35 deletions

View File

@@ -102,36 +102,6 @@
]
}
},
"teams": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"memberIds": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false,
"required": [
"id",
"name",
"createdAt",
"memberIds"
]
}
},
"matches": {
"type": "array",
"items": {
@@ -195,6 +165,9 @@
},
"notes": {
"type": "string"
},
"teams": {
"type": ["array", "null"]
}
},
"additionalProperties": false,
@@ -214,7 +187,6 @@
"players",
"games",
"groups",
"teams",
"matches"
]
}

View File

@@ -137,9 +137,6 @@ void main() {
await database.playerDao.addPlayer(player: testPlayer2);
await database.gameDao.addGame(game: testGame);
await database.groupDao.addGroup(group: testGroup);
/*
await database.teamDao.addTeam(team: testTeam);
*/
await database.matchDao.addMatch(match: testMatch);
final ctx = await getContext(tester);
@@ -853,7 +850,7 @@ void main() {
});
});
test('validateJsonSchema()', () async {
test('validateJsonSchema() works correctly', () async {
final validJson = json.encode({
'players': [
{
@@ -912,5 +909,23 @@ void main() {
final isValid = await DataTransferService.validateJsonSchema(validJson);
expect(isValid, true);
});
testWidgets('validateJsonSchema() validates exported json file', (
tester,
) async {
await database.playerDao.addPlayer(player: testPlayer1);
await database.playerDao.addPlayer(player: testPlayer2);
await database.gameDao.addGame(game: testGame);
await database.groupDao.addGroup(group: testGroup);
await database.matchDao.addMatch(match: testMatch);
final ctx = await getContext(tester);
final jsonString = await DataTransferService.getAppDataAsJson(ctx);
expect(jsonString, isNotEmpty);
final isValid = await DataTransferService.validateJsonSchema(jsonString);
expect(isValid, true);
});
});
}