Добавил позитивные сценарии для UI, API регистрации организации
This commit is contained in:
81
tests/api/registration/register-organization.api.spec.ts
Normal file
81
tests/api/registration/register-organization.api.spec.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import axios from 'axios';
|
||||
import {
|
||||
createTempEmail,
|
||||
waitForConfirmationCode
|
||||
} from '../../../utils/mailTmApi';
|
||||
import {
|
||||
generateFirstName,
|
||||
generateLastName,
|
||||
generateMiddleName,
|
||||
generateLogin,
|
||||
generatePhone,
|
||||
generateKPP,
|
||||
generateINN,
|
||||
generateShortOrgName,
|
||||
generateFullOrgName
|
||||
} 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 representativeName = `${surname} ${name} ${patronymic}`;
|
||||
const login = generateLogin();
|
||||
const phone = '+7 (900) 000-00-00';
|
||||
const password = '!Test123456';
|
||||
const shortName = generateShortOrgName();
|
||||
const fullName = generateFullOrgName();
|
||||
const kpp = generateKPP();
|
||||
const inn = generateINN();
|
||||
|
||||
const registerPayload = {
|
||||
shortName,
|
||||
fullName,
|
||||
description: "Абсолютно неуникальное тестовое описание",
|
||||
website: "https://test-org.ru",
|
||||
address: "г. Таганрог, ул. Тестовая, д. 1",
|
||||
inn,
|
||||
kpp,
|
||||
representativeName,
|
||||
position: "Генеральный директор",
|
||||
phone,
|
||||
basis: "федерального закона",
|
||||
email,
|
||||
password,
|
||||
login,
|
||||
socialLinks: {
|
||||
tg: "https://t.me/test_user",
|
||||
vk: "https://vk.com/test_user"
|
||||
}};
|
||||
|
||||
try {
|
||||
const registerRes = await axios.post(`${BASE_URL}/auth/register/organization`, 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('🎉 Почта подтверждена успешно');
|
||||
});
|
||||
Reference in New Issue
Block a user