Skip to content

Commit

Permalink
Remove cleanup from tests, remove tests from tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz committed Nov 22, 2023
1 parent 361e36f commit d7670df
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 127 deletions.
14 changes: 2 additions & 12 deletions __tests__/block-lists.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { BlockList, StreamClient } from "../";
import { v4 as uuidv4 } from "uuid";
import { createTestClient } from "./create-test-client";
import { StreamClient } from "../src/StreamClient";
import { BlockList } from "../src/gen/chat";

describe("block lists CRUD API", () => {
let client: StreamClient;
Expand Down Expand Up @@ -55,15 +56,4 @@ describe("block lists CRUD API", () => {
});
expect(response).toBeDefined();
});

afterAll(async () => {
const blockLists = (await client.chat.listBlockLists()).blocklists;
const customBlockLists = blockLists.filter((b) =>
b.name.startsWith("streamnodetest-F1")
);

await Promise.all(
customBlockLists.map((b) => client.chat.deleteBlockList({ name: b.name }))
);
});
});
4 changes: 3 additions & 1 deletion __tests__/call-members.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { beforeAll, describe, expect, it } from "vitest";
import { v4 as uuidv4 } from "uuid";
import { StreamCall, StreamClient, VideoOwnCapability } from "../";
import { createTestClient } from "./create-test-client";
import { StreamCall } from "../src/StreamCall";
import { StreamClient } from "../src/StreamClient";
import { VideoOwnCapability } from "../src/gen/video";

describe("call members API", () => {
let client: StreamClient;
Expand Down
21 changes: 5 additions & 16 deletions __tests__/call-types.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { beforeAll, describe, expect, it } from "vitest";
import { v4 as uuidv4 } from "uuid";
import { createTestClient } from "./create-test-client";
import { StreamClient } from "../src/StreamClient";
import {
StreamClient,
VideoLayoutSettingsNameEnum,
VideoOwnCapability,
VideoRecordSettingsRequestModeEnum,
VideoRecordSettingsRequestQualityEnum,
} from "../";
import { createTestClient } from "./create-test-client";
VideoLayoutSettingsNameEnum,
} from "../src/gen/video";

describe("call types CRUD API", () => {
let client: StreamClient;
Expand Down Expand Up @@ -162,15 +162,4 @@ describe("call types CRUD API", () => {
client.video.getCallType({ name: callTypeName })
).rejects.toThrowError();
});

afterAll(async () => {
const callTypes = (await client.video.listCallTypes()).call_types;
const customCallTypes = Object.keys(callTypes).filter(
(t) => t.startsWith("streamnodetest") || t.startsWith("calltype")
);

await Promise.all(
customCallTypes.map((t) => client.video.deleteCallType({ name: t }))
);
});
});
10 changes: 4 additions & 6 deletions __tests__/call.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { beforeAll, describe, expect, it } from "vitest";
import { v4 as uuidv4 } from "uuid";
import { createTestClient } from "./create-test-client";
import { StreamCall } from "../src/StreamCall";
import { StreamClient } from "../src/StreamClient";
import {
StreamClient,
StreamCall,
VideoRecordSettingsRequestModeEnum,
VideoRecordSettingsRequestQualityEnum,
} from "../";
import { createTestClient } from "./create-test-client";

const apiKey = process.env.STREAM_API_KEY!;
} from "../src/gen/video";

