fix: Improve error handling and logging in chess user journey scenario

This commit is contained in:
2026-05-13 20:53:51 +02:00
parent fbe0d20dc5
commit 55bc188560
+17 -5
View File
@@ -13,18 +13,26 @@ export function chessUserJourney() {
email,
password,
}), httpConfig);
check(registerRes, { 'Register: status 200': (r) => r.status === 200 });
const registerOk = check(registerRes, { 'Register: status 200': (r) => r.status === 200 });
if (!registerOk || !registerRes.body) {
console.error('Register failed or no body returned');
return;
}
// Login
const loginRes = http.post(`${BASE_URL}/api/account/login`, JSON.stringify({
username,
password,
}), httpConfig);
check(loginRes, { 'Login: status 200': (r) => r.status === 200 });
const loginOk = check(loginRes, { 'Login: status 200': (r) => r.status === 200 });
if (!loginOk || !loginRes.body) {
console.error('Login failed or no body returned');
return;
}
const jwt = loginRes.json('token');
if (!jwt) {
console.error('Failed to get JWT token');
console.error('Failed to get JWT token from login response');
return;
}
@@ -40,11 +48,15 @@ export function chessUserJourney() {
black: { id: `opponent_${__VU}`, displayName: 'Opponent' },
timeControl: { limitSeconds: 300, incrementSeconds: 3 },
}), { headers: authHeaders, timeout: '30s' });
check(importRes, { 'Import Game: status 200/201': (r) => r.status === 200 || r.status === 201 });
const importOk = check(importRes, { 'Import Game: status 200/201': (r) => r.status === 200 || r.status === 201 });
if (!importOk || !importRes.body) {
console.error('Import game failed or no body returned');
return;
}
const gameId = importRes.json('gameId');
if (!gameId) {
console.error('Failed to get gameId');
console.error('Failed to get gameId from import response');
return;
}