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>
121 lines
3.9 KiB
Swift
121 lines
3.9 KiB
Swift
import Foundation
|
|
import Testing
|
|
@testable import WordeckNative
|
|
|
|
@Suite("Marketplace-JSON-Decoding")
|
|
struct MarketplaceDecodingTests {
|
|
private func decoder() -> JSONDecoder {
|
|
let d = JSONDecoder()
|
|
d.dateDecodingStrategy = .iso8601withFractional
|
|
return d
|
|
}
|
|
|
|
@Test("PublicDeckEntry aus Browse-Response")
|
|
func decodesPublicDeckEntry() throws {
|
|
let json = Data("""
|
|
{
|
|
"slug": "geografie-welt-top30",
|
|
"title": "Geografie Welt Top 30",
|
|
"description": "Hauptstädte",
|
|
"language": "de",
|
|
"category": "geography",
|
|
"license": "CC0-1.0",
|
|
"price_credits": 0,
|
|
"card_count": 30,
|
|
"star_count": 12,
|
|
"subscriber_count": 5,
|
|
"is_featured": true,
|
|
"created_at": "2026-05-08T10:00:00.000Z",
|
|
"owner": {
|
|
"slug": "mana-curators",
|
|
"display_name": "mana-Kuratoren",
|
|
"verified_mana": true,
|
|
"verified_community": false,
|
|
"pseudonym": false
|
|
}
|
|
}
|
|
""".utf8)
|
|
|
|
let entry = try decoder().decode(PublicDeckEntry.self, from: json)
|
|
#expect(entry.slug == "geografie-welt-top30")
|
|
#expect(entry.cardCount == 30)
|
|
#expect(entry.isFeatured == true)
|
|
#expect(entry.isPaid == false)
|
|
#expect(entry.owner.verifiedMana == true)
|
|
}
|
|
|
|
@Test("ExploreResponse mit featured + trending")
|
|
func decodesExploreResponse() throws {
|
|
let json = Data("""
|
|
{
|
|
"featured": [],
|
|
"trending": []
|
|
}
|
|
""".utf8)
|
|
let res = try decoder().decode(ExploreResponse.self, from: json)
|
|
#expect(res.featured.isEmpty)
|
|
#expect(res.trending.isEmpty)
|
|
}
|
|
|
|
@Test("PublicDeckDetail mit camelCase 'latest_version'")
|
|
func decodesPublicDeckDetail() throws {
|
|
let json = Data("""
|
|
{
|
|
"deck": {
|
|
"id": "deck_1",
|
|
"slug": "english-a2",
|
|
"title": "English A2",
|
|
"description": null,
|
|
"language": "en",
|
|
"category": "language",
|
|
"license": "CC-BY-4.0",
|
|
"price_credits": 0,
|
|
"owner_user_id": "user_1",
|
|
"latest_version_id": "v_1",
|
|
"is_featured": false,
|
|
"is_takedown": false,
|
|
"created_at": "2026-05-01T00:00:00.000Z"
|
|
},
|
|
"latest_version": {
|
|
"id": "v_1",
|
|
"deck_id": "deck_1",
|
|
"semver": "1.0.0",
|
|
"changelog": "Initial release",
|
|
"content_hash": "abc",
|
|
"card_count": 500,
|
|
"published_at": "2026-05-01T00:00:00.000Z",
|
|
"deprecated_at": null
|
|
},
|
|
"owner": null
|
|
}
|
|
""".utf8)
|
|
|
|
let detail = try decoder().decode(PublicDeckDetail.self, from: json)
|
|
#expect(detail.deck.slug == "english-a2")
|
|
#expect(detail.latestVersion?.semver == "1.0.0")
|
|
#expect(detail.latestVersion?.cardCount == 500)
|
|
#expect(detail.owner == nil)
|
|
}
|
|
|
|
@Test("SubscribeResponse mit private_deck_id")
|
|
func decodesSubscribeResponse() throws {
|
|
let json = Data("""
|
|
{
|
|
"subscribed": true,
|
|
"deck_slug": "english-a2",
|
|
"current_version_id": "v_1",
|
|
"private_deck_id": "private_deck_xyz"
|
|
}
|
|
""".utf8)
|
|
let res = try decoder().decode(SubscribeResponse.self, from: json)
|
|
#expect(res.subscribed == true)
|
|
#expect(res.privateDeckId == "private_deck_xyz")
|
|
}
|
|
|
|
@Test("MarketplaceSort-Werte sind exakt wie API erwartet")
|
|
func sortRawValues() {
|
|
#expect(MarketplaceSort.recent.rawValue == "recent")
|
|
#expect(MarketplaceSort.popular.rawValue == "popular")
|
|
#expect(MarketplaceSort.trending.rawValue == "trending")
|
|
}
|
|
}
|