import { test, expect } from '@playwright/test'; import axios from 'axios'; import { createTempEmail, waitForConfirmationCode } from '../../../utils/mailTmApi'; import { generateFirstName, generateLastName, generateMiddleName, generateLogin, generatePhone, } from '../../../utils/userGenerator'; const BASE_URL = 'https://rumc.dev.rdcenter.ru/api'; test('API: регистрация выпускника + подтверждение почты', async () => { const { email, token: mailToken } = await createTempEmail(); const surname = generateLastName(); const name = generateFirstName(); const patronymic = generateMiddleName(); const fullName = `${surname} ${name} ${patronymic}`; const login = generateLogin(); const phone = '+7 (900) 000-00-00'; const registerPayload = { type: 'INDIVIDUAL', programId: 'a0d11741-eeae-11ef-b5b3-00155d011a8e', educationForm: 'Очная', educationLevel: 'Специалитет', login, fullName, email, password: '!Test123456', phone, approval: true }; try { const registerRes = await axios.post(`${BASE_URL}/auth/register/graduate`, registerPayload); expect(registerRes.status).toBe(200); const userId = registerRes.data.userId; console.log('🆔 ID зарегистрированного пользователя:', userId); } catch (error: any) { console.error('❌ Ошибка регистрации:', error.response?.data || error.message); throw error; } console.log('📬 Ожидание письма с кодом подтверждения...'); const code = await waitForConfirmationCode(mailToken, 60000); console.log('✅ Код получен:', code); const confirmPayload = { email, code }; const confirmRes = await axios.post(`${BASE_URL}/auth/confirm`, confirmPayload); expect(confirmRes.status).toBe(200); console.log('🎉 Почта подтверждена успешно'); });