Skip to content

Commit

Permalink
LEAF 4585 test, verbiage, positive input to last for better final pos…
Browse files Browse the repository at this point in the history
…ition
  • Loading branch information
aerinkayne authored and Pelentan committed Nov 27, 2024
1 parent d621113 commit 5be996b
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions API-tests/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/google/go-cmp/cmp"
)

func getWorkflowStep(url string) WorkflowStep {
res, _ := client.Get(url)
func getWorkflowStep(stepID string) WorkflowStep {
res, _ := client.Get(RootURL + "api/workflow/step/" + stepID)
b, _ := io.ReadAll(res.Body)

var m WorkflowStep
Expand All @@ -24,14 +24,14 @@ func getWorkflowStep(url string) WorkflowStep {
return m
}

func setStepCoordinates(stepID string, x string, y string) string {
func setStepCoordinates(workflowID string, stepID string, x string, y string) string {
postData := url.Values{}
postData.Set("CSRFToken", CsrfToken)
postData.Set("stepID", stepID)
postData.Set("x", x)
postData.Set("y", y)

res, _ := client.PostForm(RootURL+`api/workflow/1/editorPosition`, postData)
res, _ := client.PostForm(RootURL + `api/workflow/`+ workflowID + `/editorPosition`, postData)
bodyBytes, _ := io.ReadAll(res.Body)

var c string
Expand All @@ -42,24 +42,41 @@ func setStepCoordinates(stepID string, x string, y string) string {
return c
}

func TestWorkflow_No_Negative_Step_Coordinates(t *testing.T) {
res := setStepCoordinates("1", "-100", "-100")

got := res
func TestWorkflow_Set_Step_Coordinates(t *testing.T) {
//negative coords use min val of 0
got := setStepCoordinates("1", "1", "-100", "-100")
want := "1"
if !cmp.Equal(got, want) {
t.Errorf("Error updating step position = %v, want = %v", got, want)
t.Errorf("Error setting step position = %v, want = %v", got, want)
}

workflowStep := getWorkflowStep(RootURL + "api/workflow/step/1")
workflowStep := getWorkflowStep("1")
got = strconv.Itoa(workflowStep.PosX)
want = "0"
if !cmp.Equal(got, want) {
t.Errorf("Saved X position should have min possible value of 0 = %v, want = %v", got, want)
}
got = strconv.Itoa(workflowStep.PosY)
want = "0"
if !cmp.Equal(got, want) {
t.Errorf("Saved Y position should have min possible value of 0 = %v, want = %v", got, want)
}

//positive coords should save as given
got = setStepCoordinates("1", "1", "200", "500")
want = "1"
if !cmp.Equal(got, want) {
t.Errorf("Error setting step position = %v, want = %v", got, want)
}

workflowStep = getWorkflowStep("1")
got = strconv.Itoa(workflowStep.PosX)
want = "200"
if !cmp.Equal(got, want) {
t.Errorf("Saved X position did not match input = %v, want = %v", got, want)
}
got = strconv.Itoa(workflowStep.PosY)
want = "500"
if !cmp.Equal(got, want) {
t.Errorf("Saved Y position did not match input = %v, want = %v", got, want)
}
}

0 comments on commit 5be996b

Please sign in to comment.