Fix e2e tests

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-02-06 14:38:14 +04:00
parent 9243681f1b
commit 8d20220c86
25 changed files with 323 additions and 1142 deletions

View File

@@ -21,7 +21,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.probo.inc/probo/e2e/internal/factory"
"go.probo.inc/probo/e2e/internal/testutil"
)
@@ -100,7 +99,7 @@ func createAuditForNC(t *testing.T, owner *testutil.Client, name string) string
func TestNonconformity_Create(t *testing.T) {
t.Parallel()
owner := testutil.NewClient(t, testutil.RoleOwner)
peopleID := factory.NewPeople(owner).WithFullName("NC Owner").Create()
profileID := testutil.NewClientInOrg(t, testutil.RoleViewer, owner).GetProfileID()
auditID := createAuditForNC(t, owner, "NC Test Audit")
query := `
@@ -143,7 +142,7 @@ func TestNonconformity_Create(t *testing.T) {
"auditId": auditID,
"rootCause": "Insufficient access controls",
"correctiveAction": "Implement MFA",
"ownerId": peopleID,
"ownerId": profileID.String(),
"status": "OPEN",
},
}, &result)
@@ -159,7 +158,7 @@ func TestNonconformity_Create(t *testing.T) {
func TestNonconformity_Update(t *testing.T) {
t.Parallel()
owner := testutil.NewClient(t, testutil.RoleOwner)
peopleID := factory.NewPeople(owner).WithFullName("NC Owner").Create()
profileID := testutil.NewClientInOrg(t, testutil.RoleViewer, owner).GetProfileID()
auditID := createAuditForNC(t, owner, "NC Update Test Audit")
// Create a nonconformity to update
@@ -191,7 +190,7 @@ func TestNonconformity_Update(t *testing.T) {
"referenceId": fmt.Sprintf("NC-UPDATE-%d", time.Now().UnixNano()),
"auditId": auditID,
"rootCause": "Original root cause",
"ownerId": peopleID,
"ownerId": profileID.String(),
"status": "OPEN",
},
}, &createResult)
@@ -242,7 +241,7 @@ func TestNonconformity_Update(t *testing.T) {
func TestNonconformity_Delete(t *testing.T) {
t.Parallel()
owner := testutil.NewClient(t, testutil.RoleOwner)
peopleID := factory.NewPeople(owner).WithFullName("NC Owner").Create()
profileID := testutil.NewClientInOrg(t, testutil.RoleViewer, owner).GetProfileID()
auditID := createAuditForNC(t, owner, "NC Delete Test Audit")
// Create a nonconformity to delete
@@ -274,7 +273,7 @@ func TestNonconformity_Delete(t *testing.T) {
"referenceId": fmt.Sprintf("NC-DELETE-%d", time.Now().UnixNano()),
"auditId": auditID,
"rootCause": "Test root cause",
"ownerId": peopleID,
"ownerId": profileID.String(),
"status": "OPEN",
},
}, &createResult)
@@ -307,7 +306,7 @@ func TestNonconformity_Delete(t *testing.T) {
func TestNonconformity_List(t *testing.T) {
t.Parallel()
owner := testutil.NewClient(t, testutil.RoleOwner)
peopleID := factory.NewPeople(owner).WithFullName("NC Owner").Create()
profileID := testutil.NewClientInOrg(t, testutil.RoleViewer, owner).GetProfileID()
auditID := createAuditForNC(t, owner, "NC List Test Audit")
// Create multiple nonconformities
@@ -340,7 +339,7 @@ func TestNonconformity_List(t *testing.T) {
"referenceId": fmt.Sprintf("NC-LIST-%d-%d", i, time.Now().UnixNano()),
"auditId": auditID,
"rootCause": fmt.Sprintf("Root cause %d", i),
"ownerId": peopleID,
"ownerId": profileID.String(),
"status": "OPEN",
},
}, &createResult)
@@ -391,7 +390,7 @@ func TestNonconformity_List(t *testing.T) {
func TestNonconformity_StatusValues(t *testing.T) {
t.Parallel()
owner := testutil.NewClient(t, testutil.RoleOwner)
peopleID := factory.NewPeople(owner).WithFullName("NC Owner").Create()
profileID := testutil.NewClientInOrg(t, testutil.RoleViewer, owner).GetProfileID()
auditID := createAuditForNC(t, owner, "NC Status Test Audit")
statuses := []string{"OPEN", "IN_PROGRESS", "CLOSED"}
@@ -428,7 +427,7 @@ func TestNonconformity_StatusValues(t *testing.T) {
"referenceId": fmt.Sprintf("NC-STATUS-%s-%d", status, time.Now().UnixNano()),
"auditId": auditID,
"rootCause": "Test root cause",
"ownerId": peopleID,
"ownerId": profileID.String(),
"status": status,
},
}, &result)