mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-22 21:41:10 +08:00
feat: include categories and tags in global search
This commit is contained in:
@@ -61,10 +61,10 @@ class SearchIntegrationTest {
|
||||
String admin = registerAndLoginAsAdmin("admin1", "a@a.com");
|
||||
String user = registerAndLogin("bob_nice", "b@b.com");
|
||||
|
||||
ResponseEntity<Map> catResp = postJson("/api/categories", Map.of("name", "misc", "description", "d", "icon", "i"), admin);
|
||||
ResponseEntity<Map> catResp = postJson("/api/categories", Map.of("name", "nic-cat", "description", "d", "icon", "i"), admin);
|
||||
Long catId = ((Number)catResp.getBody().get("id")).longValue();
|
||||
|
||||
ResponseEntity<Map> tagResp = postJson("/api/tags", Map.of("name", "misc", "description", "d", "icon", "i"), admin);
|
||||
ResponseEntity<Map> tagResp = postJson("/api/tags", Map.of("name", "nic-tag", "description", "d", "icon", "i"), admin);
|
||||
Long tagId = ((Number)tagResp.getBody().get("id")).longValue();
|
||||
|
||||
ResponseEntity<Map> postResp = postJson("/api/posts",
|
||||
@@ -76,9 +76,11 @@ class SearchIntegrationTest {
|
||||
Map.of("content", "Nice article"), admin);
|
||||
|
||||
List<Map<String, Object>> results = rest.getForObject("/api/search/global?keyword=nic", List.class);
|
||||
assertEquals(3, results.size());
|
||||
assertEquals(5, results.size());
|
||||
assertTrue(results.stream().anyMatch(m -> "user".equals(m.get("type"))));
|
||||
assertTrue(results.stream().anyMatch(m -> "post".equals(m.get("type"))));
|
||||
assertTrue(results.stream().anyMatch(m -> "comment".equals(m.get("type"))));
|
||||
assertTrue(results.stream().anyMatch(m -> "category".equals(m.get("type"))));
|
||||
assertTrue(results.stream().anyMatch(m -> "tag".equals(m.get("type"))));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user