84530d55bf
Pre-existing failing test from commit c9ee8d8 — data-testid lives on
<label>, but @change handler sits on <input> inside it. jsdom does not
bubble change-event from label to input via @vue/test-utils trigger.
Use child-input selector to fire the event on the right node.
Baseline после fix: 614 passed / 3 skipped / 0 failed (vs 613 / 3 / 1).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { mount } from '@vue/test-utils';
|
|
import { createVuetify } from 'vuetify';
|
|
import ProjectCard from '../../resources/js/components/projects/ProjectCard.vue';
|
|
|
|
const vuetify = createVuetify();
|
|
const baseProject = {
|
|
id: 1,
|
|
name: 'Окна СПб',
|
|
signal_type: 'site' as const,
|
|
signal_identifier: 'okna.ru',
|
|
daily_limit_target: 50,
|
|
delivered_today: 32,
|
|
is_active: true,
|
|
archived_at: null,
|
|
sync_status: 'ok' as const,
|
|
};
|
|
|
|
describe('ProjectCard', () => {
|
|
it('renders project name + signal_identifier', () => {
|
|
const wrapper = mount(ProjectCard, {
|
|
global: { plugins: [vuetify] },
|
|
props: { project: baseProject, selected: false },
|
|
});
|
|
expect(wrapper.text()).toContain('Окна СПб');
|
|
expect(wrapper.text()).toContain('okna.ru');
|
|
});
|
|
|
|
it('shows progress percentage 32/50', () => {
|
|
const wrapper = mount(ProjectCard, {
|
|
global: { plugins: [vuetify] },
|
|
props: { project: baseProject, selected: false },
|
|
});
|
|
expect(wrapper.text()).toMatch(/32.*50/);
|
|
});
|
|
|
|
it('emits select event on checkbox change', async () => {
|
|
const wrapper = mount(ProjectCard, {
|
|
global: { plugins: [vuetify] },
|
|
props: { project: baseProject, selected: false },
|
|
});
|
|
await wrapper.find('[data-testid="card-select"] input').trigger('change');
|
|
expect(wrapper.emitted('toggle-select')).toBeTruthy();
|
|
});
|
|
|
|
it('shows "На паузе" when is_active=false', () => {
|
|
const wrapper = mount(ProjectCard, {
|
|
global: { plugins: [vuetify] },
|
|
props: { project: { ...baseProject, is_active: false }, selected: false },
|
|
});
|
|
expect(wrapper.text()).toContain('На паузе');
|
|
});
|
|
});
|