Skip to content

Commit

Permalink
Merge branch 'main' into feat/asst-url
Browse files Browse the repository at this point in the history
  • Loading branch information
yk-eukarya authored Nov 22, 2024
2 parents c923939 + 397f81a commit 1b489c0
Show file tree
Hide file tree
Showing 114 changed files with 2,500 additions and 1,089 deletions.
6 changes: 6 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2598,6 +2598,12 @@ github.com/redis/go-redis/v9 v9.1.0/go.mod h1:urWj3He21Dj5k4TK1y59xH8Uj6ATueP8AH
github.com/reearth/reearthx v0.0.0-20221109022045-dd54f4626639/go.mod h1:YZMXO1RhQ5fFL0GIOFvJq2GNskW7w+xoW4Zfu2QUXhw=
github.com/reearth/reearthx v0.0.0-20230531092445-3bdc26691898 h1:M9m03h+EBR33vxIfBnen5kavaIRRu7gXFkwqHqHU0l4=
github.com/reearth/reearthx v0.0.0-20230531092445-3bdc26691898/go.mod h1:Rh7MJPKq43f+HZ/PwjZ5vEbGPpllNFvUrxn9sBn2b+s=
github.com/reearth/reearthx v0.0.0-20241023075926-e29bdd6c4ae3 h1:aFm6QNDFs08EKlrWJN9IBqdxlDUuCBIIgBIcPkLHOZY=
github.com/reearth/reearthx v0.0.0-20241023075926-e29bdd6c4ae3/go.mod h1:d1WXkdCVzSoc8pl3vW9/9yKfk4fdoZQZhX8Ot8jqgnc=
github.com/reearth/reearthx v0.0.0-20241025125329-f01a05daf443 h1:r3bAWyEVAMX60W70OPeWd0uA+2sLhXgox41rQb2XKDY=
github.com/reearth/reearthx v0.0.0-20241025125329-f01a05daf443/go.mod h1:d1WXkdCVzSoc8pl3vW9/9yKfk4fdoZQZhX8Ot8jqgnc=
github.com/reearth/reearthx v0.0.0-20241121115830-a7f7b61afe26 h1:epJj+4FT1OkHr4uOugcGU70pT3SKK1VquLi1z8aE2wk=
github.com/reearth/reearthx v0.0.0-20241121115830-a7f7b61afe26/go.mod h1:/ByvE9o0WANHL2nhOyZjOXWwY8cCgze0OmwyNzxcYoA=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481 h1:jMxcLa+VjJKhpCwbLUXAD15wJ+hhvXMLujCl3MkXpfM=
Expand Down
2 changes: 1 addition & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23.2-alpine AS build
FROM golang:1.23.3-alpine AS build
ARG TAG=release
ARG REV
ARG VERSION
Expand Down
68 changes: 63 additions & 5 deletions server/e2e/gql_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ func TestMe(t *testing.T) {
o.Value("myWorkspaceId").String().IsEqual(wId2.String())
}

