Add route smoke tests
This commit is contained in:
1 parent
5e9146f2cb
commit
f24a4e73a2
4 files changed
+98
No files matched your search
@@ -0,0 +1,65 @@
|
||||
using System.Net;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
|
||||
namespace Elternbeirat.Web.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Smoke tests: every known route must return 200, unknown routes must return
|
||||
/// 404. This catches broken content files, renamed slugs or routing regressions
|
||||
/// before a deploy.
|
||||
/// </summary>
|
||||
public sealed class RouteSmokeTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
{
|
||||
private readonly WebApplicationFactory<Program> _factory;
|
||||
|
||||
public RouteSmokeTests(WebApplicationFactory<Program> factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Every route that a visitor can reach through the navigation, the FAQ hub
|
||||
/// or the news section.
|
||||
/// </summary>
|
||||
public static TheoryData<string> KnownRoutes =>
|
||||
[
|
||||
"/",
|
||||
"/vorstandsteam",
|
||||
"/foerderverein",
|
||||
"/faq",
|
||||
"/faq-mensa",
|
||||
"/faq-schliessfach",
|
||||
"/faq-elterneuro",
|
||||
"/faq-elternarbeit",
|
||||
"/downloads",
|
||||
"/kontakt",
|
||||
"/impressum",
|
||||
"/datenschutz",
|
||||
"/beitraege",
|
||||
"/beitraege/neuer-vorstand-gewaehlt",
|
||||
"/beitraege/neue-sporthalle-eroeffnet",
|
||||
];
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(KnownRoutes))]
|
||||
public async Task Known_route_returns_200(string route)
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
var response = await client.GetAsync(route);
|
||||
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/gibt-es-nicht")]
|
||||
[InlineData("/beitraege/gibt-es-nicht")]
|
||||
public async Task Unknown_route_returns_404(string route)
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
var response = await client.GetAsync(route);
|
||||
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user