Skip to content

Commit 5102979

Browse files
committed
fix(tests): align admin integration tests with current behavior
- TestAdminCanUpdateUserProfile: use status active instead of disabled since Login now rejects disabled accounts (added in b421656) - TestAdminCanCreateWebhookForUser: use underscore event names (new_message, mailbox_created) matching SupportedWebhookEvents - TestAdminCanUpdateAndToggleWebhookForUser: same event name fix
1 parent aa19b87 commit 5102979

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

backend/tests/admin_integration_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestAdminCanUpdateUserRoles(t *testing.T) {
108108
func TestAdminCanUpdateUserProfile(t *testing.T) {
109109
server, token, _ := newAdminServer(t)
110110

111-
body := `{"username":"alice-updated","email":"alice-updated@shiro.local","status":"disabled","emailVerified":true,"roles":["admin","user"],"newPassword":"BetterSecret123!"}`
111+
body := `{"username":"alice-updated","email":"alice-updated@shiro.local","status":"active","emailVerified":true,"roles":["admin","user"],"newPassword":"BetterSecret123!"}`
112112
rr := performJSON(server, http.MethodPut, "/api/v1/admin/users/1", body, token)
113113
if rr.Code != http.StatusOK {
114114
t.Fatalf("expected 200 on user update, got %d: %s", rr.Code, rr.Body.String())
@@ -119,7 +119,7 @@ func TestAdminCanUpdateUserProfile(t *testing.T) {
119119
if !strings.Contains(rr.Body.String(), `"email":"alice-updated@shiro.local"`) {
120120
t.Fatalf("expected updated email in response: %s", rr.Body.String())
121121
}
122-
if !strings.Contains(rr.Body.String(), `"status":"disabled"`) {
122+
if !strings.Contains(rr.Body.String(), `"status":"active"`) {
123123
t.Fatalf("expected updated status in response: %s", rr.Body.String())
124124
}
125125
if !strings.Contains(rr.Body.String(), `"emailVerified":true`) {
@@ -1319,7 +1319,7 @@ func TestAdminCanManageDocs(t *testing.T) {
13191319
func TestAdminCanCreateWebhookForUser(t *testing.T) {
13201320
server, token, _ := newAdminServer(t)
13211321

1322-
body := `{"userId":1,"name":"ops-events","targetUrl":"https://sandbox.local/hooks/ops-events","events":["message.received","mailbox.released"]}`
1322+
body := `{"userId":1,"name":"ops-events","targetUrl":"https://sandbox.local/hooks/ops-events","events":["new_message","mailbox_created"]}`
13231323
rr := performJSON(server, http.MethodPost, "/api/v1/admin/webhooks", body, token)
13241324
if rr.Code != http.StatusCreated {
13251325
t.Fatalf("expected 201 on admin webhook create, got %d: %s", rr.Code, rr.Body.String())
@@ -1333,7 +1333,7 @@ func TestAdminCanCreateWebhookForUser(t *testing.T) {
13331333
if !strings.Contains(rr.Body.String(), `"targetUrl":"https://sandbox.local/hooks/ops-events"`) {
13341334
t.Fatalf("expected created webhook target in response: %s", rr.Body.String())
13351335
}
1336-
if !strings.Contains(rr.Body.String(), `"events":["message.received","mailbox.released"]`) {
1336+
if !strings.Contains(rr.Body.String(), `"events":["new_message","mailbox_created"]`) {
13371337
t.Fatalf("expected webhook events in response: %s", rr.Body.String())
13381338
}
13391339

@@ -1357,7 +1357,7 @@ func TestAdminCanCreateWebhookForUser(t *testing.T) {
13571357
func TestAdminCanUpdateAndToggleWebhookForUser(t *testing.T) {
13581358
server, token, _ := newAdminServer(t)
13591359

1360-
createBody := `{"userId":1,"name":"ops-events","targetUrl":"https://sandbox.local/hooks/ops-events","events":["message.received","mailbox.released"]}`
1360+
createBody := `{"userId":1,"name":"ops-events","targetUrl":"https://sandbox.local/hooks/ops-events","events":["new_message","mailbox_created"]}`
13611361
rr := performJSON(server, http.MethodPost, "/api/v1/admin/webhooks", createBody, token)
13621362
if rr.Code != http.StatusCreated {
13631363
t.Fatalf("expected 201 on admin webhook create, got %d: %s", rr.Code, rr.Body.String())
@@ -1367,7 +1367,7 @@ func TestAdminCanUpdateAndToggleWebhookForUser(t *testing.T) {
13671367
t.Fatalf("expected webhook id in create response: %s", rr.Body.String())
13681368
}
13691369

1370-
updateBody := `{"name":"ops-events-updated","targetUrl":"https://sandbox.local/hooks/ops-events-updated","events":["message.received"]}`
1370+
updateBody := `{"name":"ops-events-updated","targetUrl":"https://sandbox.local/hooks/ops-events-updated","events":["new_message"]}`
13711371
rr = performJSON(server, http.MethodPut, "/api/v1/admin/webhooks/"+webhookID, updateBody, token)
13721372
if rr.Code != http.StatusOK {
13731373
t.Fatalf("expected 200 on admin webhook update, got %d: %s", rr.Code, rr.Body.String())

0 commit comments

Comments
 (0)