mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-09-14 17:42:17 +00:00
test: replace ad-hoc tests with a layered suite and CI workflow
Splits testing into five layers so a failure points at the responsible one: - tests/unit isolated utility, repository and service tests - tests/data validates the tracked Pokémon, game, region and dex files - tests/integration schema, views, constraints, RLS and repositories - tests/bdd executable Gherkin for user-visible behaviour - tests/build service worker and manifest artifacts per build variant Replaces the two Playwright specs in client-test/ and the two Vitest files in test/. Adds a GitHub Actions workflow running the layers as separate jobs, a mock OAuth provider server so the Drive and Dropbox scenarios never touch real accounts, and a wrapper that reads the local Supabase keys from `supabase status` rather than hard-coding them. Extracts the pure formatting helpers out of PokedexExportService so they can be unit tested, and makes the provider endpoints configurable so the mock server can stand in for Google and Dropbox.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
getRegionalDexColumnName,
|
||||
getRegionalDexFieldName,
|
||||
getRegionalDexKey,
|
||||
hasRegionalDex
|
||||
} from '../../src/lib/utils/regionalDexMapping';
|
||||
|
||||
describe('regional dex mapping', () => {
|
||||
it.each([
|
||||
['Red', 'kanto', 'kanto_dex_number', 'kantoDexNumber'],
|
||||
['Black2', 'unova_b2w2', 'unova_b2w2_dex_number', 'unovaB2w2DexNumber'],
|
||||
['UltraMoon', 'alola_usum', 'alola_usum_dex_number', 'alolaUsumDexNumber'],
|
||||
['Scarlet', 'paldea', 'paldea_dex_number', 'paldeaDexNumber']
|
||||
])('maps %s consistently', (game, key, column, field) => {
|
||||
expect(hasRegionalDex(game)).toBe(true);
|
||||
expect(getRegionalDexKey(game)).toBe(key);
|
||||
expect(getRegionalDexColumnName(game)).toBe(column);
|
||||
expect(getRegionalDexFieldName(game)).toBe(field);
|
||||
});
|
||||
|
||||
it('returns no mapping for unknown games', () => {
|
||||
expect(hasRegionalDex('Legends Z-A')).toBe(false);
|
||||
expect(getRegionalDexKey('Legends Z-A')).toBeUndefined();
|
||||
expect(getRegionalDexColumnName('Legends Z-A')).toBeUndefined();
|
||||
expect(getRegionalDexFieldName('Legends Z-A')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user