MCPcopy Index your code
hub / github.com/coder/coder / TestHandleAction_CallsRecordActivity

Function TestHandleAction_CallsRecordActivity

agent/x/agentdesktop/api_test.go:301–330  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

299}
300
301func TestHandleAction_CallsRecordActivity(t *testing.T) {
302 t.Parallel()
303
304 logger := slogtest.Make(t, nil)
305 fake := &fakeDesktop{
306 startCfg: agentdesktop.DisplayConfig{Width: 1920, Height: 1080},
307 }
308 api := agentdesktop.NewAPI(logger, fake, nil)
309 defer api.Close()
310
311 body := agentdesktop.DesktopAction{
312 Action: "left_click",
313 Coordinate: &[2]int{100, 200},
314 }
315 b, err := json.Marshal(body)
316 require.NoError(t, err)
317
318 rr := httptest.NewRecorder()
319 req := httptest.NewRequest(http.MethodPost, "/action", bytes.NewReader(b))
320 req.Header.Set("Content-Type", "application/json")
321
322 handler := api.Routes()
323 handler.ServeHTTP(rr, req)
324 require.Equal(t, http.StatusOK, rr.Code)
325
326 fake.recMu.Lock()
327 count := fake.activityCount
328 fake.recMu.Unlock()
329 assert.Equal(t, 1, count, "handleAction should call RecordActivity exactly once")
330}
331
332func TestHandleAction_Screenshot(t *testing.T) {
333 t.Parallel()

Callers

nothing calls this directly

Calls 9

CloseMethod · 0.95
RoutesMethod · 0.95
NewAPIFunction · 0.92
SetMethod · 0.65
MarshalMethod · 0.45
ServeHTTPMethod · 0.45
EqualMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected