mirror of
https://github.com/outline/outline.git
synced 2026-11-30 00:50:41 +03:00
fix: Present collections in suggestions.mention response (#14747)
This commit is contained in:
1 parent
66432e53a4
commit
5891724628
2 files changed
+39
-9
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { EmailDisplay, TeamPreference } from "@shared/types";
|
||||
import {
|
||||
buildCollection,
|
||||
buildGroup,
|
||||
buildGroupUser,
|
||||
buildGuestUser,
|
||||
@@ -138,6 +139,27 @@ describe("#suggestions.mention", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("should present collections", async () => {
|
||||
const user = await buildUser();
|
||||
const collection = await buildCollection({
|
||||
teamId: user.teamId,
|
||||
userId: user.id,
|
||||
name: "Elephants",
|
||||
});
|
||||
|
||||
const res = await server.post("/api/suggestions.mention", user, {
|
||||
body: { query: "Elephants" },
|
||||
});
|
||||
const body = await res.json();
|
||||
const [found] = body.data.collections;
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(found.id).toEqual(collection.id);
|
||||
expect(found.url).toEqual(collection.path);
|
||||
expect(found.content).toBeUndefined();
|
||||
expect(found.data).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should require authentication", async () => {
|
||||
const res = await server.post("/api/suggestions.mention");
|
||||
expect(res.status).toEqual(401);
|
||||
|
||||
@@ -15,6 +15,7 @@ import SearchProviderManager from "@server/utils/SearchProviderManager";
|
||||
import { QueryHelper } from "@server/storage/QueryHelper";
|
||||
import { can } from "@server/policies";
|
||||
import {
|
||||
presentCollection,
|
||||
presentDocuments,
|
||||
presentGroup,
|
||||
presentUser,
|
||||
@@ -153,15 +154,22 @@ router.post(
|
||||
),
|
||||
withinLimit(
|
||||
"collections",
|
||||
() =>
|
||||
SearchProviderManager.getProvider().searchCollectionsForUser(
|
||||
actor,
|
||||
{
|
||||
query,
|
||||
offset,
|
||||
limit,
|
||||
}
|
||||
),
|
||||
async () => {
|
||||
const found =
|
||||
await SearchProviderManager.getProvider().searchCollectionsForUser(
|
||||
actor,
|
||||
{
|
||||
query,
|
||||
offset,
|
||||
limit,
|
||||
}
|
||||
);
|
||||
return Promise.all(
|
||||
found.map((collection) =>
|
||||
presentCollection(ctx, collection, { includeData: false })
|
||||
)
|
||||
);
|
||||
},
|
||||
[]
|
||||
),
|
||||
]);
|
||||
|
||||
Reference in new issue
Block a user