diff --git a/packages/rest/package.json b/packages/rest/package.json index 5db02088f..6103d4861 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -18,7 +18,7 @@ "test:unit-coverage": "c8 mocha --no-warnings 'tests/unit/**/*.spec.ts'", "test:unit": "c8 --r lcov mocha --no-warnings 'tests/unit/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js rest", "test:deno-unit": "swc tests --delete-dir-on-start --out-dir denoTestsDist && node ../../scripts/fixDenoTestExtension.js && deno test -A --import-map ../../denoImportMap.json denoTestsDist/unit", - "test:e2e": "c8 --r lcov mocha --no-warnings --jobs 1 --t 30000 'tests/e2e/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js rest", + "test:e2e": "c8 --r lcov mocha --exit --no-warnings --jobs 1 --t 30000 'tests/e2e/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js rest", "test:unit:watch": "mocha --no-warnings --watch --parallel 'tests/unit/**/*.spec.ts'", "test:type": "tsc --noEmit", "test:test-type": "tsc --project tsconfig.test.json" diff --git a/packages/rest/tests/e2e/message.spec.ts b/packages/rest/tests/e2e/message.spec.ts index 047dc94a3..68b42604d 100644 --- a/packages/rest/tests/e2e/message.spec.ts +++ b/packages/rest/tests/e2e/message.spec.ts @@ -1,4 +1,4 @@ -import { urlToBase64, processReactionString } from '@discordeno/utils' +import { processReactionString, urlToBase64 } from '@discordeno/utils' import { expect } from 'chai' import { describe, it } from 'mocha' import { e2ecache, rest } from './utils.js' @@ -128,6 +128,28 @@ describe('Manage reactions', async () => { }) }) +describe("Manage pins", () => { +it('Pin, get, and unpin messages', async () => { + const channel = await rest.createChannel(e2ecache.guild.id, { name: 'pinning' }) + const message = await rest.sendMessage(channel.id, { content: 'pin me' }) + const message2 = await rest.sendMessage(channel.id, { content: 'pin me 2' }) + + await rest.pinMessage(channel.id, message.id) + await rest.pinMessage(channel.id, message2.id, 'with a reason') + + const pins = await rest.getPinnedMessages(channel.id) + expect(pins.length).to.equal(2) + expect(pins.some(p => p.id === message.id)).to.equal(true) + + await rest.unpinMessage(channel.id, message.id) + await rest.unpinMessage(channel.id, message2.id, 'with a reason') + + const unpinned = await rest.getPinnedMessages(channel.id) + expect(unpinned.length).to.equal(0) +}) +}) + + describe('Rate limit manager testing', () => { it('Send 10 messages to 1 channel', async () => { const channel = await rest.createChannel(e2ecache.guild.id, { name: 'rate-limit-1' }) diff --git a/packages/rest/tests/e2e/misc.spec.ts b/packages/rest/tests/e2e/misc.spec.ts new file mode 100644 index 000000000..378659961 --- /dev/null +++ b/packages/rest/tests/e2e/misc.spec.ts @@ -0,0 +1,39 @@ +import { expect } from 'chai' +import { describe } from 'mocha' +import { e2ecache, rest } from './utils.js' + +describe('Typings', () => { + it('Trigger Typing Indication', async () => { + const channel = await rest.createChannel(e2ecache.guild.id, { name: 'typing' }) + await rest.triggerTypingIndicator(channel.id) + }) +}) + +describe('Commands', () => { + it('Upsert global commands', async () => { + await rest.upsertGlobalApplicationCommands([ + { + name: 'ping', + description: 'Ping the bot', + }, + ]) + + const cmds = await rest.getGlobalApplicationCommands() + const created = cmds.find((cmd) => cmd.name === 'ping' && cmd.description === 'Ping the bot') + expect(!!created?.id).to.be.true + + const made = await rest.getGlobalApplicationCommand(created!.id) + expect(created?.name).to.be.equal(made.name) + expect(created?.description).to.be.equal(made.description) + + const edited = await rest.editGlobalApplicationCommand(created!.id, { name: 'pong', description: 'edited description' }) + expect(edited.name).to.be.equal('pong') + expect(edited.name).to.not.be.equal(made.name) + expect(edited.description).to.be.equal('edited description') + expect(edited.description).to.not.be.equal(made.description) + + await rest.deleteGlobalApplicationCommand(created!.id) + + expect(rest.getGlobalApplicationCommand(created!.id)).to.throw + }) +})