v0.6.0 — Phase β-5 Marketplace
Voller Marketplace-Flow mit TabBar und Universal-Link-Handler. Drei Live-Decks (Geografie, English A2, Periodensystem) sind browse-, abonnier- und lernbar. - PublicDeckEntry/PublicDeck/PublicDeckVersion/PublicDeckOwner/ PublicDeckDetail Codable mit snake_case - ExploreResponse, BrowseResponse, SubscribeResponse - MarketplaceSort-Enum (recent/popular/trending) - CardsAPI.explore/browseMarketplace/publicDeck/subscribe/unsubscribe - MarketplaceStore @Observable mit Explore + Browse States - ExploreView: Featured + Trending Horizontal-Carousels, Browse-Link - BrowseView: Searchable + Sort-Picker + List - PublicDeckView: Header/Metadata/Subscribe — Subscribe löst Auto-Fork serverseitig aus, Response liefert private_deck_id, NavigationLink zum eigenen Deck - PublicDeckCard + BrowseRow mit forest-Theme - RootView: TabBar (Decks/Entdecken/Account) statt Single-View - Universal-Link-Handler: onOpenURL + onContinueUserActivity für https://cardecky.mana.how/d/<slug> und cards://d/<slug> - associated-domains: applinks:cardecky.mana.how im entitlement - 5 neue Marketplace-Decoding-Tests (35 Total grün) Universal-Links funktionieren erst nach AASA-Setup auf cardecky.mana.how/.well-known/apple-app-site-association (Web-Aufgabe, heute 404). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
80eb3708b4
commit
07ada72b0f
10 changed files with 1015 additions and 24 deletions
121
Tests/UnitTests/MarketplaceDecodingTests.swift
Normal file
121
Tests/UnitTests/MarketplaceDecodingTests.swift
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
import Foundation
|
||||
import Testing
|
||||
@testable import CardsNative
|
||||
|
||||
@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 = """
|
||||
{
|
||||
"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": null
|
||||
}
|
||||
}
|
||||
""".data(using: .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 = """
|
||||
{
|
||||
"featured": [],
|
||||
"trending": []
|
||||
}
|
||||
""".data(using: .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 = """
|
||||
{
|
||||
"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
|
||||
}
|
||||
""".data(using: .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 = """
|
||||
{
|
||||
"subscribed": true,
|
||||
"deck_slug": "english-a2",
|
||||
"current_version_id": "v_1",
|
||||
"private_deck_id": "private_deck_xyz"
|
||||
}
|
||||
""".data(using: .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")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue