Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

namespace Execution_UI.Tests.IntegrationTests
{
/// <summary>
/// Integration tests for the Execution_UI application.
/// These tests verify end-to-end HTTP requests and responses.
/// </summary>
public class ApplicationTests : IClassFixture<WebApplicationFactory<Program>>
{
private readonly WebApplicationFactory<Program> _factory;
Expand All @@ -15,7 +19,7 @@ public ApplicationTests(WebApplicationFactory<Program> factory)
}

[Fact]
public async Task Get_IndexPage_ReturnsSuccessStatusCode()
public async Task Get_IndexPage_ReturnsOkStatusCode()
{
// Arrange
var client = _factory.CreateClient();
Expand All @@ -24,30 +28,77 @@ public async Task Get_IndexPage_ReturnsSuccessStatusCode()
var response = await client.GetAsync("/");

// Assert
Assert.True(response.IsSuccessStatusCode || response.StatusCode == HttpStatusCode.OK);
Assert.True(response.IsSuccessStatusCode, $"Expected success status code, got {response.StatusCode}");
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}

[Fact]
public async Task Get_PrivacyPage_ReturnsSuccessStatusCode()
public async Task Get_IndexPage_ReturnsHtmlContent()
{
// Arrange
var client = _factory.CreateClient();

// Act
var response = await client.GetAsync("/");
var content = await response.Content.ReadAsStringAsync();

// Assert
Assert.True(response.IsSuccessStatusCode);
Assert.NotEmpty(content);
Assert.True(content.Contains("<!DOCTYPE") || content.Contains("<html"), "Response should contain HTML content");
}

[Fact]
public async Task Get_IndexPage_ReturnsHtmlContentType()
{
// Arrange
var client = _factory.CreateClient();

// Act
var response = await client.GetAsync("/");

// Assert
Assert.NotNull(response.Content.Headers.ContentType);
Assert.Contains("text/html", response.Content.Headers.ContentType.MediaType);
}

[Fact]
public async Task Get_PrivacyPage_ReturnsOkStatusCode()
{
// Arrange
var client = _factory.CreateClient();

// Act
var response = await client.GetAsync("/Privacy");

// Assert
Assert.True(response.IsSuccessStatusCode, $"Expected success status code, got {response.StatusCode}");
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}

[Fact]
public async Task Get_PrivacyPage_ReturnsHtmlContent()
{
// Arrange
var client = _factory.CreateClient();

// Act
var response = await client.GetAsync("/Privacy");
var content = await response.Content.ReadAsStringAsync();

// Assert
Assert.True(response.IsSuccessStatusCode || response.StatusCode == HttpStatusCode.OK);
Assert.True(response.IsSuccessStatusCode);
Assert.NotEmpty(content);
}

[Fact]
public async Task Get_CastPage_ReturnsSuccessStatusCode()
public async Task Get_CastPage_ReturnsResponse()
{
// Arrange
var client = _factory.CreateClient();

// Act
var response = await client.GetAsync("/cast_new");
var response = await client.GetAsync("/cast");

// Assert
// Note: May return 500 if RabbitMQ/MySQL are not configured,
Expand All @@ -62,25 +113,31 @@ public async Task Get_InvalidPage_ReturnsNotFound()
var client = _factory.CreateClient();

// Act
var response = await client.GetAsync("/invalid-page-that-does-not-exist");
var response = await client.GetAsync("/invalid-page-that-does-not-exist-12345");

// Assert
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}

[Fact]
public async Task Get_IndexPage_ReturnsHtmlContent()
public async Task Get_RootPath_DoesNotThrow()
{
// Arrange
var client = _factory.CreateClient();

// Act
// Act & Assert - Should not throw an exception
var response = await client.GetAsync("/");
var content = await response.Content.ReadAsStringAsync();
Assert.NotNull(response);
}

[Fact]
public async Task ApplicationFactory_CanCreateClient()
{
// Arrange & Act
var client = _factory.CreateClient();

// Assert
Assert.True(response.IsSuccessStatusCode);
Assert.True(content.Contains("<!DOCTYPE") || content.Contains("<html"));
Assert.NotNull(client);
}
}
}
Loading
Loading