Skip to content

Commit 304af98

Browse files
committed
Fix review findings: assert grant-access preconditions, remove unused import
- Add StatusCode assertions on all GrantAccessDto calls so test setup failures surface clearly instead of causing confusing Forbidden errors - Remove unused System.Collections.Concurrent import from SignalRTestHelper
1 parent 5329ab2 commit 304af98

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

backend/tests/Taskdeck.Api.Tests/BoardsHubIntegrationTests.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,11 @@ public async Task LeaveBoard_ShouldRemoveUserFromPresence()
168168

169169
using var client2 = _factory.CreateClient();
170170
var user2 = await ApiTestHarness.AuthenticateAsync(client2, "hub-leave2");
171-
await client1.PostAsJsonAsync(
171+
var grantResponse = await client1.PostAsJsonAsync(
172172
$"/api/boards/{board.Id}/access",
173173
new GrantAccessDto(board.Id, user2.UserId, UserRole.Editor));
174+
grantResponse.StatusCode.Should().Be(HttpStatusCode.OK,
175+
"granting board access is a precondition for this test");
174176

175177
// Observer (user1) joins board
176178
var observerEvents = new EventCollector<BoardPresenceSnapshot>();
@@ -209,9 +211,11 @@ public async Task AbruptDisconnect_ShouldCleanUpPresence()
209211

210212
using var client2 = _factory.CreateClient();
211213
var user2 = await ApiTestHarness.AuthenticateAsync(client2, "hub-disc2");
212-
await client1.PostAsJsonAsync(
214+
var grantResponse = await client1.PostAsJsonAsync(
213215
$"/api/boards/{board.Id}/access",
214216
new GrantAccessDto(board.Id, user2.UserId, UserRole.Editor));
217+
grantResponse.StatusCode.Should().Be(HttpStatusCode.OK,
218+
"granting board access is a precondition for this test");
215219

216220
// User1 connects and joins
217221
var events1 = new EventCollector<BoardPresenceSnapshot>();
@@ -252,9 +256,11 @@ public async Task MultipleUsersOnSameBoard_ShouldSeeAllMembersInPresence()
252256

253257
using var client2 = _factory.CreateClient();
254258
var user2 = await ApiTestHarness.AuthenticateAsync(client2, "hub-multi2");
255-
await client1.PostAsJsonAsync(
259+
var grantResponse = await client1.PostAsJsonAsync(
256260
$"/api/boards/{board.Id}/access",
257261
new GrantAccessDto(board.Id, user2.UserId, UserRole.Editor));
262+
grantResponse.StatusCode.Should().Be(HttpStatusCode.OK,
263+
"granting board access is a precondition for this test");
258264

259265
var events1 = new EventCollector<BoardPresenceSnapshot>();
260266
await using var conn1 = SignalRTestHelper.CreateBoardsHubConnection(_factory, user1.Token);

backend/tests/Taskdeck.Api.Tests/Support/SignalRTestHelper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Collections.Concurrent;
21
using Microsoft.AspNetCore.SignalR.Client;
32
using Microsoft.AspNetCore.Mvc.Testing;
43

0 commit comments

Comments
 (0)