Files
portal/app/tests/Frontend/RegionsBulkDialog.spec.ts
T
Дмитрий 54451d2ea6 feat(projects): RegionsBulkDialog — subject-level regions (89 RF subjects) #1426
Bulk regions dialog reworked from federal-district bitmask to subject/region
selection, consistent with ProjectDetailsDrawer/NewProjectDialog. Full-stack:
add_regions/remove_regions on projects.regions INT[], BulkProjectActionRequest
split validation, ProjectService model-instance update. federal-districts.ts
removed (zero consumers). +menuRepositionFix util for v-autocomplete menu.
phpstan-baseline: bump actingAs ignore count 14->15 (new validation test).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 03:41:46 +03:00

59 lines
2.1 KiB
TypeScript

import { describe, it, expect, beforeEach } from 'vitest';
import { mount } from '@vue/test-utils';
import { createVuetify } from 'vuetify';
import { createPinia, setActivePinia } from 'pinia';
import RegionsBulkDialog from '../../resources/js/components/projects/RegionsBulkDialog.vue';
const vuetify = createVuetify();
const mountDialog = (count = 5) =>
mount(RegionsBulkDialog, {
props: { modelValue: true, count },
global: {
plugins: [vuetify, createPinia()],
stubs: { VDialog: { template: '<div><slot /></div>' } },
},
});
interface DialogVm {
addRegions: number[];
removeRegions: number[];
}
describe('RegionsBulkDialog', () => {
beforeEach(() => setActivePinia(createPinia()));
it('renders subject-level Add and Remove selectors (not federal districts)', () => {
const wrapper = mountDialog();
expect(wrapper.find('[data-testid="region-add-select"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="region-remove-select"]').exists()).toBe(true);
});
it('shows count from prop', () => {
const wrapper = mountDialog(7);
expect(wrapper.text()).toContain('7');
});
it('emits apply with selected subject codes', async () => {
const wrapper = mountDialog();
(wrapper.vm as unknown as DialogVm).addRegions = [82, 83];
(wrapper.vm as unknown as DialogVm).removeRegions = [56];
await wrapper.vm.$nextTick();
await wrapper.find('[data-testid="apply"]').trigger('click');
expect(wrapper.emitted('apply')?.[0]).toEqual([{ add_regions: [82, 83], remove_regions: [56] }]);
});
it('apply button disabled when nothing selected', () => {
const wrapper = mountDialog();
expect(wrapper.find('[data-testid="apply"]').attributes('disabled')).toBeDefined();
});
it('apply button enabled once a subject is picked', async () => {
const wrapper = mountDialog();
(wrapper.vm as unknown as DialogVm).addRegions = [82];
await wrapper.vm.$nextTick();
expect(wrapper.find('[data-testid="apply"]').attributes('disabled')).toBeUndefined();
});
});