From 28f26e45fbcbf9b9cc326aa2bfb2302ca417fb42 Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 27 Feb 2026 17:52:26 +0200 Subject: [PATCH] Add tests for forwarded messages --- .../Infra/ChannelIds.cs | 4 ++- .../Specs/HtmlForwardSpecs.cs | 27 +++++++++++++++++ .../Specs/JsonForwardSpecs.cs | 30 +++++++++++++++++++ .../Specs/PlainTextForwardSpecs.cs | 21 +++++++++++++ 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 DiscordChatExporter.Cli.Tests/Specs/HtmlForwardSpecs.cs create mode 100644 DiscordChatExporter.Cli.Tests/Specs/JsonForwardSpecs.cs create mode 100644 DiscordChatExporter.Cli.Tests/Specs/PlainTextForwardSpecs.cs diff --git a/DiscordChatExporter.Cli.Tests/Infra/ChannelIds.cs b/DiscordChatExporter.Cli.Tests/Infra/ChannelIds.cs index b3f92fe3..e380e136 100644 --- a/DiscordChatExporter.Cli.Tests/Infra/ChannelIds.cs +++ b/DiscordChatExporter.Cli.Tests/Infra/ChannelIds.cs @@ -1,4 +1,4 @@ -using DiscordChatExporter.Core.Discord; +using DiscordChatExporter.Core.Discord; namespace DiscordChatExporter.Cli.Tests.Infra; @@ -15,6 +15,8 @@ public static class ChannelIds public static Snowflake GroupingTestCases { get; } = Snowflake.Parse("992092091545034842"); public static Snowflake FilterTestCases { get; } = Snowflake.Parse("866744075033641020"); + + public static Snowflake ForwardTestCases { get; } = Snowflake.Parse("1455202357204877477"); public static Snowflake MarkdownTestCases { get; } = Snowflake.Parse("866459526819348521"); diff --git a/DiscordChatExporter.Cli.Tests/Specs/HtmlForwardSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/HtmlForwardSpecs.cs new file mode 100644 index 00000000..1322008c --- /dev/null +++ b/DiscordChatExporter.Cli.Tests/Specs/HtmlForwardSpecs.cs @@ -0,0 +1,27 @@ +using System.Threading.Tasks; +using AngleSharp.Dom; +using DiscordChatExporter.Cli.Tests.Infra; +using DiscordChatExporter.Core.Discord; +using FluentAssertions; +using Xunit; + +namespace DiscordChatExporter.Cli.Tests.Specs; + +public class HtmlForwardSpecs +{ + [Fact] + public async Task I_can_export_a_channel_that_contains_a_forwarded_message() + { + // Act + var message = await ExportWrapper.GetMessageAsHtmlAsync( + ChannelIds.ForwardTestCases, + Snowflake.Parse("1455202427115536514") + ); + + // Assert + message + .Text() + .Should() + .ContainAll("Forwarded", @"¯\_(ツ)_/¯", "December 29, 2025"); + } +} diff --git a/DiscordChatExporter.Cli.Tests/Specs/JsonForwardSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/JsonForwardSpecs.cs new file mode 100644 index 00000000..ca2ddd4e --- /dev/null +++ b/DiscordChatExporter.Cli.Tests/Specs/JsonForwardSpecs.cs @@ -0,0 +1,30 @@ +using System.Threading.Tasks; +using DiscordChatExporter.Cli.Tests.Infra; +using DiscordChatExporter.Core.Discord; +using FluentAssertions; +using Xunit; + +namespace DiscordChatExporter.Cli.Tests.Specs; + +public class JsonForwardSpecs +{ + [Fact] + public async Task I_can_export_a_channel_that_contains_a_forwarded_message() + { + // Act + var message = await ExportWrapper.GetMessageAsJsonAsync( + ChannelIds.ForwardTestCases, + Snowflake.Parse("1455202427115536514") + ); + + // Assert + var reference = message.GetProperty("reference"); + reference.GetProperty("type").GetString().Should().Be("Forward"); + reference.GetProperty("guildId").GetString().Should().Be("869237470565392384"); + + var forwardedMessage = message.GetProperty("forwardedMessage"); + forwardedMessage.GetProperty("content").GetString().Should().Contain(@"¯\_(ツ)_/¯"); + forwardedMessage.GetProperty("timestamp").GetString().Should().StartWith("2025-12-29"); + } +} + diff --git a/DiscordChatExporter.Cli.Tests/Specs/PlainTextForwardSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/PlainTextForwardSpecs.cs new file mode 100644 index 00000000..7d543a8d --- /dev/null +++ b/DiscordChatExporter.Cli.Tests/Specs/PlainTextForwardSpecs.cs @@ -0,0 +1,21 @@ +using System.Threading.Tasks; +using DiscordChatExporter.Cli.Tests.Infra; +using FluentAssertions; +using Xunit; + +namespace DiscordChatExporter.Cli.Tests.Specs; + +public class PlainTextForwardSpecs +{ + [Fact] + public async Task I_can_export_a_channel_that_contains_a_forwarded_message() + { + // Act + var document = await ExportWrapper.ExportAsPlainTextAsync(ChannelIds.ForwardTestCases); + + // Assert + document + .Should() + .ContainAll("{Forwarded Message}", @"¯\_(ツ)_/¯", "December 29, 2025"); + } +}