map finder: quick lists from my listening (top/recent/now/Spotify top/liked), Artist - Title without Spotify, owned playlists via the user token, rich beatmap cards (cover, mapper, status, BPM, length, star chips, preview, osu!direct), mode/status/star filters, DB result cache (music.osu_match_cache)
Some checks failed
Deploy production / deploy (push) Has been cancelled

This commit is contained in:
2026-10-24 16:15:56 +00:00
parent 0aa14cebf3
commit 46703f1a6c
21 changed files with 21050 additions and 178 deletions

View File

@@ -1,4 +1,4 @@
import { expect, it, vi } from 'vitest';
import { describe, expect, it, vi } from 'vitest';
vi.mock('$app/env/private', () => ({ OSU_CLIENT_ID: '1', OSU_CLIENT_SECRET: 'test' }));
import { getOsuMaps } from './osu';
it('falls back deliberately, merges IDs, reuses OAuth and caches matching results', async () => {
@@ -32,3 +32,31 @@ it('falls back deliberately, merges IDs, reuses OAuth and caches matching result
1
);
});
describe('parseBeatmapset', () => {
it('keeps the shown fields, fixes preview URLs and sorts difficulties', async () => {
const { parseBeatmapset } = await import('./osu');
const set = parseBeatmapset({
id: 7,
title: 'T',
artist: 'A',
creator: 'mapper',
status: 'ranked',
preview_url: '//b.ppy.sh/preview/7.mp3',
covers: { card: 'https://assets.ppy.sh/c.jpg', list: 'javascript:alert(1)' },
beatmaps: [
{ id: 2, mode: 'osu', difficulty_rating: 5.123, total_length: 90, version: 'Hard' },
{ id: 1, mode: 'osu', difficulty_rating: 2, total_length: 90, version: 'Easy' },
{ id: 3, mode: 'bogus' }
]
});
expect(set).toMatchObject({
id: 7,
creator: 'mapper',
preview_url: 'https://b.ppy.sh/preview/7.mp3'
});
expect(set?.covers?.list).toBeUndefined();
expect(set?.beatmaps?.map((d) => d.stars)).toEqual([2, 5.12]);
expect(parseBeatmapset({ id: 'x' })).toBeNull();
});
});