Compare commits

...
9 changed files with 5115 additions and 1044 deletions
+5020 -1023
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -20,6 +20,8 @@ const summary = hack.summary || hack.notability || 'No summary has been added ye
data-base={hack.base ?? 'Unknown'} data-base={hack.base ?? 'Unknown'}
data-status={hack.status ?? 'Unknown'} data-status={hack.status ?? 'Unknown'}
data-types={hack.types.join('|')} data-types={hack.types.join('|')}
data-fakemon={hack.fakemon ?? 'Unknown'}
data-generations={hack.generations.join('|')}
data-release={hack.releaseDate ?? ''} data-release={hack.releaseDate ?? ''}
data-search={hack.searchText} data-search={hack.searchText}
style={`--accent: var(--type-${accent.toLowerCase().replaceAll(' ', '-')}, var(--type-unknown));`} style={`--accent: var(--type-${accent.toLowerCase().replaceAll(' ', '-')}, var(--type-unknown));`}
+1
View File
@@ -171,6 +171,7 @@
"mystery-dungeon-explorers-of-skies": "/assets/banners/mystery-dungeon-explorers-of-skies.jpg", "mystery-dungeon-explorers-of-skies": "/assets/banners/mystery-dungeon-explorers-of-skies.jpg",
"mystery-dungeon-wigglytuff-s-bizarre-adventure": "/assets/banners/mystery-dungeon-wigglytuff-s-bizarre-adventure.png", "mystery-dungeon-wigglytuff-s-bizarre-adventure": "/assets/banners/mystery-dungeon-wigglytuff-s-bizarre-adventure.png",
"mystery-mail-blooming-chaos": "/assets/banners/mystery-mail-blooming-chaos.png", "mystery-mail-blooming-chaos": "/assets/banners/mystery-mail-blooming-chaos.png",
"myth-2": "/assets/banners/myth-2.png",
"myth": "/assets/banners/myth.png", "myth": "/assets/banners/myth.png",
"mythic-silver": "/assets/banners/mythic-silver.webp", "mythic-silver": "/assets/banners/mythic-silver.webp",
"nameless": "/assets/banners/nameless.png", "nameless": "/assets/banners/nameless.png",
+27
View File
@@ -29,6 +29,8 @@ const baseCatalog: RawCatalog = {
base: 'FireRed', base: 'FireRed',
status: 'Complete', status: 'Complete',
version: '4.1', version: '4.1',
generations: ['Gen I', 'Gen II', 'Gen III', 'Gen IV', 'Gen V', 'Gen VI', 'Gen VII', 'Gen VIII', 'Gen IX'],
fakemon: 'No',
developer: 'Soupercell', developer: 'Soupercell',
release_date: '2024', release_date: '2024',
banner: 'https://romhacks-files.ginnoir.com/_meta/radical/banner.jpg', banner: 'https://romhacks-files.ginnoir.com/_meta/radical/banner.jpg',
@@ -104,6 +106,31 @@ describe('catalog normalization', () => {
expect(unknown?.searchText).not.toMatch(/\bnull\b|—/i); expect(unknown?.searchText).not.toMatch(/\bnull\b|—/i);
}); });
it('normalizes roster generations and Fakemon metadata into chips', () => {
const catalog = normalizeCatalog(baseCatalog);
const radical = catalog.hacks.find((hack) => hack.slug === 'radical-red');
expect(radical?.generations).toEqual([
'Gen I',
'Gen II',
'Gen III',
'Gen IV',
'Gen V',
'Gen VI',
'Gen VII',
'Gen VIII',
'Gen IX',
]);
expect(radical?.fakemon).toBe('No');
expect(radical?.chips).toEqual(
expect.arrayContaining([
{ label: 'Roster', value: 'Gen I, Gen II, Gen III, Gen IV, Gen V, Gen VI, Gen VII, Gen VIII, Gen IX', kind: 'generation' },
{ label: 'Fakemon', value: 'No', kind: 'fakemon' },
]),
);
expect(radical?.searchText).toContain('gen ix');
});
it('maps ROM and library paths to internal file-server links', () => { it('maps ROM and library paths to internal file-server links', () => {
const catalog = normalizeCatalog(baseCatalog); const catalog = normalizeCatalog(baseCatalog);
const radical = catalog.hacks.find((hack) => hack.slug === 'radical-red'); const radical = catalog.hacks.find((hack) => hack.slug === 'radical-red');
+8
View File
@@ -56,6 +56,8 @@ export function normalizeHack(raw: RawHack): SiteHack {
const developer = cleanText(raw.developer); const developer = cleanText(raw.developer);
const releaseDate = cleanText(raw.release_date); const releaseDate = cleanText(raw.release_date);
const generation = cleanText(raw.generation); const generation = cleanText(raw.generation);
const generations = cleanList(raw.generations);
const fakemon = cleanText(raw.fakemon);
const scrapeDir = cleanText(raw.scrape_dir); const scrapeDir = cleanText(raw.scrape_dir);
const libraryPath = cleanText(raw.library_path); const libraryPath = cleanText(raw.library_path);
const banner = cleanText(raw.banner); const banner = cleanText(raw.banner);
@@ -74,6 +76,8 @@ export function normalizeHack(raw: RawHack): SiteHack {
version, version,
status, status,
generation, generation,
generations,
fakemon,
developer, developer,
releaseDate, releaseDate,
banner, banner,
@@ -106,10 +110,12 @@ export function normalizeHack(raw: RawHack): SiteHack {
hack.version, hack.version,
hack.developer, hack.developer,
hack.releaseDate, hack.releaseDate,
hack.fakemon,
hack.summary, hack.summary,
hack.notability, hack.notability,
hack.story, hack.story,
...hack.types, ...hack.types,
...hack.generations,
...hack.features, ...hack.features,
] ]
.filter(Boolean) .filter(Boolean)
@@ -216,6 +222,8 @@ function buildChips(hack: SiteHack): HackChip[] {
addChip(chips, 'status', 'Status', hack.status); addChip(chips, 'status', 'Status', hack.status);
addChip(chips, 'developer', 'Dev', hack.developer); addChip(chips, 'developer', 'Dev', hack.developer);
addChip(chips, 'release_date', 'Release', hack.releaseDate); addChip(chips, 'release_date', 'Release', hack.releaseDate);
addChip(chips, 'generation', 'Roster', hack.generations.join(', '));
addChip(chips, 'fakemon', 'Fakemon', hack.fakemon);
for (const type of hack.types) { for (const type of hack.types) {
addChip(chips, 'type', 'Type', type); addChip(chips, 'type', 'Type', type);
} }
+21
View File
@@ -67,6 +67,27 @@ export function getHacksForFacet(facet: FacetName, value: string, sort: SortKey
return sortHacks(matches, sort); return sortHacks(matches, sort);
} }
export function getFakemonEntries(): [string, number][] {
const counts: Record<string, number> = {};
for (const hack of catalog.hacks) {
const value = hack.fakemon ?? 'Unknown';
counts[value] = (counts[value] ?? 0) + 1;
}
return Object.entries(counts)
.filter(([value]) => value !== 'Unknown')
.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
}
export function getGenerationEntries(): [string, number][] {
const counts: Record<string, number> = {};
for (const hack of catalog.hacks) {
for (const gen of hack.generations) {
counts[gen] = (counts[gen] ?? 0) + 1;
}
}
return Object.entries(counts).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
}
export function displayValue(value?: string): string { export function displayValue(value?: string): string {
return value || 'Unknown'; return value || 'Unknown';
} }
+5 -1
View File
@@ -20,6 +20,8 @@ export interface RawHack {
version?: string | null; version?: string | null;
status?: string | null; status?: string | null;
generation?: string | null; generation?: string | null;
generations?: string[] | null;
fakemon?: string | null;
developer?: string | null; developer?: string | null;
release_date?: string | null; release_date?: string | null;
banner?: string | null; banner?: string | null;
@@ -46,7 +48,7 @@ export interface ExternalLink {
export interface HackChip { export interface HackChip {
label: string; label: string;
value: string; value: string;
kind: 'platform' | 'base' | 'version' | 'status' | 'developer' | 'release_date' | 'type'; kind: 'platform' | 'base' | 'version' | 'status' | 'developer' | 'release_date' | 'generation' | 'fakemon' | 'type';
} }
export interface FileLink { export interface FileLink {
@@ -64,6 +66,8 @@ export interface SiteHack {
version?: string; version?: string;
status?: string; status?: string;
generation?: string; generation?: string;
generations: string[];
fakemon?: string;
developer?: string; developer?: string;
releaseDate?: string; releaseDate?: string;
banner?: string; banner?: string;
+10 -1
View File
@@ -2,13 +2,15 @@
import HackCard from '../components/HackCard.astro'; import HackCard from '../components/HackCard.astro';
import FilterGroup from '../components/FilterGroup.astro'; import FilterGroup from '../components/FilterGroup.astro';
import Layout from '../components/Layout.astro'; import Layout from '../components/Layout.astro';
import { catalog, facetValueSlug, flagshipHacks, getFacetEntries, hacks } from '../lib/site-data'; import { catalog, facetValueSlug, flagshipHacks, getFacetEntries, getFakemonEntries, getGenerationEntries, hacks } from '../lib/site-data';
import type { FacetName } from '../lib/types'; import type { FacetName } from '../lib/types';
const platforms = getFacetEntries('platform'); const platforms = getFacetEntries('platform');
const bases = getFacetEntries('base').slice(0, 12); const bases = getFacetEntries('base').slice(0, 12);
const types = getFacetEntries('type'); const types = getFacetEntries('type');
const statuses = getFacetEntries('status'); const statuses = getFacetEntries('status');
const fakemonEntries = getFakemonEntries();
const generationEntries = getGenerationEntries();
type StatItem = { type StatItem = {
label: string; label: string;
@@ -149,6 +151,8 @@ const browseGroups: BrowseGroup[] = [
<FilterGroup title="Base" name="base" entries={bases} /> <FilterGroup title="Base" name="base" entries={bases} />
<FilterGroup title="Type" name="type" entries={types} /> <FilterGroup title="Type" name="type" entries={types} />
<FilterGroup title="Status" name="status" entries={statuses} /> <FilterGroup title="Status" name="status" entries={statuses} />
<FilterGroup title="Fakemon" name="fakemon" entries={fakemonEntries} />
<FilterGroup title="Generation" name="generation" entries={generationEntries} />
</aside> </aside>
<div class="catalog-results"> <div class="catalog-results">
@@ -184,12 +188,17 @@ const browseGroups: BrowseGroup[] = [
const base = selected('base'); const base = selected('base');
const type = selected('type'); const type = selected('type');
const status = selected('status'); const status = selected('status');
const fakemon = selected('fakemon');
const generation = selected('generation');
const cardTypes = card.dataset.types ? card.dataset.types.split('|') : []; const cardTypes = card.dataset.types ? card.dataset.types.split('|') : [];
const cardGens = card.dataset.generations ? card.dataset.generations.split('|') : [];
if (query && !card.dataset.search.includes(query)) return false; if (query && !card.dataset.search.includes(query)) return false;
if (platform.length && !platform.includes(card.dataset.platform)) return false; if (platform.length && !platform.includes(card.dataset.platform)) return false;
if (base.length && !base.includes(card.dataset.base)) return false; if (base.length && !base.includes(card.dataset.base)) return false;
if (status.length && !status.includes(card.dataset.status)) return false; if (status.length && !status.includes(card.dataset.status)) return false;
if (type.length && !type.some((value) => cardTypes.includes(value))) return false; if (type.length && !type.some((value) => cardTypes.includes(value))) return false;
if (fakemon.length && !fakemon.includes(card.dataset.fakemon)) return false;
if (generation.length && !generation.some((value) => cardGens.includes(value))) return false;
return true; return true;
} }
+21 -19
View File
@@ -11,23 +11,23 @@ test('homepage presents balanced navigation and facet summaries', async ({ page
await expect(primaryNav.getByRole('link', { name: 'Difficulty' })).toHaveCount(0); await expect(primaryNav.getByRole('link', { name: 'Difficulty' })).toHaveCount(0);
const heroStats = page.locator('.hero-stats'); const heroStats = page.locator('.hero-stats');
await expect(heroStats).toContainText('368'); await expect(heroStats).toContainText('396');
await expect(heroStats).toContainText('hacks'); await expect(heroStats).toContainText('hacks');
await expect(heroStats).toContainText('Platforms'); await expect(heroStats).toContainText('Platforms');
await expect(heroStats).toContainText('GBA 188'); await expect(heroStats).toContainText('GBA 197');
await expect(heroStats).toContainText('NDS 47'); await expect(heroStats).toContainText('NDS 47');
await expect(heroStats).toContainText('PC 40'); await expect(heroStats).toContainText('PC 66');
await expect(heroStats).toContainText('GBC 22'); await expect(heroStats).toContainText('GBC 36');
await expect(heroStats).toContainText('Types'); await expect(heroStats).toContainText('Types');
await expect(heroStats).toContainText('Expansion 143'); await expect(heroStats).toContainText('Expansion 144');
await expect(heroStats).toContainText('New Experience 129'); await expect(heroStats).toContainText('New Experience 156');
await expect(heroStats).toContainText('Difficulty 105'); await expect(heroStats).toContainText('Difficulty 108');
await expect(heroStats).toContainText('QoL 50'); await expect(heroStats).toContainText('QoL 54');
await expect(heroStats).toContainText('Status'); await expect(heroStats).toContainText('Status');
await expect(heroStats).toContainText('Complete 168'); await expect(heroStats).toContainText('Complete 196');
await expect(heroStats).toContainText('Ongoing 28'); await expect(heroStats).toContainText('Ongoing 34');
await expect(heroStats).toContainText('Beta 10'); await expect(heroStats).toContainText('Beta 12');
await expect(heroStats).toContainText('Unclassified 161'); await expect(heroStats).toContainText('Unclassified 153');
}); });
test('homepage stat cards are polished and responsive', async ({ page }) => { test('homepage stat cards are polished and responsive', async ({ page }) => {
@@ -72,12 +72,12 @@ test('homepage browse summary links to grouped facet pages', async ({ page }) =>
const browse = page.getByRole('region', { name: 'Browse by catalog facets' }); const browse = page.getByRole('region', { name: 'Browse by catalog facets' });
await expect(browse.getByRole('heading', { name: 'Browse the archive' })).toBeVisible(); await expect(browse.getByRole('heading', { name: 'Browse the archive' })).toBeVisible();
await expect(browse.getByRole('link', { name: /GBA\s+188/ })).toHaveAttribute('href', '/browse/platform/gba/'); await expect(browse.getByRole('link', { name: /GBA\s+197/ })).toHaveAttribute('href', '/browse/platform/gba/');
await expect(browse.getByRole('link', { name: /Difficulty\s+105/ })).toHaveAttribute( await expect(browse.getByRole('link', { name: /Difficulty\s+108/ })).toHaveAttribute(
'href', 'href',
'/browse/type/difficulty/', '/browse/type/difficulty/',
); );
await expect(browse.getByRole('link', { name: /Complete\s+168/ })).toHaveAttribute( await expect(browse.getByRole('link', { name: /Complete\s+196/ })).toHaveAttribute(
'href', 'href',
'/browse/status/complete/', '/browse/status/complete/',
); );
@@ -89,7 +89,7 @@ test('catalog search and filters update visible card count', async ({ page }) =>
await expect(page).toHaveTitle(/ROM Hack Archive/); await expect(page).toHaveTitle(/ROM Hack Archive/);
await expect(page.getByRole('heading', { name: 'ROM Hack Archive' })).toBeVisible(); await expect(page.getByRole('heading', { name: 'ROM Hack Archive' })).toBeVisible();
const catalogCards = page.locator('[data-card-grid] [data-card]:visible'); const catalogCards = page.locator('[data-card-grid] [data-card]:visible');
await expect(catalogCards).toHaveCount(368); await expect(catalogCards).toHaveCount(396);
await page.getByPlaceholder('Search hacks').fill('Radical Red'); await page.getByPlaceholder('Search hacks').fill('Radical Red');
await expect(catalogCards).toHaveCount(4); await expect(catalogCards).toHaveCount(4);
@@ -97,7 +97,7 @@ test('catalog search and filters update visible card count', async ({ page }) =>
await page.getByPlaceholder('Search hacks').fill(''); await page.getByPlaceholder('Search hacks').fill('');
await page.getByLabel('GBA').check(); await page.getByLabel('GBA').check();
await expect(catalogCards).toHaveCount(188); await expect(catalogCards).toHaveCount(197);
await page.getByLabel('Difficulty').check(); await page.getByLabel('Difficulty').check();
await expect(catalogCards.first()).toBeVisible(); await expect(catalogCards.first()).toBeVisible();
@@ -181,10 +181,12 @@ test('detail page renders metadata and private file links', async ({ page }) =>
await expect(page.getByRole('heading', { name: 'Pokémon Radical Red' })).toBeVisible(); await expect(page.getByRole('heading', { name: 'Pokémon Radical Red' })).toBeVisible();
await expect(page.getByText('Platform').first()).toBeVisible(); await expect(page.getByText('Platform').first()).toBeVisible();
await expect(page.getByText('Roster').first()).toBeVisible();
await expect(page.getByText('Fakemon').first()).toBeVisible();
await expect(page.getByRole('heading', { name: 'Files' })).toBeVisible(); await expect(page.getByRole('heading', { name: 'Files' })).toBeVisible();
await expect(page.getByRole('link', { name: 'ROM file' })).toHaveAttribute( await expect(page.getByRole('link', { name: 'ROM file' })).toHaveAttribute(
'href', 'href',
/https:\/\/romhacks-files\.ginnoir\.com\/_roms\/gba\/Hacks\//, /https:\/\/romhacks-files\.ginnoir\.com\/_roms\/gba\/Pokemon%20-%20Radical%20Red/,
); );
await expect(page.locator('body')).not.toContainText('undefined'); await expect(page.locator('body')).not.toContainText('undefined');
}); });
@@ -193,6 +195,6 @@ test('browse pages render static grouped lists', async ({ page }) => {
await page.goto('/browse/type/difficulty/'); await page.goto('/browse/type/difficulty/');
await expect(page.getByRole('heading', { name: 'Difficulty' })).toBeVisible(); await expect(page.getByRole('heading', { name: 'Difficulty' })).toBeVisible();
await expect(page.locator('[data-card]:visible')).toHaveCount(105); await expect(page.locator('[data-card]:visible')).toHaveCount(108);
await expect(page.getByRole('link', { name: /Open Pokémon Radical Red/ })).toBeVisible(); await expect(page.getByRole('link', { name: /Open Pokémon Radical Red/ })).toBeVisible();
}); });