Code + Identity-Rename zur Vorbereitung auf Apple-Dev-Portal-Aktion (Bundle ev.mana.wordeck, App-Group group.ev.mana.wordeck, AASA applinks:wordeck.com). Build bleibt funktional, aber gegen die neue text-only-API können image-occlusion-Creates 422 zurückgeben — das wird mit der Wordeck-Native v1.0-Welle (parallele Apple-Aktion) sauber gemacht. Umbenennung: - 41 Files: cardecky/Cardecky → wordeck/Wordeck (Display, Strings, Kommentare) - 57 Files: CardsNative → WordeckNative, CardsAPI → WordeckAPI, CardsTheme → WordeckTheme, CardsBrand → WordeckBrand, CardsWidget → WordeckWidget, CardsDueWidget → WordeckDueWidget - Bundle-ID ev.mana.cardecky → ev.mana.wordeck (project.yml, Info.plist, entitlements, Keychain-Service, App-Group) - AASA applinks:cardecky.mana.how → applinks:wordeck.com - API-Base cardecky-api.mana.how → api.wordeck.com - 10 Files renamed (App-Entry, API-Extensions, Theme, Widget, Entitlements, Tests) - xcodeproj regenerated via xcodegen → WordeckNative.xcodeproj - MaskRegionsTests.swift gelöscht (image-occlusion entfällt mit Wordeck text-only) Forgejo-Repo git.mana.how/till/cards-native → wordeck-native umbenannt (Auto-Redirect aktiv). Lokales Verzeichnis Code/cards-native/ bleibt vorerst — wird beim nächsten Apple-Setup mit Bundle-Test umbenannt. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
105 lines
3.6 KiB
Swift
105 lines
3.6 KiB
Swift
import Foundation
|
|
import Testing
|
|
@testable import WordeckNative
|
|
|
|
@Suite("Deck-JSON-Decoding")
|
|
struct DeckDecodingTests {
|
|
@Test("Wire-Format aus toDeckDto decodet sauber")
|
|
func decodesDeckFromWireFormat() throws {
|
|
let json = Data("""
|
|
{
|
|
"id": "01ARZ3NDEKTSV4RRFFQ69G5FAV",
|
|
"user_id": "user_123",
|
|
"name": "Spanisch A1",
|
|
"description": "Grundwortschatz",
|
|
"color": "#10803D",
|
|
"category": "language",
|
|
"visibility": "private",
|
|
"fsrs_settings": {"request_retention": 0.9, "maximum_interval": 365},
|
|
"content_hash": "abc123",
|
|
"forked_from_marketplace_deck_id": null,
|
|
"forked_from_marketplace_version_id": null,
|
|
"archived_at": null,
|
|
"created_at": "2026-05-12T10:30:00.123Z",
|
|
"updated_at": "2026-05-12T15:45:00.456Z"
|
|
}
|
|
""".utf8)
|
|
|
|
let decoder = JSONDecoder()
|
|
decoder.dateDecodingStrategy = .iso8601withFractional
|
|
let deck = try decoder.decode(Deck.self, from: json)
|
|
|
|
#expect(deck.id == "01ARZ3NDEKTSV4RRFFQ69G5FAV")
|
|
#expect(deck.name == "Spanisch A1")
|
|
#expect(deck.description == "Grundwortschatz")
|
|
#expect(deck.color == "#10803D")
|
|
#expect(deck.category == .language)
|
|
#expect(deck.visibility == .private)
|
|
#expect(deck.isFromMarketplace == false)
|
|
#expect(deck.archivedAt == nil)
|
|
}
|
|
|
|
@Test("Marketplace-Forks werden erkannt")
|
|
func recognizesMarketplaceFork() throws {
|
|
let json = Data("""
|
|
{
|
|
"id": "deck_456",
|
|
"user_id": "user_123",
|
|
"name": "Geografie",
|
|
"description": null,
|
|
"color": null,
|
|
"category": null,
|
|
"visibility": "private",
|
|
"fsrs_settings": {},
|
|
"content_hash": null,
|
|
"forked_from_marketplace_deck_id": "mp_deck_789",
|
|
"forked_from_marketplace_version_id": "mp_ver_1",
|
|
"archived_at": null,
|
|
"created_at": "2026-05-01T00:00:00.000Z",
|
|
"updated_at": "2026-05-01T00:00:00.000Z"
|
|
}
|
|
""".utf8)
|
|
|
|
let decoder = JSONDecoder()
|
|
decoder.dateDecodingStrategy = .iso8601withFractional
|
|
let deck = try decoder.decode(Deck.self, from: json)
|
|
|
|
#expect(deck.isFromMarketplace == true)
|
|
#expect(deck.forkedFromMarketplaceDeckId == "mp_deck_789")
|
|
#expect(deck.category == nil)
|
|
}
|
|
|
|
@Test("DeckListResponse-Wrapper")
|
|
func decodesListResponse() throws {
|
|
let json = Data("""
|
|
{
|
|
"decks": [
|
|
{
|
|
"id": "d1",
|
|
"user_id": "u1",
|
|
"name": "Deck 1",
|
|
"description": null,
|
|
"color": null,
|
|
"category": null,
|
|
"visibility": "private",
|
|
"fsrs_settings": {},
|
|
"content_hash": null,
|
|
"forked_from_marketplace_deck_id": null,
|
|
"forked_from_marketplace_version_id": null,
|
|
"archived_at": null,
|
|
"created_at": "2026-01-01T00:00:00.000Z",
|
|
"updated_at": "2026-01-01T00:00:00.000Z"
|
|
}
|
|
],
|
|
"total": 1
|
|
}
|
|
""".utf8)
|
|
|
|
let decoder = JSONDecoder()
|
|
decoder.dateDecodingStrategy = .iso8601withFractional
|
|
let response = try decoder.decode(DeckListResponse.self, from: json)
|
|
|
|
#expect(response.total == 1)
|
|
#expect(response.decks.first?.name == "Deck 1")
|
|
}
|
|
}
|