/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. *--------------------------------------------------------------------------------------------*/ package com.github.copilot.sdk; import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import com.github.copilot.sdk.generated.AssistantUsageEvent; import com.github.copilot.sdk.generated.SessionEvent; import com.github.copilot.sdk.generated.SessionUsageInfoEvent; import com.github.copilot.sdk.json.MessageOptions; import com.github.copilot.sdk.json.PermissionHandler; import com.github.copilot.sdk.json.SessionConfig; /** * E2E tests for event fidelity — verifying the shape, ordering, and presence of * key events emitted from the runtime. * *
* Snapshots are stored in {@code test/snapshots/event_fidelity/}. *
*/ public class EventFidelityTest { private static E2ETestContext ctx; @BeforeAll static void setup() throws Exception { ctx = E2ETestContext.create(); } @AfterAll static void teardown() throws Exception { if (ctx != null) { ctx.close(); } } /** * Verifies that an {@code assistant.usage} event is emitted after the model * processes a prompt. * * @see Snapshot: * event_fidelity/should_emit_assistant_usage_event_after_model_call */ @Test void testShouldEmitAssistantUsageEventAfterModelCall() throws Exception { ctx.configureForTest("event_fidelity", "should_emit_assistant_usage_event_after_model_call"); try (CopilotClient client = ctx.createClient()) { CopilotSession session = client .createSession(new SessionConfig().setOnPermissionRequest(PermissionHandler.APPROVE_ALL)).get(); List