fix(web): treat AIFF and WavPack as lossless in the upload format hint
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m30s
ci / ts / ts (packages + web) (push) Successful in 2m11s

The web check only accepted FLAC and WAV, so AIFF files were flagged
"needs attention" although the server already counts them as lossless.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mrleo1nidandClaude Opus 5.5 committed 2026-10-21 10:35:43 +03:00
1 parent dca7173a88
commit 4d2c6ce22f
6 files changed
+14 -10

No files matched your search

+2 -2
View File
@@ -316,10 +316,10 @@ describe('my wave', () => {
});
describe('suggest tracks', () => {
it('warns that FLAC and WAV are the formats to send', async () => {
it('warns that lossless formats are the ones to send', async () => {
const admin = makeUser('admin', 'admin');
await renderApp([admin], '/uploads/new', { signedInAs: admin });
expect(await screen.findByText(/Нужны FLAC или WAV/)).toBeInTheDocument();
expect(await screen.findByText(/Нужны FLAC, WAV или AIFF/)).toBeInTheDocument();
expect(screen.getByText(/MP3 — только в крайнем случае/)).toBeInTheDocument();
});
});
+4 -1
View File
@@ -3,10 +3,13 @@ import { describe, expect, it } from 'vitest';
import { needsFormatAttention } from './files';
describe('needsFormatAttention', () => {
it('marks everything except flac and wav', () => {
it('marks everything except lossless formats', () => {
expect(needsFormatAttention('flac', 'a.mp3')).toBe(false);
expect(needsFormatAttention('WAV', 'track.wav')).toBe(false);
expect(needsFormatAttention(null, 'Кино/01.wav')).toBe(false);
expect(needsFormatAttention('aiff', 'a.aif')).toBe(false);
expect(needsFormatAttention(null, 'track.AIFF')).toBe(false);
expect(needsFormatAttention(null, 'track.wv')).toBe(false);
expect(needsFormatAttention('mp3', 'a.flac')).toBe(true);
expect(needsFormatAttention(null, 'folder/song.MP3')).toBe(true);
expect(needsFormatAttention(null, 'song.m4a')).toBe(true);
+3 -2
View File
@@ -9,7 +9,8 @@ export interface PickedFile {
export const AUDIO_EXTENSIONS = ['flac', 'mp3', 'm4a', 'ogg', 'opus', 'wav', 'aiff', 'aif', 'wv'];
/** То, что просим присылать. MP3 и прочие — крайний случай, их помечает очередь. */
const PREFERRED_AUDIO = new Set(['flac', 'wav']);
// Lossless — как в quality.go на сервере.
const PREFERRED_AUDIO = new Set(['flac', 'wav', 'aiff', 'aif', 'wv']);
export function audioExt(name: string): string {
const base = name.split(/[/\\]/).pop() ?? name;
@@ -18,7 +19,7 @@ export function audioExt(name: string): string {
return base.slice(dot + 1).toLowerCase();
}
/** Не FLAC и не WAV: в очереди на добавление такой файл нужно выделить. */
/** Не lossless (FLAC, WAV, AIFF, WavPack): в очереди на добавление такой файл нужно выделить. */
export function needsFormatAttention(format: string | null | undefined, name: string): boolean {
const ext = (format || audioExt(name)).toLowerCase();
return ext !== '' && !PREFERRED_AUDIO.has(ext);