import {describe, expect, it} from 'vitest'; import {createBrowserPageCapture, createPluginTestHost, runGameSourceRefresh, runGameSourceResolve, runGameSourceSearch} from '@xlibrary/plugin-sdk/testing'; import plugin from '../src/index.js'; describe('My Game Catalog plugin', () => { it('returns a validated search candidate without starting XLibrary', async () => { const result = await runGameSourceSearch( plugin, {sourceId: 'catalog', query: 'example', limit: 20}, createPluginTestHost(), ); expect(result.candidates).toEqual([{ identity: { externalId: 'example-game', canonicalUrl: 'https://catalog.example/games/example-game', }, title: 'Example Game', }]); }); it('resolves a provider URL and parses a browser capture', async () => { const host = createPluginTestHost(); await expect(runGameSourceResolve(plugin, { sourceId: 'catalog', url: 'https://catalog.example/games/example-game', }, host)).resolves.toMatchObject({ externalId: 'example-game', name: 'Example Game (example-game)', }); await expect(runGameSourceResolve(plugin, { sourceId: 'catalog', url: 'https://catalog.example/games/example-game', page: createBrowserPageCapture({ url: 'https://catalog.example/games/example-game', title: 'Captured Game', text: 'Captured description', }), }, host)).resolves.toMatchObject({ externalId: 'example-game', name: 'Captured Game', description: 'Captured description', }); }); it('returns a patch through the standard refresh contract', async () => { const result = await runGameSourceRefresh(plugin, { sourceId: 'catalog', externalId: 'example-game', url: 'https://catalog.example/games/example-game', game: {id: 'local-1', name: 'Example Game', version: '0.9.0'}, }, createPluginTestHost()); expect(result).toMatchObject({ externalId: 'example-game', changedFields: ['description', 'version'], }); }); });