fix: Improve error handling and logging in chess user journey scenario
This commit is contained in:
@@ -13,18 +13,26 @@ export function chessUserJourney() {
|
|||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
}), httpConfig);
|
}), 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
|
// Login
|
||||||
const loginRes = http.post(`${BASE_URL}/api/account/login`, JSON.stringify({
|
const loginRes = http.post(`${BASE_URL}/api/account/login`, JSON.stringify({
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
}), httpConfig);
|
}), 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');
|
const jwt = loginRes.json('token');
|
||||||
if (!jwt) {
|
if (!jwt) {
|
||||||
console.error('Failed to get JWT token');
|
console.error('Failed to get JWT token from login response');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,11 +48,15 @@ export function chessUserJourney() {
|
|||||||
black: { id: `opponent_${__VU}`, displayName: 'Opponent' },
|
black: { id: `opponent_${__VU}`, displayName: 'Opponent' },
|
||||||
timeControl: { limitSeconds: 300, incrementSeconds: 3 },
|
timeControl: { limitSeconds: 300, incrementSeconds: 3 },
|
||||||
}), { headers: authHeaders, timeout: '30s' });
|
}), { 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');
|
const gameId = importRes.json('gameId');
|
||||||
if (!gameId) {
|
if (!gameId) {
|
||||||
console.error('Failed to get gameId');
|
console.error('Failed to get gameId from import response');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user