func TestSearchUser(t *testing.T) {
func TestUserByNameOrEmail(t *testing.T) {
e := StartServer(t, &app.Config{}, true, baseSeederUser)
query := fmt.Sprintf(` { searchUser(nameOrEmail: "%s"){ id name email } }`, "e2e")
query := fmt.Sprintf(` { userByNameOrEmail(nameOrEmail: "%s"){ id name email } }`, "e2e")
request := GraphQLRequest{
Query: query,
}
Expand All @@ -221,12 +221,12 @@ func TestSearchUser(t *testing.T) {
WithHeader("authorization", "Bearer test").
WithHeader("Content-Type", "application/json").
WithHeader("X-Reearth-Debug-User", uId1.String()).
WithBytes(jsonData).Expect().Status(http.StatusOK).JSON().Object().Value("data").Object().Value("searchUser").Object()
WithBytes(jsonData).Expect().Status(http.StatusOK).JSON().Object().Value("data").Object().Value("userByNameOrEmail").Object()
o.Value("id").String().IsEqual(uId1.String())
o.Value("name").String().IsEqual("e2e")
o.Value("email").String().IsEqual("e2e@e2e.com")

query = fmt.Sprintf(` { searchUser(nameOrEmail: "%s"){ id name email } }`, "notfound")
query = fmt.Sprintf(` { userByNameOrEmail(nameOrEmail: "%s"){ id name email } }`, "notfound")
request = GraphQLRequest{
Query: query,
}
Expand All @@ -239,7 +239,65 @@ func TestSearchUser(t *testing.T) {
WithHeader("Content-Type", "application/json").
WithHeader("X-Reearth-Debug-User", uId1.String()).
WithBytes(jsonData).Expect().Status(http.StatusOK).JSON().Object().
Value("data").Object().Value("searchUser").IsNull()
Value("data").Object().Value("userByNameOrEmail").IsNull()
}

func TestUserSearch(t *testing.T) {
e := StartServer(t, &app.Config{}, true, baseSeederUser)
query := fmt.Sprintf(` { userSearch(keyword: "%s"){ id name email } }`, "e2e")
request := GraphQLRequest{
Query: query,
}
jsonData, err := json.Marshal(request)
if err != nil {
assert.NoError(t, err)
}
res := e.POST("/api/graphql").
WithHeader("authorization", "Bearer test").
WithHeader("Content-Type", "application/json").
WithHeader("X-Reearth-Debug-User", uId1.String()).
WithBytes(jsonData).Expect().Status(http.StatusOK).JSON().Object()
ul := res.Value("data").Object().Value("userSearch").Array()
ul.Length().IsEqual(4)
o := ul.Value(0).Object()
o.Value("id").String().IsEqual(uId1.String())
o.Value("name").String().IsEqual("e2e")
o.Value("email").String().IsEqual("e2e@e2e.com")

query = fmt.Sprintf(` { userSearch(keyword: "%s"){ id name email } }`, "e2e2")
request = GraphQLRequest{
Query: query,
}
jsonData, err = json.Marshal(request)
if err != nil {
assert.NoError(t, err)
}
res = e.POST("/api/graphql").
WithHeader("authorization", "Bearer test").
WithHeader("Content-Type", "application/json").
WithHeader("X-Reearth-Debug-User", uId1.String()).
WithBytes(jsonData).Expect().Status(http.StatusOK).JSON().Object()
ul = res.Value("data").Object().Value("userSearch").Array()
ul.Length().IsEqual(1)
o = ul.Value(0).Object()
o.Value("id").String().IsEqual(uId2.String())
o.Value("name").String().IsEqual("e2e2")
o.Value("email").String().IsEqual("e2e2@e2e.com")

query = fmt.Sprintf(` { userSearch(keyword: "%s"){ id name email } }`, "notfound")
request = GraphQLRequest{
Query: query,
}
jsonData, err = json.Marshal(request)
if err != nil {
assert.NoError(t, err)
}
e.POST("/api/graphql").
WithHeader("authorization", "Bearer test").
WithHeader("Content-Type", "application/json").
WithHeader("X-Reearth-Debug-User", uId1.String()).
WithBytes(jsonData).Expect().Status(http.StatusOK).JSON().Object().
Value("data").Object().Value("userSearch").Array().IsEmpty()
}

func TestNode(t *testing.T) {
Expand Down
98 changes: 98 additions & 0 deletions server/e2e/integration_item_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var (
mId2 = id.NewModelID()
mId3 = id.NewModelID()
mId4 = id.NewModelID()
mId5 = id.NewModelID()
dvmId = id.NewModelID()
aid1 = id.NewAssetID()
aid2 = id.NewAssetID()
Expand All @@ -52,6 +53,7 @@ var (
itmId3 = id.NewItemID()
itmId4 = id.NewItemID()
itmId5 = id.NewItemID()
itmId6 = id.NewItemID()
fId1 = id.NewFieldID()
fId2 = id.NewFieldID()
fId3 = id.NewFieldID()
Expand All @@ -60,18 +62,21 @@ var (
fId6 = id.NewFieldID()
fId7 = id.NewFieldID()
fId8 = id.NewFieldID()
fId9 = id.NewFieldID()
dvsfId = id.NewFieldID()
thId1 = id.NewThreadID()
thId2 = id.NewThreadID()
thId3 = id.NewThreadID()
thId4 = id.NewThreadID()
thId5 = id.NewThreadID()
thId6 = id.NewThreadID()
icId = id.NewCommentID()
ikey0 = id.RandomKey()
ikey1 = id.RandomKey()
ikey2 = id.RandomKey()
ikey3 = id.RandomKey()
ikey4 = id.RandomKey()
ikey5 = id.RandomKey()
pid = id.NewProjectID()
sid0 = id.NewSchemaID()
sid1 = id.NewSchemaID()
Expand All @@ -86,6 +91,7 @@ var (
sfKey6 = id.NewKey("group-key")
sfKey7 = id.NewKey("geometry-key")
sfKey8 = id.NewKey("geometry-editor-key")
sfkey9 = id.NewKey("number-key")
gKey1 = id.RandomKey()
gId1 = id.NewItemGroupID()
gId2 = id.NewItemGroupID()
Expand Down Expand Up @@ -263,6 +269,28 @@ func baseSeeder(ctx context.Context, r *repo.Container) error {
if err := r.Model.Save(ctx, m4); err != nil {
return err
}

float1 := float64(1.2)
float2 := float64(123.4)
sn1, _ := schema.NewNumber(&float1, &float2)
sf9 := schema.NewField(sn1.TypeProperty()).ID(fId9).Key(sfkey9).Type(sn1.TypeProperty()).MustBuild()
s8 := schema.New().ID(id.NewSchemaID()).Workspace(w.ID()).Project(p.ID()).Fields([]*schema.Field{sf9}).MustBuild()
if err := r.Schema.Save(ctx, s8); err != nil {
return err
}
m5 := model.New().
ID((mId5)).
Name("m5").
Description("m5 desc").
Public(true).
Key(ikey5).
Project(p.ID()).
Schema(s8.ID()).
MustBuild()
if err := r.Model.Save(ctx, m5); err != nil {
return err
}

// endregion

// region items
Expand Down Expand Up @@ -336,6 +364,22 @@ func baseSeeder(ctx context.Context, r *repo.Container) error {
if err := r.Item.Save(ctx, itm5); err != nil {
return err
}

itm6 := item.New().ID(itmId6).
Schema(s8.ID()).
Model(m5.ID()).
Project(p.ID()).
Thread(thId6).
IsMetadata(false).
Fields([]*item.Field{
item.NewField(fId9, value.MultipleFrom(value.TypeNumber, []*value.Value{
value.TypeNumber.Value(21.2),
}), nil),
}).
MustBuild()
if err := r.Item.Save(ctx, itm6); err != nil {
return err
}
// endregion

// region thread & comment
Expand Down Expand Up @@ -611,6 +655,56 @@ func TestIntegrationItemListAPI(t *testing.T) {
HasValue("page", 1).
HasValue("perPage", 5).
HasValue("totalCount", 1)

r3 := e.POST("/api/models/{modelId}/items", mId5).
WithHeader("authorization", "Bearer "+secret).
WithJSON(map[string]interface{}{
"fields": []interface{}{
map[string]any{
"key": sfkey9.String(),
"type": "number",
"value": float64(21.2),
},
},
}).
Expect().
Status(http.StatusOK).
JSON().
Object()

r3.
Value("fields").
IsEqual([]any{
map[string]any{
"id": fId9.String(),
"type": "number",
"value": float64(21.2),
"key": sfkey9.String(),
},
})

e.GET("/api/models/{modelId}/items", mId5).
WithHeader("authorization", "Bearer "+secret).
WithQuery("page", 1).
WithQuery("perPage", 5).
WithQuery("asset", "true").
Expect().
Status(http.StatusOK).
JSON().
Object().
HasValue("page", 1).
HasValue("perPage", 5).
HasValue("totalCount", 2)
r3.
Value("fields").
IsEqual([]any{
map[string]any{
"id": fId9.String(),
"type": "number",
"value": float64(21.2),
"key": sfkey9.String(),
},
})
}

// GET /models/{modelId}/items
Expand Down Expand Up @@ -1998,6 +2092,10 @@ func TestIntegrationDeleteItemAPI(t *testing.T) {
Status(http.StatusNotFound)
}

func TestIntegrationItemForNumberAndIntegerType(t *testing.T) {

}

func assertItem(v *httpexpect.Value, assetEmbeded bool) {
o := v.Object()
o.Value("id").IsEqual(itmId1.String())
Expand Down
4 changes: 2 additions & 2 deletions server/e2e/integration_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ func TestIntegrationModelFilterAPI(t *testing.T) {
Object().
HasValue("page", 1).
HasValue("perPage", 10).
HasValue("totalCount", 6).
HasValue("totalCount", 7).
Value("models").
Array()
models.Length().IsEqual(6)
models.Length().IsEqual(7)

obj0 := models.Value(0).Object()
obj0.
Expand Down
4 changes: 2 additions & 2 deletions server/e2e/integration_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ func TestIntegrationSchemaFilterAPI(t *testing.T) {
Object().
HasValue("page", 1).
HasValue("perPage", 10).
HasValue("totalCount", 6).
HasValue("totalCount", 7).
Value("models").
Array()
models.Length().IsEqual(6)
models.Length().IsEqual(7)

obj0 := models.Value(0).Object()
obj0.
Expand Down
2 changes: 1 addition & 1 deletion server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require (
github.com/oapi-codegen/runtime v1.1.1
github.com/paulmach/go.geojson v1.5.0
github.com/ravilushqa/otelgqlgen v0.17.0
github.com/reearth/reearthx v0.0.0-20241023075926-e29bdd6c4ae3
github.com/reearth/reearthx v0.0.0-20241121115830-a7f7b61afe26
github.com/robbiet480/go.sns v0.0.0-20230523235941-e8d832c79d68
github.com/samber/lo v1.47.0
github.com/sendgrid/sendgrid-go v3.16.0+incompatible
Expand Down
4 changes: 2 additions & 2 deletions server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSg
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/ravilushqa/otelgqlgen v0.17.0 h1:bLwQfKqtj9P24QpjM2sc1ipBm5Fqv2u7DKN5LIpj3g8=
github.com/ravilushqa/otelgqlgen v0.17.0/go.mod h1:orOIikuYsay1y3CmLgd5gsHcT9EsnXwNKmkAplzzYXQ=
github.com/reearth/reearthx v0.0.0-20241023075926-e29bdd6c4ae3 h1:aFm6QNDFs08EKlrWJN9IBqdxlDUuCBIIgBIcPkLHOZY=
github.com/reearth/reearthx v0.0.0-20241023075926-e29bdd6c4ae3/go.mod h1:d1WXkdCVzSoc8pl3vW9/9yKfk4fdoZQZhX8Ot8jqgnc=
github.com/reearth/reearthx v0.0.0-20241121115830-a7f7b61afe26 h1:epJj+4FT1OkHr4uOugcGU70pT3SKK1VquLi1z8aE2wk=
github.com/reearth/reearthx v0.0.0-20241121115830-a7f7b61afe26/go.mod h1:/ByvE9o0WANHL2nhOyZjOXWwY8cCgze0OmwyNzxcYoA=
github.com/robbiet480/go.sns v0.0.0-20230523235941-e8d832c79d68 h1:Jknsfy5cqCH6qAuoU1qNZ51hfBJfMSJYwsH9j9mdVnw=
github.com/robbiet480/go.sns v0.0.0-20230523235941-e8d832c79d68/go.mod h1:9CDhL7uDVy8vEVDNPJzxq89dPaPBWP6hxQcC8woBHus=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
Expand Down
Loading

0 comments on commit 1b489c0

Please sign in to comment.