Render server cross-posts properly

Closes #633
This commit is contained in:
Tyrrrz 2023-02-09 18:44:24 +02:00
parent 93799eb231
commit 049338009e
22 changed files with 96 additions and 43 deletions

View file

@ -0,0 +1,8 @@
using Xunit;
namespace DiscordChatExporter.Cli.Tests.Fixtures;
[CollectionDefinition(nameof(ExportWrapperCollection))]
public class ExportWrapperCollection : ICollectionFixture<ExportWrapperFixture>
{
}

View file

@ -6,7 +6,8 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
public class CsvContentSpecs : IClassFixture<ExportWrapperFixture>
[Collection(nameof(ExportWrapperCollection))]
public class CsvContentSpecs
{
private readonly ExportWrapperFixture _exportWrapper;

View file

@ -15,6 +15,7 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
[Collection(nameof(ExportWrapperCollection))]
public class DateRangeSpecs : IClassFixture<TempOutputFixture>
{
private readonly TempOutputFixture _tempOutput;

View file

@ -14,6 +14,7 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
[Collection(nameof(ExportWrapperCollection))]
public class FilterSpecs : IClassFixture<TempOutputFixture>
{
private readonly TempOutputFixture _tempOutput;

View file

@ -9,7 +9,8 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
public class HtmlAttachmentSpecs : IClassFixture<ExportWrapperFixture>
[Collection(nameof(ExportWrapperCollection))]
public class HtmlAttachmentSpecs
{
private readonly ExportWrapperFixture _exportWrapper;

View file

@ -3,12 +3,14 @@ using System.Threading.Tasks;
using AngleSharp.Dom;
using DiscordChatExporter.Cli.Tests.Fixtures;
using DiscordChatExporter.Cli.Tests.TestData;
using DiscordChatExporter.Core.Discord;
using FluentAssertions;
using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
public class HtmlContentSpecs : IClassFixture<ExportWrapperFixture>
[Collection(nameof(ExportWrapperCollection))]
public class HtmlContentSpecs
{
private readonly ExportWrapperFixture _exportWrapper;
@ -46,4 +48,21 @@ public class HtmlContentSpecs : IClassFixture<ExportWrapperFixture>
"Yeet"
);
}
[Fact]
public async Task Messages_cross_posted_from_other_guilds_are_rendered_with_the_server_tag()
{
// https://github.com/Tyrrrz/DiscordChatExporter/issues/633
// Act
var message = await _exportWrapper.GetMessageAsHtmlAsync(
ChannelIds.ReplyTestCases,
Snowflake.Parse("1072165330853576876")
);
// Assert
message.Text().Should().Contain("This is a test message from an announcement channel on another server");
message.Text().Should().Contain("SERVER");
message.QuerySelector(".chatlog__reply-link").Should().BeNull();
}
}

View file

@ -9,7 +9,8 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
public class HtmlEmbedSpecs : IClassFixture<ExportWrapperFixture>
[Collection(nameof(ExportWrapperCollection))]
public class HtmlEmbedSpecs
{
private readonly ExportWrapperFixture _exportWrapper;

View file

@ -13,6 +13,7 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
[Collection(nameof(ExportWrapperCollection))]
public class HtmlGroupingSpecs : IClassFixture<TempOutputFixture>
{
private readonly TempOutputFixture _tempOutput;

View file

@ -8,7 +8,8 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
public class HtmlMentionSpecs : IClassFixture<ExportWrapperFixture>
[Collection(nameof(ExportWrapperCollection))]
public class HtmlMentionSpecs
{
private readonly ExportWrapperFixture _exportWrapper;

View file

@ -8,7 +8,8 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
public class HtmlReplySpecs : IClassFixture<ExportWrapperFixture>
[Collection(nameof(ExportWrapperCollection))]
public class HtmlReplySpecs
{
private readonly ExportWrapperFixture _exportWrapper;
@ -28,7 +29,7 @@ public class HtmlReplySpecs : IClassFixture<ExportWrapperFixture>
// Assert
message.Text().Should().Contain("reply to original");
message.QuerySelector(".chatlog__reference-link")?.Text().Should().Contain("original");
message.QuerySelector(".chatlog__reply-link")?.Text().Should().Contain("original");
}
[Fact]
@ -44,7 +45,7 @@ public class HtmlReplySpecs : IClassFixture<ExportWrapperFixture>
// Assert
message.Text().Should().Contain("reply to deleted");
message.QuerySelector(".chatlog__reference-link")?.Text().Should().Contain(
message.QuerySelector(".chatlog__reply-link")?.Text().Should().Contain(
"Original message was deleted or could not be loaded."
);
}
@ -62,6 +63,6 @@ public class HtmlReplySpecs : IClassFixture<ExportWrapperFixture>
// Assert
message.Text().Should().Contain("reply to attachment");
message.QuerySelector(".chatlog__reference-link")?.Text().Should().Contain("Click to see attachment");
message.QuerySelector(".chatlog__reply-link")?.Text().Should().Contain("Click to see attachment");
}
}

View file

@ -7,7 +7,8 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
public class HtmlStickerSpecs : IClassFixture<ExportWrapperFixture>
[Collection(nameof(ExportWrapperCollection))]
public class HtmlStickerSpecs
{
private readonly ExportWrapperFixture _exportWrapper;

View file

@ -8,7 +8,8 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
public class JsonAttachmentSpecs : IClassFixture<ExportWrapperFixture>
[Collection(nameof(ExportWrapperCollection))]
public class JsonAttachmentSpecs
{
private readonly ExportWrapperFixture _exportWrapper;

View file

@ -7,7 +7,8 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
public class JsonContentSpecs : IClassFixture<ExportWrapperFixture>
[Collection(nameof(ExportWrapperCollection))]
public class JsonContentSpecs
{
private readonly ExportWrapperFixture _exportWrapper;

View file

@ -8,7 +8,8 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
public class JsonEmbedSpecs : IClassFixture<ExportWrapperFixture>
[Collection(nameof(ExportWrapperCollection))]
public class JsonEmbedSpecs
{
private readonly ExportWrapperFixture _exportWrapper;

View file

@ -8,7 +8,8 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
public class JsonMentionSpecs : IClassFixture<ExportWrapperFixture>
[Collection(nameof(ExportWrapperCollection))]
public class JsonMentionSpecs
{
private readonly ExportWrapperFixture _exportWrapper;

View file

@ -8,7 +8,8 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
public class JsonStickerSpecs : IClassFixture<ExportWrapperFixture>
[Collection(nameof(ExportWrapperCollection))]
public class JsonStickerSpecs
{
private readonly ExportWrapperFixture _exportWrapper;

View file

@ -12,6 +12,7 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
[Collection(nameof(ExportWrapperCollection))]
public class PartitioningSpecs : IClassFixture<TempOutputFixture>
{
private readonly TempOutputFixture _tempOutput;

View file

@ -6,7 +6,8 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
public class PlainTextContentSpecs : IClassFixture<ExportWrapperFixture>
[Collection(nameof(ExportWrapperCollection))]
public class PlainTextContentSpecs
{
private readonly ExportWrapperFixture _exportWrapper;

View file

@ -13,6 +13,7 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
[Collection(nameof(ExportWrapperCollection))]
public class SelfContainedSpecs : IClassFixture<TempOutputFixture>
{
private readonly TempOutputFixture _tempOutput;

View file

@ -1,5 +1,6 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"methodDisplayOptions": "all",
"methodDisplay": "method"
"methodDisplay": "method",
"parallelizeTestCollections": true
}