Some checks are pending
CI / validate (push) Waiting to run
Phase 2 des cards→wordeck Big-Bang-Rebrand:
- 4 package.json: @cards/* → @wordeck/*
- packages/cards-domain/ → packages/wordeck-domain/
- 41+12 Files: from '@cards/domain' → '@wordeck/domain'
- pgSchema('cards') → pgSchema('wordeck') (Drizzle-Schema)
- 17 Files: process.env.CARDS_* → process.env.WORDECK_*
- docker-compose Service-Names: cards-* → wordeck-*
- docker-compose Volume: /Volumes/ManaData/cards → wordeck
- env-vars in compose: CARDS_DB_PASSWORD/_API_VERSION/_DSGVO_SERVICE_KEY etc. → WORDECK_*
- Log-Prefixes + Error-Strings + manifest-id 'cards' → 'wordeck'
- CORS-Origin cardecky.mana.how → wordeck.com
- .env.production.example umbenannt + S3-Key entfernt (kein MinIO mehr)
Type-Check 0 Errors in api+domain+web, 51/51 Domain-Tests grün.
DB-Rename + Container/Volume-Rename auf mana-server folgen in nächstem
Commit nach Verzeichnis-Rename.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
49 lines
1.7 KiB
TypeScript
49 lines
1.7 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { cardContentHash } from '@wordeck/domain';
|
|
|
|
import { hashVersionCards } from '../src/lib/marketplace/version-hash.ts';
|
|
|
|
describe('hashVersionCards', () => {
|
|
const card1 = { type: 'basic', fields: { front: 'Q1', back: 'A1' }, ord: 0 };
|
|
const card2 = { type: 'basic', fields: { front: 'Q2', back: 'A2' }, ord: 1 };
|
|
|
|
it('is deterministic', async () => {
|
|
const a = await hashVersionCards([card1, card2]);
|
|
const b = await hashVersionCards([card1, card2]);
|
|
expect(a).toBe(b);
|
|
});
|
|
|
|
it('changes when card order changes', async () => {
|
|
const original = await hashVersionCards([card1, card2]);
|
|
const swapped = await hashVersionCards([
|
|
{ ...card1, ord: 1 },
|
|
{ ...card2, ord: 0 },
|
|
]);
|
|
expect(original).not.toBe(swapped);
|
|
});
|
|
|
|
it('changes when a field changes', async () => {
|
|
const original = await hashVersionCards([card1, card2]);
|
|
const tweaked = await hashVersionCards([
|
|
card1,
|
|
{ ...card2, fields: { ...card2.fields, back: 'A2-edited' } },
|
|
]);
|
|
expect(original).not.toBe(tweaked);
|
|
});
|
|
|
|
it('input order independent (sorts by ord)', async () => {
|
|
const inOrder = await hashVersionCards([card1, card2]);
|
|
const reversedInput = await hashVersionCards([card2, card1]);
|
|
expect(inOrder).toBe(reversedInput);
|
|
});
|
|
|
|
it('uses cardContentHash for per-card identity (consumes @wordeck/domain SoT)', async () => {
|
|
// Smoke: changing fields without changing the type must change the
|
|
// per-card hash (cardContentHash semantics) and therefore the
|
|
// version hash.
|
|
const a = await cardContentHash({ type: 'basic', fields: { front: 'X', back: 'Y' } });
|
|
const b = await cardContentHash({ type: 'basic', fields: { front: 'X', back: 'Y2' } });
|
|
expect(a).not.toBe(b);
|
|
});
|
|
});
|