diff options
Diffstat (limited to 'tests/Jellyfin.Server.Integration.Tests/Controllers/PlaystateControllerTests.cs')
| -rw-r--r-- | tests/Jellyfin.Server.Integration.Tests/Controllers/PlaystateControllerTests.cs | 50 |
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); + } +} |
