ci / api / api (push) Successful in 55s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m6s
ci / db / db (push) Successful in 52s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m38s
release / android (APK в релиз) (push) Successful in 3m50s
ci / ts / ts (packages + web) (push) Successful in 3m20s
release / release (версия и заметки) (push) Successful in 5s
release / desktop (Linux и Windows в релиз) (push) Successful in 44m45s
release / prune (старые файлы и прогоны) (push) Successful in 7s
43 lines
2.2 KiB
TypeScript
43 lines
2.2 KiB
TypeScript
import type { components } from '@pipu/api-client';
|
|
import { createI18n } from '@pipu/i18n';
|
|
import { cleanup, render, screen } from '@testing-library/react';
|
|
import { I18nextProvider } from 'react-i18next';
|
|
import { afterEach, expect, it } from 'vitest';
|
|
import { ScanLine } from './ScanStatus';
|
|
|
|
afterEach(cleanup);
|
|
const scan: components['schemas']['ScanProgress'] = {
|
|
running: true, full: false, started_at: '2026-10-22T12:00:00Z', finished_at: null,
|
|
found: 12, to_process: 0, processed: 0, added: 0, updated: 0, moved: 0, missing: 0, errors: 0, error: null,
|
|
phase: 'walking', walked_dirs: 4, current_dir: 'Artist/Album',
|
|
};
|
|
|
|
async function fixture(overrides: Partial<typeof scan> = {}) {
|
|
const i18n = await createI18n('ru');
|
|
render(<I18nextProvider i18n={i18n}><ScanLine scan={{ ...scan, ...overrides }} lastScanAt={null} /></I18nextProvider>);
|
|
}
|
|
|
|
it('shows changing folder and file counts during the walk without a misleading percentage', async () => {
|
|
await fixture();
|
|
expect(screen.getByText(/Проверено папок: 4 · найдено аудиофайлов: 12/)).toBeVisible();
|
|
expect(screen.getByText('Текущая папка: Artist/Album')).toBeVisible();
|
|
expect(screen.getByRole('progressbar')).not.toHaveAttribute('aria-valuenow');
|
|
});
|
|
|
|
it('shows a percentage only once file processing has a known total', async () => {
|
|
await fixture({ phase: 'processing', to_process: 12, processed: 3 });
|
|
expect(screen.getByRole('progressbar')).toHaveAttribute('aria-valuenow', '25');
|
|
expect(screen.queryByText(/Текущая папка/)).not.toBeInTheDocument();
|
|
});
|
|
|
|
it.each([['preparing', 'Сопоставление файлов с библиотекой…'], ['finalizing', 'Завершение сканирования…']] as const)('labels the %s stage', async (phase, label) => {
|
|
await fixture({ phase });
|
|
expect(screen.getByText(label)).toBeVisible();
|
|
expect(screen.getByRole('progressbar')).not.toHaveAttribute('aria-valuenow');
|
|
});
|
|
|
|
it('supports servers without the new progress fields', async () => {
|
|
await fixture({ phase: undefined, walked_dirs: undefined, current_dir: undefined, found: 0 });
|
|
expect(screen.getByText('Обход папок…')).toBeVisible();
|
|
});
|