import AppKit import Foundation import Testing @testable import OpenClaw @MainActor struct OnboardingProviderIconTests { @Test func `provider aliases resolve to bundled artwork`() throws { let aliases = [ ("claude", ["claude-cli", "claude-code", "anthropic"]), ("codex", ["codex-cli", "openai"]), ("kimi", ["kimi-code"]), ("xai", ["grok-build", "xai"]), ] for (brand, candidates) in aliases { let expected = try #require(OnboardingProviderIcon.resourceURL(for: brand)) for candidate in candidates { #expect(OnboardingProviderIcon.resourceURL(for: candidate) == expected) } } #expect(OnboardingProviderIcon.resourceURL(for: "Ollama") == OnboardingProviderIcon.resourceURL(for: "ollama")) // Composed choice ids resolve via their leading brand token. #expect(OnboardingProviderIcon.resourceURL(for: "xai-oauth") == OnboardingProviderIcon.resourceURL(for: "xai")) #expect(OnboardingProviderIcon.resourceURL(for: "anthropic-vertex") == OnboardingProviderIcon.resourceURL(for: "claude")) #expect(OnboardingProviderIcon.resourceURL(for: "unknown") == nil) #expect(OnboardingProviderIcon.resourceURL(for: "unknown-oauth") == nil) } @Test func `every mapped brand has decodable vector artwork`() throws { for brand in ["claude", "codex", "gemini", "ollama", "lmstudio", "pi", "opencode", "kimi", "xai"] { let url = try #require(OnboardingProviderIcon.resourceURL(for: brand)) #expect(url.pathExtension == "svg") #expect(try #require(OnboardingProviderIcon.image(for: brand)).isTemplate) } } @Test func `remote artwork distinguishes vector and raster payloads`() throws { // Leading whitespace exercises the sniffer; an XML declaration after // whitespace would be invalid XML, so the fixture uses a bare root. let svg = Data( " \n" .utf8) let vector = try #require(OnboardingRemoteProviderIcon.decode(svg)) #expect(vector.isVector) #expect(vector.nsImage.isTemplate) // Bundled assets lead with a license comment; the sniffer must scan the // prolog instead of expecting as the first non-whitespace token. let commented = try #require(OnboardingProviderIcon.resourceURL(for: "ollama")) let commentedData = try Data(contentsOf: commented) #expect(String(bytes: commentedData.prefix(4), encoding: .utf8) == "