Skip to content

Commit f20b6e1

Browse files
committed
test: update institution membership tests for head leave behavior
1 parent 0f73d06 commit f20b6e1

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

testing/institution_membership_test.go

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -353,13 +353,13 @@ func (s *MultiUserTestSuite) TestInstitutionManagementLeadership() {
353353
s.Equal(2, len(instWithBothHeads.Members), "should have 2 members")
354354
s.T().Logf("Institution has 2 heads again")
355355

356-
// Charlie cannot remove himself - the validation prevents self-removal
357-
MustFail(clientCharlie.RemoveMember(institution.ID.String(), clientCharlie.ID))
358-
s.T().Logf("Charlie cannot remove himself (expected - validation prevents self-removal)")
356+
// Charlie CAN remove himself (leave) since Diana is also a head
357+
MustSucceed(clientCharlie.RemoveMember(institution.ID.String(), clientCharlie.ID))
358+
s.T().Logf("Charlie left the institution (Diana remains as head)")
359359

360-
// Diana also cannot remove herself
360+
// Diana is now the last head — she cannot leave
361361
MustFail(clientDiana.RemoveMember(institution.ID.String(), clientDiana.ID))
362-
s.T().Logf("Diana cannot remove herself (expected - validation prevents self-removal)")
362+
s.T().Logf("Diana cannot leave (expected - she is the last head)")
363363
}
364364

365365
// TestInstitutionManagementLeadershipSteal creates two institutions with one head each
@@ -457,22 +457,19 @@ func (s *MultiUserTestSuite) TestInstitutionManagementLeadershipSteal() {
457457
s.Equal(obj.RoleHead, inst2AfterFrankLeft.Members[0].Role)
458458
s.T().Logf("Institution2 now has 1 head: grace (Frank left)")
459459

460-
// Frank cannot remove himself from institution1 (self-removal validation)
461-
MustFail(clientFrank.RemoveMember(institution1.ID.String(), clientFrank.ID))
462-
s.T().Logf("Frank cannot remove himself from institution1 (validation prevents self-removal)")
463-
464-
// Eve can remove Frank from institution1 (since there are 2 heads)
465-
MustSucceed(clientEve.RemoveMember(institution1.ID.String(), clientFrank.ID))
466-
s.T().Logf("Eve removed Frank from institution1")
460+
// Frank CAN remove himself from institution1 (there are 2 heads: eve and frank)
461+
MustSucceed(clientFrank.RemoveMember(institution1.ID.String(), clientFrank.ID))
462+
s.T().Logf("Frank left institution1 (Eve remains as head)")
467463

468464
// Verify Frank was removed from institution1
469465
inst1AfterRemoval := Must(clientEve.GetInstitution(institution1.ID.String()))
470466
s.Equal(1, len(inst1AfterRemoval.Members), "institution1 should have 1 member")
471467
s.Equal("eve", inst1AfterRemoval.Members[0].Name)
472468
s.T().Logf("Institution1 back to 1 head: eve")
473469

474-
// Frank now has no role in any institution
475-
s.T().Logf("Frank has no role in any institution")
470+
// Eve is now the last head — she cannot leave
471+
MustFail(clientEve.RemoveMember(institution1.ID.String(), clientEve.ID))
472+
s.T().Logf("Eve cannot leave institution1 (she is the last head)")
476473
}
477474

478475
// TestInviteByEmail tests email-based invitations

0 commit comments

Comments
 (0)