Skip to content
This repository was archived by the owner on Dec 6, 2025. It is now read-only.
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package stories

import (
"context"
pb "gen/services/property_svc/v1"
"github.com/stretchr/testify/require"
"hwtesting"
"testing"

"github.com/google/uuid"
"github.com/stretchr/testify/assert"
)

func TestGetAttachedPropertyValuesAlwaysInclude(t *testing.T) {
ctx := context.Background()
propertyClient := propertyServiceClient()
propertyValueClient := propertyValueServiceClient()
propertyViewClient := propertyViewServiceClient()

subjectTypes := []pb.SubjectType{
pb.SubjectType_SUBJECT_TYPE_PATIENT,
pb.SubjectType_SUBJECT_TYPE_TASK,
}

fieldTypes := []pb.FieldType{
pb.FieldType_FIELD_TYPE_TEXT,
pb.FieldType_FIELD_TYPE_NUMBER,
pb.FieldType_FIELD_TYPE_CHECKBOX,
pb.FieldType_FIELD_TYPE_DATE,
pb.FieldType_FIELD_TYPE_DATE_TIME,
pb.FieldType_FIELD_TYPE_SELECT,
pb.FieldType_FIELD_TYPE_MULTI_SELECT,
}

for _, subjectType := range subjectTypes {
for _, fieldType := range fieldTypes {
t.Run(t.Name()+"_"+subjectType.String()+"_"+fieldType.String(), func(t *testing.T) {
subjectID := uuid.New().String()

// Create a property
property, err := propertyClient.CreateProperty(ctx, &pb.CreatePropertyRequest{
SubjectType: subjectType,
FieldType: fieldType,
Name: t.Name(),
Description: nil,
})
require.NoError(t, err)
hwtesting.WaitForProjectionsToSettle()

// Don't create a property value

// Add property to the always_include list of an arbitrary subject
_, err = propertyViewClient.UpdatePropertyViewRule(ctx, &pb.UpdatePropertyViewRuleRequest{
FilterUpdate: &pb.FilterUpdate{
AppendToAlwaysInclude: []string{property.PropertyId},
},
Matcher: &pb.UpdatePropertyViewRuleRequest_PatientMatcher{
PatientMatcher: &pb.PatientPropertyMatcher{
WardId: nil,
PatientId: &subjectID,
},
},
})
require.NoError(t, err)
hwtesting.WaitForProjectionsToSettle()

// Call GetAttachedPropertyValues for this arbitrary patient or task

res, err := propertyValueClient.GetAttachedPropertyValues(ctx, &pb.GetAttachedPropertyValuesRequest{
Matcher: &pb.GetAttachedPropertyValuesRequest_PatientMatcher{
PatientMatcher: &pb.PatientPropertyMatcher{
WardId: nil,
PatientId: &subjectID,
},
},
})
require.NoError(t, err)

// Property shows up
require.Len(t, res.Values, 1)
assert.Equal(t, res.Values[0].PropertyId, property.PropertyId)
})
}
}
}
Loading