Send club context and surface TTR preview HTTP errors
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 59s
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 59s
This commit is contained in:
@@ -102,13 +102,14 @@ test('test mode on a saved report calls the real endpoint and exposes lookup dia
|
||||
standaloneTest: false,
|
||||
isTestMode: true,
|
||||
canOpenTtrPreview: true,
|
||||
match: { id: 42 },
|
||||
match: { id: 42, clubId: 7 },
|
||||
meetingDetails: {},
|
||||
meetingData: { homeClub: 'TSV 1875 Bonames', guestClub: 'Eintracht Frankfurt' },
|
||||
});
|
||||
const originalPost = context.apiClient.post;
|
||||
context.apiClient.post = async (url, body) => {
|
||||
assert.equal(url, '/matches/42/ttr-preview');
|
||||
assert.equal(body.clubId, 7);
|
||||
assert.equal(body.homeClubName, 'TSV 1875 Bonames');
|
||||
assert.equal(body.homePlayers[0].name, 'Anton Schottdorf');
|
||||
return { data: { players: [], diagnostics: [{ side: 'home', message: 'Session abgelaufen' }] } };
|
||||
@@ -121,3 +122,25 @@ test('test mode on a saved report calls the real endpoint and exposes lookup dia
|
||||
context.apiClient.post = originalPost;
|
||||
}
|
||||
});
|
||||
|
||||
test('HTTP errors accepted by the shared API client are shown instead of becoming empty results', async () => {
|
||||
const report = dialog();
|
||||
Object.assign(report, {
|
||||
standaloneTest: false, canOpenTtrPreview: true,
|
||||
match: { id: 42, clubId: 7 }, meetingDetails: {}, meetingData: {},
|
||||
});
|
||||
const originalPost = context.apiClient.post;
|
||||
try {
|
||||
for (const status of [400, 401, 403, 404, 500]) {
|
||||
context.apiClient.post = async () => ({ status, data: { error: `Fehler ${status}` } });
|
||||
await report.loadTtrPreview();
|
||||
assert.equal(report.ttrError, `Fehler ${status}`);
|
||||
assert.equal(report.ttrLoading, false);
|
||||
}
|
||||
context.apiClient.post = async () => ({ status: 200, data: '<html>Keine API-Antwort</html>' });
|
||||
await report.loadTtrPreview();
|
||||
assert.match(report.ttrError, /keine gültigen TTR-Spielerdaten/);
|
||||
} finally {
|
||||
context.apiClient.post = originalPost;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user