Добавлен позитивный API тест для проверки восстановления пароля
This commit is contained in:
42
tests/api/auth/recover-password.api.spec.ts
Normal file
42
tests/api/auth/recover-password.api.spec.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import axios from 'axios';
|
||||
import fs from 'fs';
|
||||
|
||||
const BASE_URL = 'https://rumc.dev.rdcenter.ru/api';
|
||||
const NEW_PASSWORD = '!Test123456';
|
||||
|
||||
const user = JSON.parse(fs.readFileSync('temp/user.json', 'utf-8'));
|
||||
|
||||
test('API: восстановление пароля', async () => {
|
||||
const email = user.email;
|
||||
|
||||
const sendResetRes = await axios.post(`${BASE_URL}/auth/resetPassword?type=reset`, {
|
||||
email,
|
||||
});
|
||||
expect(sendResetRes.status).toBe(201);
|
||||
|
||||
console.log('📬 Письмо с кодом отправлено');
|
||||
|
||||
const { waitForConfirmationCode } = await import('../../../utils/mailTmApi');
|
||||
const code = await waitForConfirmationCode(email, user.mailToken, 'recover', 60000);
|
||||
expect(code).toMatch(/^\d{6}$/);
|
||||
console.log('✅ Код подтверждения:', code);
|
||||
|
||||
const confirmRes = await axios.post(`${BASE_URL}/auth/confirmReset`, {
|
||||
email,
|
||||
code
|
||||
});
|
||||
expect(confirmRes.status).toBe(201);
|
||||
const resetTokenRaw = confirmRes.data.resetTokenRaw;
|
||||
console.log('🔑 Получен resetToken:', resetTokenRaw);
|
||||
|
||||
const recoveryRes = await axios.post(`${BASE_URL}/auth/recovery`, {
|
||||
email,
|
||||
resetToken: resetTokenRaw,
|
||||
passwordReset: NEW_PASSWORD
|
||||
});
|
||||
expect(recoveryRes.status).toBe(201);
|
||||
|
||||
const accessToken = recoveryRes.data.access_token;
|
||||
console.log('🪪 Новый access_token:', accessToken);
|
||||
});
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
const BASE_URL = 'https://rumc.dev.rdcenter.ru/api';
|
||||
|
||||
test('API: регистрация абитуриента + подтверждение почты', async () => {
|
||||
await new Promise(r => setTimeout(r, 3000));
|
||||
const { email, token: mailToken } = await createTempEmail();
|
||||
|
||||
const surname = generateLastName();
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
const BASE_URL = 'https://rumc.dev.rdcenter.ru/api';
|
||||
|
||||
test('API: регистрация выпускника + подтверждение почты', async () => {
|
||||
await new Promise(r => setTimeout(r, 3000));
|
||||
const { email, token: mailToken } = await createTempEmail();
|
||||
|
||||
const surname = generateLastName();
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
const BASE_URL = 'https://rumc.dev.rdcenter.ru/api';
|
||||
|
||||
test('API: регистрация организации + подтверждение почты', async () => {
|
||||
await new Promise(r => setTimeout(r, 3000));
|
||||
const { email, token: mailToken } = await createTempEmail();
|
||||
|
||||
const surname = generateLastName();
|
||||
|
||||
Reference in New Issue
Block a user