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

Function TestHandleAction_ScrollDown

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

Source from the content-addressed store, hash-verified

656}
657
658func TestHandleAction_ScrollDown(t *testing.T) {
659 t.Parallel()
660
661 logger := slogtest.Make(t, nil)
662 fake := &fakeDesktop{
663 startCfg: agentdesktop.DisplayConfig{Width: 1920, Height: 1080},
664 }
665 api := agentdesktop.NewAPI(logger, fake, nil)
666 defer api.Close()
667
668 dir := "down"
669 amount := 5
670 body := agentdesktop.DesktopAction{
671 Action: "scroll",
672 Coordinate: &[2]int{500, 400},
673 ScrollDirection: &dir,
674 ScrollAmount: &amount,
675 }
676 b, err := json.Marshal(body)
677 require.NoError(t, err)
678
679 rr := httptest.NewRecorder()
680 req := httptest.NewRequest(http.MethodPost, "/action", bytes.NewReader(b))
681 req.Header.Set("Content-Type", "application/json")
682
683 handler := api.Routes()
684 handler.ServeHTTP(rr, req)
685
686 assert.Equal(t, http.StatusOK, rr.Code)
687 assert.Equal(t, [4]int{500, 400, 0, 5}, fake.lastScroll)
688}
689
690func TestHandleAction_CoordinateScaling(t *testing.T) {
691 t.Parallel()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected