-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LEAF-4581 - extended character set test (#22)
* LEAF-4851 - initial setup of test * LEAF-4581 - testing of special characters on record title and data. Also includes test to show affects on other parts of the site that do not use mb4 --------- Co-authored-by: shane <[email protected]>
- Loading branch information
Showing
2 changed files
with
99 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,11 @@ package main | |
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"net/url" | ||
"strings" | ||
"strconv" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
|
@@ -248,9 +249,9 @@ func TestFormQuery_FindTwoSteps(t *testing.T) { | |
/* post a new employee to an orgchart format question and then confirm expected values on orgchart property */ | ||
func TestFormQuery_Employee_Format__Orgchart_Has_Expected_Values(t *testing.T) { | ||
mock_orgchart_employee := FormQuery_Orgchart_Employee{ | ||
EmpUID: 201, | ||
FirstName: "Ramon", | ||
LastName: "Watsica", | ||
EmpUID: 201, | ||
FirstName: "Ramon", | ||
LastName: "Watsica", | ||
MiddleName: "Yundt", | ||
Email: "[email protected]", | ||
UserName: "vtrycxbethany", | ||
|
@@ -524,3 +525,43 @@ func TestForm_VerifyInitiator(t *testing.T) { | |
t.Error("UserName not set") | ||
} | ||
} | ||
|
||
/* Test special characters saved in the title of a record and contents of a record */ | ||
func TestFormQuery_Special_Characters(t *testing.T) { | ||
|
||
theTestString := "This is an otter 🦦 this is a smiley 😀" | ||
theTestTitleString := "TestForm_Special_Characters😀" | ||
|
||
// Setup conditions | ||
postData := url.Values{} | ||
postData.Set("CSRFToken", CsrfToken) | ||
postData.Set("numform_5ea07", "1") | ||
postData.Set("title", theTestTitleString) | ||
postData.Set("3", theTestString) | ||
postData.Set("8", "1") | ||
postData.Set("9", "112") | ||
|
||
// TODO: streamline this | ||
pRes, _ := client.PostForm(RootURL+`api/form/new`, postData) | ||
bodyBytes, _ := io.ReadAll(pRes.Body) | ||
var response string | ||
json.Unmarshal(bodyBytes, &response) | ||
recordID, err := strconv.Atoi(string(response)) | ||
|
||
if err != nil { | ||
t.Errorf("Could not create record for TestFormQuery_Special_Characters: " + err.Error()) | ||
} | ||
|
||
res, _ := getFormQuery(RootURL + fmt.Sprintf(`api/form/query/?q={"terms":[{"id":"recordID","operator":"=","match":"%d","gate":"AND"},{"id":"deleted","operator":"=","match":0,"gate":"AND"}],"joins":[],"sort":{},"getData":["3"]}&x-filterData=recordID,title`, recordID)) | ||
|
||
if res[recordID].Title != theTestTitleString { | ||
t.Errorf(`Title %v Does not match %v.`, res[recordID].Title, theTestTitleString) | ||
} | ||
|
||
for tKey, tVal := range res[recordID].S1 { | ||
|
||
if tKey == "id3" && tVal != theTestString { | ||
t.Errorf(`Text %v Does not match %v.`, tVal, theTestString) | ||
} | ||
} | ||
} |