diff --git a/packages/reacord/test/action-row.test.tsx b/packages/reacord/test/action-row.test.tsx index 26b6369..fd373a4 100644 --- a/packages/reacord/test/action-row.test.tsx +++ b/packages/reacord/test/action-row.test.tsx @@ -1,41 +1,112 @@ +import { raise } from "@reacord/helpers/raise" +import type { TextBasedChannel } from "discord.js" +import { + CategoryChannel, + ChannelType, + ComponentType, + GatewayIntentBits, +} from "discord.js" import React from "react" -import { test } from "vitest" -import { ActionRow, Button, Select } from "../library/main" -import { ReacordTester } from "./test-adapter" +import { beforeAll, expect, test } from "vitest" +import { createDiscordClient } from "../library/create-discord-client" +import { + ActionRow, + Button, + Option, + ReacordClient, + Select, +} from "../library/main" +import { testEnv } from "./test-env" -const testing = new ReacordTester() +let channel: TextBasedChannel +beforeAll(async () => { + const client = await createDiscordClient(testEnv.TEST_BOT_TOKEN, { + intents: GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages, + }) + + const category = + client.channels.cache.get(testEnv.TEST_CATEGORY_ID) ?? + (await client.channels.fetch(testEnv.TEST_CATEGORY_ID)) + + if (!(category instanceof CategoryChannel)) { + throw new TypeError("Category channel not found") + } + + const channelName = "test-channel" + + let existing = category.children.cache.find((the) => the.name === channelName) + if (!existing || !existing.isTextBased()) { + existing = await category.children.create({ + type: ChannelType.GuildText, + name: channelName, + }) + } + channel = existing + + for (const [, message] of await channel.messages.fetch()) { + await message.delete() + } +}) test("action row", async () => { - await testing.assertRender( + const reacord = new ReacordClient({ + token: testEnv.TEST_BOT_TOKEN, + }) + + reacord.send( + channel.id, <>