Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): add photooverlay property [VIZ-1340] #1462

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@ github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZ
github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8=
github.com/reearth/reearthx v0.0.0-20240229141256-04bd46953fe6 h1:7EMP5wvzOcip/Bi7KPkCMx5Vtq4V31cfkSneqZxr+as=
github.com/reearth/reearthx v0.0.0-20240229141256-04bd46953fe6/go.mod h1:8DSD6e+h1KhfhO4TceYDDPpLkhZJH2CLF6nHxyV8hts=
github.com/reearth/reearthx v0.0.0-20250303100614-3195e85d0cd8 h1:p6owtV+2dPUWL/yhXc4SR1QfzLUEEgmWq0HRZEYO2W0=
github.com/reearth/reearthx v0.0.0-20250303100614-3195e85d0cd8/go.mod h1:/ByvE9o0WANHL2nhOyZjOXWwY8cCgze0OmwyNzxcYoA=
github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481 h1:jMxcLa+VjJKhpCwbLUXAD15wJ+hhvXMLujCl3MkXpfM=
github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s=
github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk=
Expand Down
7 changes: 7 additions & 0 deletions server/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ type GraphQLRequest struct {
}

func Request(e *httpexpect.Expect, user string, requestBody GraphQLRequest) *httpexpect.Value {
// RequestDump(requestBody)
return e.POST("/api/graphql").
WithHeader("Origin", "https://example.com").
WithHeader("authorization", "Bearer test").
Expand Down Expand Up @@ -275,6 +276,12 @@ func aligningJSON(t *testing.T, str string) string {
return string(strBytes)
}

func RequestDump(requestBody GraphQLRequest) {
if jsonData, err := json.MarshalIndent(requestBody, "", " "); err == nil {
fmt.Println(string(jsonData))
}
}

func ValueDump(val *httpexpect.Value) {
raw := val.Raw()
switch data := raw.(type) {
Expand Down
69 changes: 66 additions & 3 deletions server/e2e/gql_nlslayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ func TestNLSLayerCRUD(t *testing.T) {
Value("updatedAt").NotEqual(notUpdatedProjectUpdatedAt)
}

func createInfobox(e *httpexpect.Expect, layerId string) (GraphQLRequest, *httpexpect.Value, string) {
func createInfobox(e *httpexpect.Expect, layerId string) (GraphQLRequest, *httpexpect.Value, string, string) {
requestBody := GraphQLRequest{
OperationName: "CreateNLSInfobox",
Query: `mutation CreateNLSInfobox($layerId: ID!) {
Expand All @@ -509,6 +509,7 @@ func createInfobox(e *httpexpect.Expect, layerId string) (GraphQLRequest, *httpe
infobox {
id
layerId
propertyId
}
}
}
Expand All @@ -527,7 +528,10 @@ func createInfobox(e *httpexpect.Expect, layerId string) (GraphQLRequest, *httpe
Value("infobox").Object().
HasValue("layerId", layerId)

return requestBody, res, res.Path("$.data.createNLSInfobox.layer.infobox.id").Raw().(string)
infobox := res.Path("$.data.createNLSInfobox.layer.infobox")
lId := infobox.Object().Value("layerId").Raw().(string)
pId := infobox.Object().Value("propertyId").Raw().(string)
return requestBody, res, lId, pId
}

// func removeNLSInfobox(e *httpexpect.Expect, layerId string) (GraphQLRequest, *httpexpect.Value) {
Expand Down Expand Up @@ -734,7 +738,7 @@ func TestInfoboxBlocksCRUD(t *testing.T) {
Value("newLayers").Array().
Length().IsEqual(1)

_, _, _ = createInfobox(e, layerId)
_, _, _, _ = createInfobox(e, layerId)

_, res = fetchSceneForNewLayers(e, sId)
res.Object().
Expand Down Expand Up @@ -774,6 +778,65 @@ func TestInfoboxBlocksCRUD(t *testing.T) {
Value("updatedAt").NotEqual(notUpdatedProjectUpdatedAt)
}

func TestInfoboxProperty(t *testing.T) {
e := Server(t, baseSeeder)

pId := createProject(e, "test")
_, _, sId := createScene(e, pId)

// fetch scene
_, res := fetchSceneForNewLayers(e, sId)
res.Object().
Value("data").Object().
Value("node").Object().
Value("newLayers").Array().
Length().IsEqual(0)

// Add NLSLayer
_, _, layerId := addNLSLayerSimple(e, sId, "someTitle", 1)
_, res = fetchSceneForNewLayers(e, sId)
res.Object().
Value("data").Object().
Value("node").Object().
Value("newLayers").Array().
Length().IsEqual(1)

_, _, _, propertyId := createInfobox(e, layerId)

// --- Position Property
_, r := updatePropertyValue(e, propertyId, "default", "", "position", "left", "STRING")
r.Path("$.data.updatePropertyValue.propertyField.value").IsEqual("left")

// --- Padding Property
_, r = updatePropertyValue(e, propertyId, "default", "", "padding", map[string]any{
"top": 11,
"bottom": 12,
"left": 13,
"right": 14,
}, "SPACING")
r.Path("$.data.updatePropertyValue.propertyField.value").IsEqual(map[string]any{
"top": 11,
"bottom": 12,
"left": 13,
"right": 14,
})

// --- Gap Property
_, r = updatePropertyValue(e, propertyId, "default", "", "gap", 10, "NUMBER")
r.Path("$.data.updatePropertyValue.propertyField.value").IsEqual(10)

// --- PhotoOverlay Property
_, r = updatePropertyValue(e, propertyId, "default", "", "photooverlay", map[string]any{
"enabled": true,
"cameraDuration": 30,
}, "PHOTOOVERLAY")
r.Path("$.data.updatePropertyValue.propertyField.value").IsEqual(map[string]any{
"enabled": true,
"cameraDuration": 30,
})

}

func updateCustomProperties(
e *httpexpect.Expect,
layerId string,
Expand Down
4 changes: 2 additions & 2 deletions server/e2e/gql_project_export_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func importProject(t *testing.T, e *httpexpect.Expect, filePath string) *httpexp
func getScene(e *httpexpect.Expect, s string, l string) *httpexpect.Value {
requestBody := GraphQLRequest{
OperationName: "GetScene",
Query: GetSceneGuery,
Query: GetSceneQuery,
Variables: map[string]any{
"sceneId": s,
"lang": l,
Expand All @@ -189,7 +189,7 @@ func getScene(e *httpexpect.Expect, s string, l string) *httpexpect.Value {
return v
}

const GetSceneGuery = `
const GetSceneQuery = `
query GetScene($sceneId: ID!, $lang: Lang) {
node(id: $sceneId, type: SCENE) {
id
Expand Down
Loading
Loading