Skip to content

Commit

Permalink
add e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
  • Loading branch information
Nexucis committed May 15, 2024
1 parent 6c04bdf commit 6fa3f21
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions internal/api/e2e/api/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,28 @@ func TestListDashboardInEmptyProject(t *testing.T) {
})
}

func TestListDashboardWithOnlyMetadata(t *testing.T) {
e2eframework.WithServer(t, func(expect *httpexpect.Expect, manager dependency.PersistenceManager) []api.Entity {
demoDashboard := e2eframework.NewDashboard(t, "perses", "Demo")
persesProject := e2eframework.NewProject("perses")
e2eframework.CreateAndWaitUntilEntitiesExist(t, manager, persesProject, demoDashboard)

response := expect.GET(fmt.Sprintf("%s/%s/%s/%s", utils.APIV1Prefix, utils.PathProject, persesProject.GetMetadata().GetName(), utils.PathDashboard)).
WithQuery("metadata_only", true).
Expect().
Status(http.StatusOK)

response.JSON().Array().Length().IsEqual(1)
response.JSON().Array().Value(0).Object().IsEqual(modelV1.PartialProjectEntity{
Kind: demoDashboard.Kind,
Metadata: demoDashboard.Metadata,
Spec: struct{}{},
})

return []api.Entity{persesProject, demoDashboard}
})
}

func extractDashboardFromHTTPBody(body interface{}, t *testing.T) *modelV1.Dashboard {
b := testUtils.JSONMarshalStrict(body)
dashboard := &modelV1.Dashboard{}
Expand Down

0 comments on commit 6fa3f21

Please sign in to comment.