using System.Net; using System.Net.Http.Headers; using Azaion.Missions.E2E.Fixtures; using Azaion.Missions.E2E.Helpers; using Xunit; namespace Azaion.Missions.E2E.Tests.Waypoints; /// /// FT-N-07 — waypoint operation against a missing mission must surface as /// a 404 with the standard envelope (results_report.md row 4.1 / AC-4.2). /// [Collection("Waypoints")] [Trait("Category", "Blackbox")] [Trait("db_access", "seed-or-assert-only")] public sealed class NegativeTests : TestBase, IClassFixture { [Fact] [Trait("Traces", "AC-4.2")] [Trait("max_ms", "2000")] [Trait("carry_forward", "AC-4.2")] public async Task FT_N_07_waypoint_list_against_missing_mission_returns_empty_array_today() { // CARRY-FORWARD: spec says 404 with problem envelope (AZ-580 AC-7 // and results_report.md row 4.1). Today the SUT // (WaypointService.GetWaypoints) does NOT validate parent existence // — it returns an empty list which the controller wraps as 200 []. Per // /autodev batch 2 user choice, this test asserts the CODE shape. // Flip to 404+envelope expectation when the divergence is closed. // Arrange DbResetFixture.ResetDatabase(TestEnvironment.DbSideChannel); var token = await Tokens.MintDefaultAsync(); var randomMissionId = Guid.NewGuid(); // Act using var http = new HttpRequestMessage( HttpMethod.Get, $"/missions/{randomMissionId}/waypoints"); http.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token.Jwt); using var response = await Missions.SendAsync(http); // Assert await HttpAssertions.AssertStatusAsync(response, HttpStatusCode.OK); var raw = await response.Content.ReadAsStringAsync(); Assert.Equal("[]", raw.Trim()); } }