chore: More flakey test improvements (#5801)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import randomstring from "randomstring";
|
||||
import { IntegrationService } from "@shared/types";
|
||||
import env from "@server/env";
|
||||
import { IntegrationAuthentication, SearchQuery } from "@server/models";
|
||||
@@ -17,7 +18,7 @@ jest.mock("../slack", () => ({
|
||||
const server = getTestServer();
|
||||
|
||||
describe("#hooks.unfurl", () => {
|
||||
it("should return documents", async () => {
|
||||
it("should return documents with matching SSO user", async () => {
|
||||
const user = await buildUser();
|
||||
const document = await buildDocument({
|
||||
userId: user.id,
|
||||
@@ -28,18 +29,19 @@ describe("#hooks.unfurl", () => {
|
||||
service: IntegrationService.Slack,
|
||||
userId: user.id,
|
||||
teamId: user.teamId,
|
||||
token: "",
|
||||
token: randomstring.generate(32),
|
||||
});
|
||||
|
||||
const res = await server.post("/api/hooks.unfurl", {
|
||||
body: {
|
||||
token: env.SLACK_VERIFICATION_TOKEN,
|
||||
team_id: "TXXXXXXXX",
|
||||
api_app_id: "AXXXXXXXXX",
|
||||
team_id: `T${randomstring.generate(8)}`,
|
||||
api_app_id: `A${randomstring.generate(8)}`,
|
||||
event: {
|
||||
type: "link_shared",
|
||||
channel: "Cxxxxxx",
|
||||
channel: `C${randomstring.generate(8)}`,
|
||||
user: user.authentications[0].providerId,
|
||||
message_ts: "123456789.9875",
|
||||
message_ts: randomstring.generate(12),
|
||||
links: [
|
||||
{
|
||||
domain: "getoutline.com",
|
||||
|
||||
@@ -70,20 +70,31 @@ router.post(
|
||||
model: UserAuthentication,
|
||||
as: "authentications",
|
||||
required: true,
|
||||
separate: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
if (!user) {
|
||||
Logger.debug("plugins", "No user found for Slack user ID", {
|
||||
providerId: event.user,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const auth = await IntegrationAuthentication.findOne({
|
||||
where: {
|
||||
service: IntegrationService.Slack,
|
||||
teamId: user.teamId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!auth) {
|
||||
Logger.debug(
|
||||
"plugins",
|
||||
"No Slack integration authentication found for team",
|
||||
{
|
||||
teamId: user.teamId,
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
// get content for unfurled links
|
||||
|
||||
Reference in New Issue
Block a user