Fix e2e tests

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-02-18 12:05:53 +04:00
parent b49747f3ba
commit ab5fe8e5e2
30 changed files with 874 additions and 715 deletions

View File

@@ -19,13 +19,14 @@ 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"
)
func TestObligation_Create(t *testing.T) {
t.Parallel()
owner := testutil.NewClient(t, testutil.RoleOwner)
profileID := testutil.NewClientInOrg(t, testutil.RoleViewer, owner).GetProfileID()
profileID := factory.CreateUser(owner)
query := `
mutation CreateObligation($input: CreateObligationInput!) {
@@ -66,7 +67,7 @@ func TestObligation_Create(t *testing.T) {
"source": "GDPR Article 5",
"requirement": "Data must be processed lawfully",
"regulator": "ICO",
"ownerId": profileID.String(),
"ownerId": profileID,
"status": "NON_COMPLIANT",
"type": "LEGAL",
},
@@ -84,7 +85,7 @@ func TestObligation_Create(t *testing.T) {
func TestObligation_Update(t *testing.T) {
t.Parallel()
owner := testutil.NewClient(t, testutil.RoleOwner)
profileID := testutil.NewClientInOrg(t, testutil.RoleViewer, owner).GetProfileID()
profileID := factory.CreateUser(owner)
// Create an obligation to update
createQuery := `
@@ -113,7 +114,7 @@ func TestObligation_Update(t *testing.T) {
"input": map[string]any{
"organizationId": owner.GetOrganizationID().String(),
"area": "Original Area",
"ownerId": profileID.String(),
"ownerId": profileID,
"status": "NON_COMPLIANT",
"type": "LEGAL",
},
@@ -161,7 +162,7 @@ func TestObligation_Update(t *testing.T) {
func TestObligation_Delete(t *testing.T) {
t.Parallel()
owner := testutil.NewClient(t, testutil.RoleOwner)
profileID := testutil.NewClientInOrg(t, testutil.RoleViewer, owner).GetProfileID()
profileID := factory.CreateUser(owner)
// Create an obligation to delete
createQuery := `
@@ -190,7 +191,7 @@ func TestObligation_Delete(t *testing.T) {
"input": map[string]any{
"organizationId": owner.GetOrganizationID().String(),
"area": "Obligation to Delete",
"ownerId": profileID.String(),
"ownerId": profileID,
"status": "NON_COMPLIANT",
"type": "LEGAL",
},
@@ -225,7 +226,7 @@ func TestObligation_Delete(t *testing.T) {
func TestObligation_List(t *testing.T) {
t.Parallel()
owner := testutil.NewClient(t, testutil.RoleOwner)
profileID := testutil.NewClientInOrg(t, testutil.RoleViewer, owner).GetProfileID()
profileID := factory.CreateUser(owner)
// Create multiple obligations
areas := []string{"Area A", "Area B", "Area C"}
@@ -256,7 +257,7 @@ func TestObligation_List(t *testing.T) {
"input": map[string]any{
"organizationId": owner.GetOrganizationID().String(),
"area": area,
"ownerId": profileID.String(),
"ownerId": profileID,
"status": "NON_COMPLIANT",
"type": "LEGAL",
},
@@ -309,7 +310,7 @@ func TestObligation_List(t *testing.T) {
func TestObligation_StatusValues(t *testing.T) {
t.Parallel()
owner := testutil.NewClient(t, testutil.RoleOwner)
profileID := testutil.NewClientInOrg(t, testutil.RoleViewer, owner).GetProfileID()
profileID := factory.CreateUser(owner)
statuses := []string{"NON_COMPLIANT", "PARTIALLY_COMPLIANT", "COMPLIANT"}
@@ -343,7 +344,7 @@ func TestObligation_StatusValues(t *testing.T) {
"input": map[string]any{
"organizationId": owner.GetOrganizationID().String(),
"area": "Status Test " + status,
"ownerId": profileID.String(),
"ownerId": profileID,
"status": status,
"type": "LEGAL",
},