test(auth): A5 — regression generic fallback ForgotPassword (Sprint 5A)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { createPinia, setActivePinia } from 'pinia';
|
||||
import { createVuetify } from 'vuetify';
|
||||
import { createRouter, createMemoryHistory } from 'vue-router';
|
||||
@@ -95,4 +95,18 @@ describe('ForgotPasswordView.vue', () => {
|
||||
expect(alert.exists()).toBe(true);
|
||||
expect(alert.text()).toContain('10 мин');
|
||||
});
|
||||
|
||||
it('A5: при не-валидационной ошибке (500/network) показывает generic fallback', async () => {
|
||||
// forgotPassword отклоняется обычной ошибкой; extractValidationErrors и
|
||||
// extractRateLimitRetry замоканы → null (см. vi.mock в шапке файла).
|
||||
vi.mocked(authApi.forgotPassword).mockRejectedValue(new Error('Network Error'));
|
||||
|
||||
const wrapper = await mountForgot();
|
||||
await wrapper.find('input[type="email"]').setValue('user@example.ru');
|
||||
await wrapper.find('form').trigger('submit.prevent');
|
||||
await flushPromises();
|
||||
|
||||
const messages = wrapper.findAll('.v-messages__message').map((m) => m.text());
|
||||
expect(messages.join(' ')).toContain('Произошла ошибка. Попробуйте позже.');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user