package com.correx.core.events.serialization

import com.correx.core.events.events.BriefEchoMismatchEvent
import com.correx.core.events.events.EventPayload
import com.correx.core.events.types.SessionId
import com.correx.core.events.types.StageId
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue

class BriefEchoEventSerializationTest {

    @Test
    fun `BriefEchoMismatchEvent round-trips as polymorphic EventPayload`() {
        val sample: EventPayload = BriefEchoMismatchEvent(
            sessionId = SessionId("s"),
            stageId = StageId("plan"),
            droppedFiles = setOf("core/kernel/Foo.kt"),
            droppedSymbols = setOf("Foo"),
            droppedAcceptanceCriteria = setOf("must compile"),
            inventedFiles = setOf("core/kernel/Bar.kt"),
        )
        val encoded = eventJson.encodeToString(EventPayload.serializer(), sample)
        assertTrue(encoded.contains("\"type\":\"BriefEchoMismatch\""), "SerialName must be present: $encoded")
        val decoded = eventJson.decodeFromString(EventPayload.serializer(), encoded)
        assertEquals(sample, decoded)
    }
}
