Files
portal/app/tests/Frontend/motion-css.spec.ts
T
Дмитрий 245b76ec43 test(frontend): fix 17 ESLint errors + TwoFactorView router stub
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>
2026-05-12 20:23:51 +03:00

32 lines
1.4 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import fs from 'node:fs';
import path from 'node:path';
const cssPath = path.resolve(__dirname, '../../resources/css/motion.css');
const css = fs.existsSync(cssPath) ? fs.readFileSync(cssPath, 'utf-8') : '';
describe('motion.css', () => {
it.each(['ld-fadeup', 'ld-slideup', 'ld-shimmer', 'ld-pulse', 'ld-dialog-in'])('@keyframes %s defined', (name) => {
expect(css).toMatch(new RegExp(`@keyframes\\s+${name}\\s*{`));
});
it('prefers-reduced-motion wrapper disables animations', () => {
const block = css.match(/@media\s*\(\s*prefers-reduced-motion:\s*reduce\s*\)[^{]*{[\s\S]*?}\s*}/);
expect(block, 'prefers-reduced-motion @media block').not.toBeNull();
expect(block?.[0]).toMatch(/animation-duration:\s*0\.01ms\s*!important/);
expect(block?.[0]).toMatch(/transition-duration:\s*0\.01ms\s*!important/);
expect(block?.[0]).toMatch(/animation-iteration-count:\s*1\s*!important/);
});
it('defines .ld-hover-lift utility (motion #4)', () => {
expect(css).toMatch(/\.ld-hover-lift\s*{/);
expect(css).toMatch(/transform:\s*translateY\(-2px\)/);
});
it('defines .ld-stagger-row utility (motion #2) with nth-child delays', () => {
expect(css).toMatch(/\.ld-stagger-row\s*{/);
expect(css).toMatch(/animation:\s*ld-slideup/);
expect(css).toMatch(/\.ld-stagger-row:nth-child\(\d+\)/);
});
});