-
Notifications
You must be signed in to change notification settings - Fork 4
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: support user search #1285
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
923405d
fix
yk-eukarya d194adf
Merge branch 'main' into feat/support-user-search
yk-eukarya 98408ea
Merge branch 'main' into feat/support-user-search
yk-eukarya e4c2c71
fix: user adding modal
caichi-t 837450c
fix: user search query
caichi-t 3883328
apply suggestion
caichi-t 7d772e2
Merge branch 'main' of https://github.com/reearth/reearth-cms into fe…
caichi-t 533164b
Merge branch 'main' into feat/support-user-search
yk-eukarya 40d397e
fix: ci error
caichi-t e462a10
Merge branch 'main' into feat/support-user-search
yk-eukarya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
} | ||
|
@@ -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("[email protected]") | ||
|
||
query = fmt.Sprintf(` { searchUser(nameOrEmail: "%s"){ id name email } }`, "notfound") | ||
query = fmt.Sprintf(` { userByNameOrEmail(nameOrEmail: "%s"){ id name email } }`, "notfound") | ||
request = GraphQLRequest{ | ||
Query: query, | ||
} | ||
|
@@ -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("[email protected]") | ||
|
||
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("[email protected]") | ||
|
||
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) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve test reliability and coverage.
The current implementation has several areas that could be improved:
The test is tightly coupled to specific test data:
Missing test cases:
Consider refactoring the test to be more resilient to data changes:
Also, consider adding validation for result ordering or explicitly documenting if the order is undefined.
Would you like me to help implement the additional test cases and make the tests more resilient?