describe("call API", () => {
let client: StreamClient;
Expand Down
21 changes: 3 additions & 18 deletions __tests__/channel-types.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { beforeAll, describe, expect, it } from "vitest";
import { v4 as uuidv4 } from "uuid";
import { CreateChannelTypeRequestAutomodEnum, StreamClient } from "../";
import { createTestClient } from "./create-test-client";
import { CreateChannelTypeRequestAutomodEnum } from "../src/gen/chat/models";
import { StreamClient } from "../src/StreamClient";

describe("channel types CRUD API", () => {
let client: StreamClient;
Expand Down Expand Up @@ -45,20 +46,4 @@ describe("channel types CRUD API", () => {
const response = await client.chat.deleteChannelType({ name: channelType });
expect(response).toBeDefined();
});

// TODO: why does this doesn't work?
// afterAll(async () => {
// await new Promise((resolve) => setTimeout(resolve, 5000));

// const channelTypes = (await client.chat.listChannelTypes()).channel_types;
// const customChannelTypes = Object.keys(channelTypes).filter((type) =>
// type.startsWith("streamnodetest")
// );

// await Promise.all(
// customChannelTypes.map((t) =>
// client.chat.deleteChannelType({ name: channelType })
// )
// );
// });
});
19 changes: 3 additions & 16 deletions __tests__/channel.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { beforeAll, describe, expect, it } from "vitest";
import { v4 as uuidv4 } from "uuid";
import { StreamClient, StreamChannel } from "../";
import { createTestClient } from "./create-test-client";
import { StreamClient } from "../src/StreamClient";
import { StreamChannel } from "../src/StreamChannel";

describe("channel API", () => {
let client: StreamClient;
Expand Down Expand Up @@ -137,18 +138,4 @@ describe("channel API", () => {
it("delete", async () => {
await channel.delete();
});

afterAll(async () => {
const channels = (
await client.chat.queryChannels({
filter_conditions: { name: { $autocomplete: "streamnodetest" } },
})
).channels;

await Promise.all(
channels.map((c) =>
client.chat.channel(c.channel!.type, c.channel!.id).delete()
)
);
});
});
15 changes: 2 additions & 13 deletions __tests__/command.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { beforeAll, describe, expect, it } from "vitest";
import { v4 as uuidv4 } from "uuid";
import { StreamClient } from "../";
import { createTestClient } from "./create-test-client";
import { StreamClient } from "../src/StreamClient";

describe("commands CRUD API", () => {
let client: StreamClient;
Expand Down Expand Up @@ -45,15 +45,4 @@ describe("commands CRUD API", () => {
client.chat.getCommand({ name: commandName })
).rejects.toThrowError();
});

afterAll(async () => {
const commands = (await client.chat.listCommands()).commands;
const customCommands = commands.filter((c) =>
c.name.startsWith("stream-node-test-command")
);

await Promise.all(
customCommands.map((c) => client.chat.deleteCommand({ name: c.name }))
);
});
});
8 changes: 4 additions & 4 deletions __tests__/devices-push.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { beforeAll, describe, expect, it } from "vitest";
import { v4 as uuidv4 } from "uuid";
import {
CreateDeviceRequest,
CreateDeviceRequestPushProviderEnum,
StreamClient,
} from "..";
import { v4 as uuidv4 } from "uuid";
import { PushProviderRequest } from "../src/gen/chat";
PushProviderRequest,
} from "../src/gen/chat";
import { createTestClient } from "./create-test-client";
import { StreamClient } from "../src/StreamClient";

describe("devices and push", () => {
let client: StreamClient;
Expand Down
8 changes: 3 additions & 5 deletions __tests__/messages.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import "dotenv/config";
import { beforeAll, describe, expect, it } from "vitest";
import {
StreamClient,
StreamChannel,
TranslateMessageRequestLanguageEnum,
} from "../";
import { createTestClient } from "./create-test-client";
import { StreamChannel } from "../src/StreamChannel";
import { StreamClient } from "../src/StreamClient";
import { TranslateMessageRequestLanguageEnum } from "../src/gen/chat";

describe("messages API", () => {
let client: StreamClient;
Expand Down
17 changes: 4 additions & 13 deletions __tests__/permissions-app-settings.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { CreateRoleRequest, StreamClient, VideoOwnCapability } from "..";
import { beforeAll, describe, expect, it } from "vitest";
import { v4 as uuidv4 } from "uuid";
import { createTestClient } from "./create-test-client";
import { StreamClient } from "../src/StreamClient";
import { CreateRoleRequest } from "../src/gen/chat";
import { VideoOwnCapability } from "../src/gen/video";

describe("permissions and app settings API", () => {
let client: StreamClient;
Expand Down Expand Up @@ -84,15 +86,4 @@ describe("permissions and app settings API", () => {

expect(response.web).toBeDefined();
});

afterAll(async () => {
const roles = (await client.listRoles()).roles;
const customRoles = roles.filter((r) =>
r.name.startsWith("streamnodetest")
);

await Promise.all(
customRoles.map((r) => client.deleteRole({ name: r.name }))
);
});
});
2 changes: 1 addition & 1 deletion __tests__/user-compat.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeAll, describe, expect, it } from "vitest";
import { StreamClient } from "../";
import { v4 as uuidv4 } from "uuid";
import { createTestClient } from "./create-test-client";
import { StreamClient } from "../src/StreamClient";

describe("user-video compatibility API", () => {
let client: StreamClient;
Expand Down
24 changes: 3 additions & 21 deletions __tests__/users.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import {
DeleteUsersRequestUserEnum,
StreamClient,
UserObjectRequest,
} from "../";
import { beforeAll, describe, expect, it } from "vitest";
import { v4 as uuidv4 } from "uuid";
import { createTestClient } from "./create-test-client";
import { StreamClient } from "../src/StreamClient";
import { UserObjectRequest } from "../src/gen/chat";

describe("user API", () => {
let client: StreamClient;
Expand Down Expand Up @@ -195,19 +192,4 @@ describe("user API", () => {

expect(response).toBeDefined();
});

afterAll(async () => {
const users = (
await client.queryUsers({
filter_conditions: { name: { $autocomplete: "streamnodetest" } },
})
).users;

if (users.length > 0) {
await client.deleteUsers({
user_ids: users.map((u) => u.id),
user: DeleteUsersRequestUserEnum.HARD,
});
}
});
});
Loading

0 comments on commit d7670df

Please sign in to comment.