3bbd7787d8
- Remove archived_at from Project interface; rename store.archive → store.del
- BulkActionsBar: archive button → delete (testid, icon, confirm text)
- ProjectCard: archive menu item → delete (emit + icon)
- ProjectDetailsDrawer: confirm text + store.del call
- ProjectsView: @delete binding, remove 'Архивные' status filter entry
- vuetify.ts: add mdi-delete → Trash2 mapping
- All specs/stories updated: archived_at removed, archive → del renamed
- New test: del() calls DELETE /api/projects/{id}
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
74 lines
2.5 KiB
TypeScript
74 lines
2.5 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
import { mount, flushPromises } from '@vue/test-utils';
|
|
import { createPinia, setActivePinia } from 'pinia';
|
|
import { createVuetify } from 'vuetify';
|
|
|
|
vi.mock('../../resources/js/api/client', () => ({
|
|
apiClient: {
|
|
post: vi.fn().mockResolvedValue({ data: {} }),
|
|
patch: vi.fn().mockResolvedValue({ data: {} }),
|
|
},
|
|
ensureCsrfCookie: vi.fn().mockResolvedValue(undefined),
|
|
extractErrorMessage: vi.fn(() => 'Произошла ошибка.'),
|
|
}));
|
|
|
|
import { apiClient } from '../../resources/js/api/client';
|
|
import EditProjectDialog from '../../resources/js/views/projects/EditProjectDialog.vue';
|
|
|
|
const sampleProject = {
|
|
id: 1,
|
|
name: 'X',
|
|
signal_type: 'site' as const,
|
|
signal_identifier: 'x.ru',
|
|
daily_limit_target: 10,
|
|
delivered_today: 0,
|
|
is_active: true,
|
|
sync_status: 'ok' as const,
|
|
region_mask: 0,
|
|
region_mode: 'include',
|
|
delivery_days_mask: 127,
|
|
};
|
|
|
|
// VDialog в JSDOM не рендерит через teleport — стаб делает <slot/> доступным
|
|
// для wrapper.text() / find(). Паттерн из NewProjectDialog.spec.ts.
|
|
const factory = (props: { modelValue: boolean; project: typeof sampleProject }) =>
|
|
mount(EditProjectDialog, {
|
|
props,
|
|
global: {
|
|
plugins: [createVuetify()],
|
|
stubs: {
|
|
VDialog: {
|
|
template: '<div class="dialog-stub" v-if="modelValue"><slot /></div>',
|
|
props: ['modelValue'],
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
beforeEach(() => {
|
|
setActivePinia(createPinia());
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
describe('EditProjectDialog', () => {
|
|
it('prefills form from project prop', async () => {
|
|
const wrapper = factory({ modelValue: true, project: sampleProject });
|
|
await flushPromises();
|
|
expect(wrapper.text()).toContain('Редактирование');
|
|
});
|
|
|
|
it('PATCH on submit', async () => {
|
|
const wrapper = factory({ modelValue: true, project: sampleProject });
|
|
await flushPromises();
|
|
await wrapper.find('[data-testid="submit-btn"]').trigger('click');
|
|
await flushPromises();
|
|
expect(apiClient.patch).toHaveBeenCalled();
|
|
});
|
|
|
|
it('signal_type tabs disabled in edit mode', async () => {
|
|
const wrapper = factory({ modelValue: true, project: sampleProject });
|
|
await flushPromises();
|
|
expect(wrapper.findComponent({ name: 'VTabs' }).props('disabled')).toBe(true);
|
|
});
|
|
});
|