Compare commits

..

1 Commits

Author SHA1 Message Date
core-devops f713c7d69c fix(ci): pin e2e-chat setup-node to mirrored SHA (mc#1292)
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 10s
Lint curl status-code capture / Scan workflows for curl status-capture pollution (pull_request) Successful in 20s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 22s
CI / Detect changes (pull_request) Successful in 1m3s
E2E API Smoke Test / detect-changes (pull_request) Successful in 1m15s
qa-review / approved (pull_request) Successful in 18s
E2E Chat / detect-changes (pull_request) Successful in 1m18s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 1m19s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 58s
security-review / approved (pull_request) Successful in 19s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m27s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 7s
CI / Python Lint & Test (pull_request) Successful in 9s
Lint workflow YAML (Gitea-1.22.6-hostile shapes) / Lint workflow YAML for Gitea-1.22.6-hostile shapes (pull_request) Successful in 1m38s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 11s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 8s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 7s
lint-continue-on-error-tracking / lint-continue-on-error-tracking (pull_request) Successful in 2m27s
Lint pre-flip continue-on-error / Verify continue-on-error flips have run-log proof (pull_request) Successful in 2m30s
lint-required-context-exists-in-bp / lint-required-context-exists-in-bp (pull_request) Successful in 2m47s
gate-check-v3 / gate-check (pull_request) Successful in 13s
sop-checklist / all-items-acked (pull_request) Successful in 16s
sop-tier-check / tier-check (pull_request) Successful in 15s
E2E Chat / E2E Chat (pull_request) Failing after 6m27s
CI / Platform (Go) (pull_request) Successful in 14m50s
CI / Canvas (Next.js) (pull_request) Successful in 16m42s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Successful in 5s
actions/setup-node@60edb5dd... (v4) was never mirrored into the
self-hosted Gitea Actions mirror, causing 100% failure rate for E2E
Chat since inception (33 runs, 0 successes).

Switch to the already-mirrored v6.4.0 SHA that sibling workflow
e2e-staging-canvas.yml uses successfully.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 06:00:54 +00:00
2 changed files with 1 additions and 273 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ jobs:
cache-dependency-path: workspace-server/go.sum
- if: needs.detect-changes.outputs.chat == 'true'
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d6f5 # v4
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 (mirrored SHA; v4 SHA was never mirrored — mc#1292)
with:
node-version: '22'
cache: 'npm'
@@ -1,272 +0,0 @@
package handlers
import (
"bytes"
"context"
"database/sql"
"net/http"
"net/http/httptest"
"testing"
"github.com/DATA-DOG/go-sqlmock"
"github.com/Molecule-AI/molecule-monorepo/platform/internal/db"
"github.com/gin-gonic/gin"
)
// setupAbilitiesDB creates a sqlmock with QueryMatcherEqual (quoted literals
// are not used by PatchAbilities but using the same pattern as
// workspace_broadcast_test.go keeps conventions consistent).
func setupAbilitiesDB(t *testing.T) sqlmock.Sqlmock {
t.Helper()
mockDB, mock, err := sqlmock.New(sqlmock.QueryMatcherOption(sqlmock.QueryMatcherEqual))
if err != nil {
t.Fatalf("failed to create sqlmock: %v", err)
}
prevDB := db.DB
db.DB = mockDB
t.Cleanup(func() { db.DB = prevDB; mockDB.Close() })
return mock
}
// buildAbilitiesCtx creates a gin.Context wired for PATCH /workspaces/:id/abilities.
func buildAbilitiesCtx(id, body string) (*gin.Context, *httptest.ResponseRecorder) {
w := httptest.NewRecorder()
c, _ := gin.CreateTestContext(w)
req := httptest.NewRequest(http.MethodPatch, "/workspaces/"+id+"/abilities", bytes.NewBufferString(body))
req.Header.Set("Content-Type", "application/json")
c.Request = req.WithContext(context.Background())
c.Params = gin.Params{{Key: "id", Value: id}}
return c, w
}
// ─── Validation ────────────────────────────────────────────────────────────────
func TestPatchAbilities_InvalidWorkspaceID(t *testing.T) {
c, w := buildAbilitiesCtx("not-a-uuid", `{"broadcast_enabled":true}`)
PatchAbilities(c)
if w.Code != http.StatusBadRequest {
t.Errorf("want 400, got %d: %s", w.Code, w.Body.String())
}
}
func TestPatchAbilities_InvalidJSON(t *testing.T) {
mock := setupAbilitiesDB(t)
c, w := buildAbilitiesCtx("bbbbbbbb-0001-0001-0001-000000000001", `not json`)
PatchAbilities(c)
if w.Code != http.StatusBadRequest {
t.Errorf("want 400, got %d: %s", w.Code, w.Body.String())
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("unmet mock expectations: %v", err)
}
}
func TestPatchAbilities_EmptyBody(t *testing.T) {
mock := setupAbilitiesDB(t)
c, w := buildAbilitiesCtx("bbbbbbbb-0001-0001-0001-000000000001", `{}`)
PatchAbilities(c)
if w.Code != http.StatusBadRequest {
t.Errorf("want 400, got %d: %s", w.Code, w.Body.String())
}
// No DB queries should fire for an empty-body rejection.
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("unmet mock expectations: %v", err)
}
}
func TestPatchAbilities_BothFieldsNil(t *testing.T) {
mock := setupAbilitiesDB(t)
c, w := buildAbilitiesCtx("bbbbbbbb-0001-0001-0001-000000000001", `{"other_field":true}`)
PatchAbilities(c)
if w.Code != http.StatusBadRequest {
t.Errorf("want 400, got %d: %s", w.Code, w.Body.String())
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("unmet mock expectations: %v", err)
}
}
// ─── Workspace not found ────────────────────────────────────────────────────────
func TestPatchAbilities_WorkspaceNotFound(t *testing.T) {
mock := setupAbilitiesDB(t)
c, w := buildAbilitiesCtx("bbbbbbbb-0001-0001-0001-000000000001", `{"broadcast_enabled":true}`)
// Workspace lookup returns exists=false.
mock.ExpectQuery("SELECT EXISTS(SELECT 1 FROM workspaces WHERE id = $1 AND status != 'removed')").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001").
WillReturnRows(sqlmock.NewRows([]string{"exists"}).AddRow(false))
PatchAbilities(c)
if w.Code != http.StatusNotFound {
t.Errorf("want 404, got %d: %s", w.Code, w.Body.String())
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("unmet mock expectations: %v", err)
}
}
func TestPatchAbilities_WorkspaceLookupQueryError(t *testing.T) {
mock := setupAbilitiesDB(t)
c, w := buildAbilitiesCtx("bbbbbbbb-0001-0001-0001-000000000001", `{"broadcast_enabled":true}`)
mock.ExpectQuery("SELECT EXISTS(SELECT 1 FROM workspaces WHERE id = $1 AND status != 'removed')").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001").
WillReturnError(sql.ErrConnDone)
PatchAbilities(c)
if w.Code != http.StatusNotFound {
t.Errorf("want 404, got %d: %s", w.Code, w.Body.String())
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("unmet mock expectations: %v", err)
}
}
// ─── Update errors ─────────────────────────────────────────────────────────────
func TestPatchAbilities_BroadcastUpdateError(t *testing.T) {
mock := setupAbilitiesDB(t)
c, w := buildAbilitiesCtx("bbbbbbbb-0001-0001-0001-000000000001", `{"broadcast_enabled":true}`)
mock.ExpectQuery("SELECT EXISTS(SELECT 1 FROM workspaces WHERE id = $1 AND status != 'removed')").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001").
WillReturnRows(sqlmock.NewRows([]string{"exists"}).AddRow(true))
mock.ExpectExec("UPDATE workspaces SET broadcast_enabled = $2, updated_at = now() WHERE id = $1").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001", true).
WillReturnError(sql.ErrConnDone)
PatchAbilities(c)
if w.Code != http.StatusInternalServerError {
t.Errorf("want 500, got %d: %s", w.Code, w.Body.String())
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("unmet mock expectations: %v", err)
}
}
func TestPatchAbilities_TalkToUserUpdateError(t *testing.T) {
mock := setupAbilitiesDB(t)
c, w := buildAbilitiesCtx("bbbbbbbb-0001-0001-0001-000000000001", `{"talk_to_user_enabled":false}`)
mock.ExpectQuery("SELECT EXISTS(SELECT 1 FROM workspaces WHERE id = $1 AND status != 'removed')").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001").
WillReturnRows(sqlmock.NewRows([]string{"exists"}).AddRow(true))
mock.ExpectExec("UPDATE workspaces SET talk_to_user_enabled = $2, updated_at = now() WHERE id = $1").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001", false).
WillReturnError(sql.ErrConnDone)
PatchAbilities(c)
if w.Code != http.StatusInternalServerError {
t.Errorf("want 500, got %d: %s", w.Code, w.Body.String())
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("unmet mock expectations: %v", err)
}
}
// ─── Success paths ─────────────────────────────────────────────────────────────
func TestPatchAbilities_BroadcastEnabledTrue(t *testing.T) {
mock := setupAbilitiesDB(t)
c, w := buildAbilitiesCtx("bbbbbbbb-0001-0001-0001-000000000001", `{"broadcast_enabled":true}`)
mock.ExpectQuery("SELECT EXISTS(SELECT 1 FROM workspaces WHERE id = $1 AND status != 'removed')").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001").
WillReturnRows(sqlmock.NewRows([]string{"exists"}).AddRow(true))
mock.ExpectExec("UPDATE workspaces SET broadcast_enabled = $2, updated_at = now() WHERE id = $1").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001", true).
WillReturnResult(sqlmock.NewResult(0, 1))
PatchAbilities(c)
if w.Code != http.StatusOK {
t.Errorf("want 200, got %d: %s", w.Code, w.Body.String())
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("unmet mock expectations: %v", err)
}
}
func TestPatchAbilities_BroadcastEnabledFalse(t *testing.T) {
mock := setupAbilitiesDB(t)
c, w := buildAbilitiesCtx("bbbbbbbb-0001-0001-0001-000000000001", `{"broadcast_enabled":false}`)
mock.ExpectQuery("SELECT EXISTS(SELECT 1 FROM workspaces WHERE id = $1 AND status != 'removed')").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001").
WillReturnRows(sqlmock.NewRows([]string{"exists"}).AddRow(true))
mock.ExpectExec("UPDATE workspaces SET broadcast_enabled = $2, updated_at = now() WHERE id = $1").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001", false).
WillReturnResult(sqlmock.NewResult(0, 1))
PatchAbilities(c)
if w.Code != http.StatusOK {
t.Errorf("want 200, got %d: %s", w.Code, w.Body.String())
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("unmet mock expectations: %v", err)
}
}
func TestPatchAbilities_TalkToUserEnabled(t *testing.T) {
mock := setupAbilitiesDB(t)
c, w := buildAbilitiesCtx("bbbbbbbb-0001-0001-0001-000000000001", `{"talk_to_user_enabled":true}`)
mock.ExpectQuery("SELECT EXISTS(SELECT 1 FROM workspaces WHERE id = $1 AND status != 'removed')").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001").
WillReturnRows(sqlmock.NewRows([]string{"exists"}).AddRow(true))
mock.ExpectExec("UPDATE workspaces SET talk_to_user_enabled = $2, updated_at = now() WHERE id = $1").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001", true).
WillReturnResult(sqlmock.NewResult(0, 1))
PatchAbilities(c)
if w.Code != http.StatusOK {
t.Errorf("want 200, got %d: %s", w.Code, w.Body.String())
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("unmet mock expectations: %v", err)
}
}
func TestPatchAbilities_BothFields(t *testing.T) {
mock := setupAbilitiesDB(t)
c, w := buildAbilitiesCtx("bbbbbbbb-0001-0001-0001-000000000001", `{"broadcast_enabled":true,"talk_to_user_enabled":false}`)
mock.ExpectQuery("SELECT EXISTS(SELECT 1 FROM workspaces WHERE id = $1 AND status != 'removed')").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001").
WillReturnRows(sqlmock.NewRows([]string{"exists"}).AddRow(true))
mock.ExpectExec("UPDATE workspaces SET broadcast_enabled = $2, updated_at = now() WHERE id = $1").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001", true).
WillReturnResult(sqlmock.NewResult(0, 1))
mock.ExpectExec("UPDATE workspaces SET talk_to_user_enabled = $2, updated_at = now() WHERE id = $1").
WithArgs("bbbbbbbb-0001-0001-0001-000000000001", false).
WillReturnResult(sqlmock.NewResult(0, 1))
PatchAbilities(c)
if w.Code != http.StatusOK {
t.Errorf("want 200, got %d: %s", w.Code, w.Body.String())
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("unmet mock expectations: %v", err)
}
}