package cn.nianxx.thhotel.platform.system.control;

import static org.hamcrest.Matchers.not;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import cn.nianxx.thhotel.ThHotelApplication;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;

@SpringBootTest(classes = ThHotelApplication.class)
@AutoConfigureMockMvc
@ActiveProfiles("test")
class AgentBusProbeStatusControllerTest {

    @Autowired
    private MockMvc mockMvc;

    @Test
    void shouldExposeAgentBusStatusWithoutSecretsOrRawFrames() throws Exception {
        mockMvc.perform(get("/api/system/agentbus-probe"))
                .andExpect(status().isOk())
                .andExpect(jsonPath("$.enabled").value(false))
                .andExpect(jsonPath("$.connected").value(false))
                .andExpect(jsonPath("$.sessionReady").value(false))
                .andExpect(jsonPath("$.receivedFrameCount").value(0))
                .andExpect(content().string(not(org.hamcrest.Matchers.containsString("AGENTBUS_WS_TOKEN"))))
                .andExpect(content().string(not(org.hamcrest.Matchers.containsString("Authorization"))))
                .andExpect(content().string(not(org.hamcrest.Matchers.containsString("payload"))));
    }
}
