fix: removed channel from user e2e tests
This commit is contained in:
@@ -2,14 +2,7 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from
|
||||
import { init, TestPlatform } from "../setup";
|
||||
import { TestDbService } from "../utils.prepare.db";
|
||||
import { v1 as uuidv1 } from "uuid";
|
||||
import { CompanyLimitsEnum, UserObject } from "../../../src/services/user/web/types";
|
||||
import { ChannelVisibility } from "../../../src/services/channels/types";
|
||||
import gr from "../../../src/services/global-resolver";
|
||||
import { ResourceListResponse, Workspace } from "../../../src/utils/types";
|
||||
import { ChannelSaveOptions } from "../../../src/services/channels/web/types";
|
||||
import { createMessage, e2e_createThread } from "../messages/utils";
|
||||
import { deserialize } from "class-transformer";
|
||||
import { get as getChannelUtils } from "../channels/utils";
|
||||
import { CompanyLimitsEnum } from "../../../src/services/user/web/types";
|
||||
|
||||
describe("The /users API", () => {
|
||||
const url = "/internal/services/users/v1";
|
||||
@@ -557,89 +550,4 @@ describe("The /users API", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Recent contacts", () => {
|
||||
it("should return list of recent contacts of user", async done => {
|
||||
// api = new Api(platform);
|
||||
const channelUtils = getChannelUtils(platform);
|
||||
|
||||
await testDbService.createDefault(platform);
|
||||
|
||||
const channels = [];
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
// const channel = channelUtils.getChannel();
|
||||
const directChannelIn = channelUtils.getDirectChannel();
|
||||
|
||||
const nextUser = await testDbService.createUser(
|
||||
[{ id: platform.workspace.workspace_id, company_id: platform.workspace.company_id }],
|
||||
{ firstName: "FirstName" + i, lastName: "LastName" + i },
|
||||
);
|
||||
|
||||
const members = [platform.currentUser.id, nextUser.id];
|
||||
const directWorkspace: Workspace = {
|
||||
company_id: platform.workspace.company_id,
|
||||
workspace_id: ChannelVisibility.DIRECT,
|
||||
};
|
||||
await Promise.all([
|
||||
// gr.services.channels.channels.save(channel, {}, getContext()),
|
||||
gr.services.channels.channels.save<ChannelSaveOptions>(
|
||||
directChannelIn,
|
||||
{
|
||||
members,
|
||||
},
|
||||
{
|
||||
...{
|
||||
workspace: platform.workspace,
|
||||
user: platform.currentUser,
|
||||
},
|
||||
...{ workspace: directWorkspace },
|
||||
},
|
||||
),
|
||||
]);
|
||||
channels.push(directChannelIn);
|
||||
}
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
|
||||
await e2e_createThread(
|
||||
platform,
|
||||
[
|
||||
{
|
||||
company_id: platform.workspace.company_id,
|
||||
created_at: 0,
|
||||
created_by: "",
|
||||
id: channels[2].id,
|
||||
type: "channel",
|
||||
workspace_id: "direct",
|
||||
},
|
||||
],
|
||||
createMessage({ text: "Some message" }),
|
||||
);
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
|
||||
const jwtToken = await platform.auth.getJWTToken();
|
||||
|
||||
const response = await platform.app.inject({
|
||||
method: "GET",
|
||||
url: `${url}/companies/${platform.workspace.company_id}/users/recent`,
|
||||
headers: {
|
||||
authorization: `Bearer ${jwtToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.statusCode).toBe(200);
|
||||
|
||||
const result: ResourceListResponse<UserObject> = deserialize(
|
||||
ResourceListResponse,
|
||||
response.body,
|
||||
);
|
||||
|
||||
expect(result.resources.length).toEqual(5);
|
||||
expect(result.resources[0].first_name).toEqual("FirstName2");
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,8 +15,6 @@ import Repository from "../../src/core/platform/services/database/services/orm/r
|
||||
import Device from "../../src/services/user/entities/device";
|
||||
|
||||
import gr from "../../src/services/global-resolver";
|
||||
import { Channel } from "../../src/services/channels/entities";
|
||||
import { get as getChannelUtils } from "./channels/utils";
|
||||
|
||||
export type uuid = string;
|
||||
|
||||
@@ -259,15 +257,4 @@ export class TestDbService {
|
||||
defaultWorkspace() {
|
||||
return this.workspaces[0].workspace;
|
||||
}
|
||||
|
||||
async createChannel(userId): Promise<Channel> {
|
||||
const channelUtils = getChannelUtils(this.testPlatform);
|
||||
const channel = channelUtils.getChannel(userId);
|
||||
const creationResult = await gr.services.channels.channels.save(
|
||||
channel,
|
||||
{},
|
||||
channelUtils.getContext({ id: userId }),
|
||||
);
|
||||
return creationResult.entity;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user