Files
at-digitaltwin/tests/api/registration/register-applicant.api.spec.ts
2026-01-26 17:50:18 +03:00

63 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 = {
role: 'APPLICANT',
type: 'INDIVIDUAL',
login,
fullName,
email,
password: '!Test123456',
phone,
approval: true
};
//const registerRes = await axios.post(`${BASE_URL}/auth/register`, registerPayload);
//expect(registerRes.status).toBe(201);
try {
const registerRes = await axios.post(`${BASE_URL}/auth/register`, registerPayload);
expect(registerRes.status).toBe(201);
} 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('🎉 Почта подтверждена успешно');
});