aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Server.Integration.Tests
diff options
context:
space:
mode:
authorChris Blake <1481712+chrisb92@users.noreply.github.com>2023-02-01 18:17:18 +0000
committerGitHub <noreply@github.com>2023-02-01 11:17:18 -0700
commitad5b83781a7d3d2ddbd2903890031257952a05f7 (patch)
treee14e16b00e0213de9900b13847383b64dc432638 /tests/Jellyfin.Server.Integration.Tests
parent992b460912f3100f126bc4db0fe042fd4aefee7c (diff)
Add 404 response to MarkPlayedItem/MarkUnplayedItem (#9211)
Fixes https://github.com/jellyfin/jellyfin/issues/9120
Diffstat (limited to 'tests/Jellyfin.Server.Integration.Tests')
-rw-r--r--tests/Jellyfin.Server.Integration.Tests/Controllers/PlaystateControllerTests.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/Jellyfin.Server.Integration.Tests/Controllers/PlaystateControllerTests.cs b/tests/Jellyfin.Server.Integration.Tests/Controllers/PlaystateControllerTests.cs
new file mode 100644
index 000000000..f8f5fecec
--- /dev/null
+++ b/tests/Jellyfin.Server.Integration.Tests/Controllers/PlaystateControllerTests.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+using Xunit;
+using Xunit.Priority;
+
+namespace Jellyfin.Server.Integration.Tests.Controllers;
+
+[TestCaseOrderer(PriorityOrderer.Name, PriorityOrderer.Assembly)]
+public class PlaystateControllerTests : IClassFixture<JellyfinApplicationFactory>
+{
+ private readonly JellyfinApplicationFactory _factory;
+ private static readonly Guid _testUserId = Guid.NewGuid();
+ private static readonly Guid _testItemId = Guid.NewGuid();
+ private static string? _accessToken;
+
+ public PlaystateControllerTests(JellyfinApplicationFactory factory)
+ {
+ _factory = factory;
+ }
+
+ private Task<HttpResponseMessage> DeleteUserPlayedItems(HttpClient httpClient, Guid userId, Guid itemId)
+ => httpClient.DeleteAsync($"Users/{userId}/PlayedItems/{itemId}");
+
+ private Task<HttpResponseMessage> PostUserPlayedItems(HttpClient httpClient, Guid userId, Guid itemId)
+ => httpClient.PostAsync($"Users/{userId}/PlayedItems/{itemId}", null);
+
+ [Fact]
+ [Priority(0)]
+ public async Task DeleteMarkUnplayedItem_DoesNotExist_NotFound()
+ {
+ var client = _factory.CreateClient();
+ client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
+
+ using var response = await DeleteUserPlayedItems(client, _testUserId, _testItemId).ConfigureAwait(false);
+ Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
+ }
+
+ [Fact]
+ [Priority(0)]
+ public async Task PostMarkPlayedItem_DoesNotExist_NotFound()
+ {
+ var client = _factory.CreateClient();
+ client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
+
+ using var response = await PostUserPlayedItems(client, _testUserId, _testItemId).ConfigureAwait(false);
+ Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
+ }
+}