Écrans : accueil, bibliothèque (grille virtualisée, filtres, tri, recherche), collections, fiche jeu, ajout manuel, choix des jaquettes
Some checks are pending
CI / windows (push) Waiting to run
Some checks are pending
CI / windows (push) Waiting to run
This commit is contained in:
parent
baa9f7391c
commit
1cfe89d1fd
43 changed files with 1890 additions and 45 deletions
24
tests/library-ui.test.ts
Normal file
24
tests/library-ui.test.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { describe, expect, it } from 'vitest'
|
||||
import { filterGames } from '../src/renderer/src/screens/filter'
|
||||
import type { Game } from '../src/shared/types'
|
||||
|
||||
const g = (name: string, o: Partial<Game> = {}): Game => ({ id: name, platform: 'steam', platformId: name, name, installed: true, favorite: false, hidden: false, addedAt: 0, playtime: 0, collections: [], media: {}, ...o })
|
||||
const games = [g('The Witcher 3: Wild Hunt', { platform: 'gog', playtime: 50 }), g('Hades', { favorite: true, lastPlayed: 10, addedAt: 5 }), g('Pokémon Légendes', { installed: false, playtime: 90 }), g('Celeste', { lastPlayed: 20 })]
|
||||
const names = (o: Parameters<typeof filterGames>[1]) => filterGames(games, o).map((x) => x.name)
|
||||
|
||||
describe('filtres de la bibliothèque', () => {
|
||||
it('cherche par mots, sans accents ni casse', () => {
|
||||
expect(names({ filter: 'all', sort: 'name', query: 'witcher 3' })).toEqual(['The Witcher 3: Wild Hunt'])
|
||||
expect(names({ filter: 'all', sort: 'name', query: 'pokemon legendes' })).toEqual(['Pokémon Légendes'])
|
||||
})
|
||||
it('filtre installés, favoris, plateforme', () => {
|
||||
expect(names({ filter: 'installed', sort: 'name', query: '' })).not.toContain('Pokémon Légendes')
|
||||
expect(names({ filter: 'favorites', sort: 'name', query: '' })).toEqual(['Hades'])
|
||||
expect(names({ filter: 'gog', sort: 'name', query: '' })).toEqual(['The Witcher 3: Wild Hunt'])
|
||||
})
|
||||
it('trie', () => {
|
||||
expect(names({ filter: 'all', sort: 'name', query: '' })).toEqual(['Celeste', 'Hades', 'Pokémon Légendes', 'The Witcher 3: Wild Hunt'])
|
||||
expect(names({ filter: 'all', sort: 'playtime', query: '' })[0]).toBe('Pokémon Légendes')
|
||||
expect(names({ filter: 'all', sort: 'recent', query: '' }).slice(0, 2)).toEqual(['Celeste', 'Hades'])
|
||||
})
|
||||
})
|
||||
30
tests/match.test.ts
Normal file
30
tests/match.test.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { describe, expect, it } from 'vitest'
|
||||
import { findGameProcs } from '../src/main/launch/match'
|
||||
import { splitArgs } from '../src/main/launch/session'
|
||||
|
||||
const procs = [
|
||||
{ pid: 1, path: 'C:\\Program Files (x86)\\Steam\\steam.exe' },
|
||||
{ pid: 2, path: 'D:\\SteamLibrary\\steamapps\\common\\Hollow Knight\\hollow_knight.exe' },
|
||||
{ pid: 3, path: 'D:\\SteamLibrary\\steamapps\\common\\Hollow Knight\\UnityCrashHandler64.exe' },
|
||||
{ pid: 4, path: 'D:\\SteamLibrary\\steamapps\\common\\Hollow Knight 2\\hk2.exe' }
|
||||
]
|
||||
|
||||
describe('processus du jeu', () => {
|
||||
it('trouve l’exe dans le dossier, sans les outils ni un dossier voisin', () => {
|
||||
expect(findGameProcs(procs, { installDir: 'D:\\SteamLibrary\\steamapps\\common\\Hollow Knight' }).map((p) => p.pid)).toEqual([2])
|
||||
expect(findGameProcs(procs, { installDir: 'd:/steamlibrary/steamapps/common/hollow knight/' }).map((p) => p.pid)).toEqual([2])
|
||||
})
|
||||
it("reconnaît l'exe exact même hors du dossier", () => {
|
||||
expect(findGameProcs(procs, { exe: 'C:\\Program Files (x86)\\Steam\\steam.exe' }).map((p) => p.pid)).toEqual([1])
|
||||
})
|
||||
it('ignore le launcher lui-même', () => {
|
||||
expect(findGameProcs(procs, { installDir: 'C:\\Program Files (x86)\\Steam', selfPid: 1 })).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('arguments', () => {
|
||||
it('respecte les guillemets', () => {
|
||||
expect(splitArgs('-windowed "C:\\Mon Dossier\\cfg.ini" -w 1920')).toEqual(['-windowed', 'C:\\Mon Dossier\\cfg.ini', '-w', '1920'])
|
||||
expect(splitArgs(undefined)).toEqual([])
|
||||
})
|
||||
})
|
||||
|
|
@ -97,3 +97,19 @@ describe('runScanners', () => {
|
|||
expect(r.ok.gog).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
import { mainExe } from '../src/main/scanners/folder'
|
||||
|
||||
describe('dossiers de jeux', () => {
|
||||
it("prend le plus gros exe qui n'est pas un outil", () => {
|
||||
const tree: Record<string, string[]> = {
|
||||
'D:\\Jeux\\Celeste': ['Celeste.exe', 'unins000.exe', 'Content'],
|
||||
'D:\\Jeux\\Celeste\\Content': ['Big.exe', 'Crash_Reporter.exe'],
|
||||
'D:\\Jeux\\Vide': ['readme.txt']
|
||||
}
|
||||
const env = { list: (d: string) => tree[d] ?? [] } as unknown as ScanEnv
|
||||
const sizes: Record<string, number> = { 'D:\\Jeux\\Celeste\\Celeste.exe': 50, 'D:\\Jeux\\Celeste\\unins000.exe': 900, 'D:\\Jeux\\Celeste\\Content\\Big.exe': 60, 'D:\\Jeux\\Celeste\\Content\\Crash_Reporter.exe': 999 }
|
||||
expect(mainExe(env, 'D:\\Jeux\\Celeste', (p) => sizes[p] ?? 0)).toBe('D:\\Jeux\\Celeste\\Content\\Big.exe')
|
||||
expect(mainExe(env, 'D:\\Jeux\\Vide', () => 0)).toBeNull()
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue