245b76ec43
ESLint emitted 17 errors in tests/Frontend/* (production code clean):
- 13× @typescript-eslint/no-explicit-any in axios mock casts
(BulkActionsBar, ProjectsView, projectsStore specs)
- 3× vitest/no-disabled-tests rule-not-found
(eslint-plugin-vitest not registered; inline-disable comments stale)
- 1× @typescript-eslint/no-unused-vars on imported beforeEach
Plus Phase 5 audit finding: TwoFactorView.spec.ts test router was
missing /recovery-use stub → Vue Router warn on every TwoFactorView mount.
Changes:
- BulkActionsBar.spec.ts, ProjectsView.spec.ts, projectsStore.spec.ts:
replace `as any` with `as unknown as ReturnType<typeof vi.fn>` on
axios method mocks; one case used `as unknown as { regionsOpen: bool }`
for vm shape.
- NewProjectDialog.spec.ts, ProjectsView.spec.ts: remove stale
`// eslint-disable-next-line vitest/no-disabled-tests` comments
(it.skip() lines kept).
- ProjectsView.toolbar.spec.ts: drop unused `beforeEach` from import.
- TwoFactorView.spec.ts: add `/recovery-use` route stub.
Verification:
- npx eslint --max-warnings=0 → exit 0 (was 17 errors).
- npx vitest run on affected specs → 24/27 passed + 3 skipped (was same).
- TwoFactorView spec → 3/3 passed, no Vue Router warn.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
79 lines
2.7 KiB
TypeScript
79 lines
2.7 KiB
TypeScript
import { describe, it, expect, vi } from 'vitest';
|
|
import { mount } from '@vue/test-utils';
|
|
import { createPinia, setActivePinia } from 'pinia';
|
|
import { createVuetify } from 'vuetify';
|
|
import axios from 'axios';
|
|
import ProjectsView from '../../resources/js/views/ProjectsView.vue';
|
|
|
|
vi.mock('axios');
|
|
|
|
const mountView = async () => {
|
|
setActivePinia(createPinia());
|
|
vi.mocked(axios.get).mockResolvedValue({
|
|
data: {
|
|
data: [
|
|
{
|
|
id: 1,
|
|
name: 'A',
|
|
signal_type: 'site',
|
|
signal_identifier: 'a.ru',
|
|
daily_limit_target: 100,
|
|
delivered_today: 0,
|
|
is_active: true,
|
|
archived_at: null,
|
|
region_mask: 1,
|
|
region_mode: 'include',
|
|
delivery_days_mask: 31,
|
|
sync_status: 'ok',
|
|
},
|
|
{
|
|
id: 2,
|
|
name: 'B',
|
|
signal_type: 'site',
|
|
signal_identifier: 'b.ru',
|
|
daily_limit_target: 100,
|
|
delivered_today: 0,
|
|
is_active: true,
|
|
archived_at: null,
|
|
region_mask: 1,
|
|
region_mode: 'include',
|
|
delivery_days_mask: 31,
|
|
sync_status: 'ok',
|
|
},
|
|
],
|
|
meta: { total: 2 },
|
|
},
|
|
});
|
|
const wrapper = mount(ProjectsView, {
|
|
global: {
|
|
plugins: [createVuetify()],
|
|
stubs: { ProjectCard: true, BulkActionsBar: true, NewProjectDialog: true, EditProjectDialog: true },
|
|
},
|
|
});
|
|
await new Promise((r) => setTimeout(r, 50)); // flush async fetch
|
|
return wrapper;
|
|
};
|
|
|
|
describe('ProjectsView toolbar — select all', () => {
|
|
it('renders select-all checkbox above grid', async () => {
|
|
const wrapper = await mountView();
|
|
expect(wrapper.find('[data-testid="select-all-toggle"]').exists()).toBe(true);
|
|
});
|
|
|
|
it('shows count "Выбрано: N из M"', async () => {
|
|
const wrapper = await mountView();
|
|
expect(wrapper.text()).toMatch(/Выбрано:\s*0\s*из\s*2/);
|
|
});
|
|
|
|
it('clicking select-all marks all visible projects', async () => {
|
|
const wrapper = await mountView();
|
|
const toggle = wrapper.find('[data-testid="select-all-toggle"] input');
|
|
await toggle.setValue(true);
|
|
|
|
const { useProjectsStore } = await import('../../resources/js/stores/projectsStore');
|
|
const store = useProjectsStore();
|
|
expect(store.selectAllByFilter).toBe(true);
|
|
expect(store.selectedIds.size).toBe(2);
|
|
});
|
|
});
|