Skip to content

Commit

Permalink
LEAF test 4604 add stapled form to test
Browse files Browse the repository at this point in the history
  • Loading branch information
aerinkayne committed Dec 10, 2024
1 parent b1ead14 commit 04232a1
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
11 changes: 9 additions & 2 deletions API-tests/database/portal_test_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ INSERT INTO `categories` (`categoryID`, `parentID`, `categoryName`, `categoryDes
('form_f8b95', '', 'Multiple person designated', '', 4, 0, 1, NULL, 1, 0, '', NULL, 1698274593),
('leaf_devconsole', '', 'LEAF Developer Console', '', -2, 0, 0, NULL, 1, 0, '', NULL, 0),
('leaf_secure', '', 'Leaf Secure Certification', '', -1, 0, 0, NULL, 1, 0, '', NULL, 0),
('form_7664a', '', 'IFTHEN display status progress checking', '', 1, 0, 0, NULL, 1, 0, '', NULL, 1733265434);
('form_7664a', '', 'IFTHEN display status progress checking', '', 1, 0, 0, NULL, 1, 0, '', NULL, 1733265434),
('form_dac2a', '', 'Test IFTHEN staple', '', 0, 10, 0, NULL, 1, 0, '', NULL, 1733840407);

DROP TABLE IF EXISTS `category_count`;
CREATE TABLE `category_count` (
Expand Down Expand Up @@ -1122,6 +1123,8 @@ CREATE TABLE `category_staples` (
CONSTRAINT `category_staples_ibfk_1` FOREIGN KEY (`categoryID`) REFERENCES `categories` (`categoryID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

INSERT INTO `category_staples` (`categoryID`, `stapledCategoryID`) VALUES
('form_7664a', 'form_dac2a');

DROP TABLE IF EXISTS `data`;
CREATE TABLE `data` (
Expand Down Expand Up @@ -6233,7 +6236,11 @@ INSERT INTO `indicators` (`indicatorID`, `name`, `format`, `description`, `defau
(25, 'normal nested multitext sub question', 'textarea', '', '', 23, 'form_7664a', '', '', NULL, NULL, 1, -127, '2024-12-09 13:38:21', 0, 0),
(26, 'checkboxes parent', 'checkboxes\r\nA & B\r\nC & D\r\nE & \"F\"', '', '', 23, 'form_7664a', '', '', NULL, NULL, 1, -126, '2024-12-09 13:38:21', 0, 0),
(27, 'multiselect child (show if parent E & "F")', 'multiselect\r\napple\r\norange\r\nbanana\r\npineapple\r\navocado', '', '', 26, 'form_7664a', '', '', '[{\"childIndID\":27,\"parentIndID\":26,\"selectedOp\":\"==\",\"selectedParentValue\":\"E & "F"\",\"selectedChildValue\":\"\",\"selectedOutcome\":\"show\",\"crosswalkFile\":\"\",\"crosswalkHasHeader\":false,\"level2IndID\":null,\"childFormat\":\"multiselect\",\"parentFormat\":\"checkboxes\"}]', NULL, 1, -128, '2024-12-09 13:38:21', 0, 0),
(28, 'normal nested checkbox child', 'checkbox\r\ntest', '', '', 27, 'form_7664a', '', '', NULL, NULL, 1, -128, '2024-12-09 13:38:21', 0, 0);
(28, 'normal nested checkbox child', 'checkbox\r\ntest', '', '', 27, 'form_7664a', '', '', NULL, NULL, 1, -128, '2024-12-09 13:38:21', 0, 0),
(29, 'Header', '', '', '', NULL, 'form_dac2a', NULL, NULL, NULL, NULL, 0, -128, '2024-12-10 14:19:05', 0, 0),
(30, 'parent dropdown', 'dropdown\n\n1\n2\n3', '', '', 29, 'form_dac2a', NULL, NULL, NULL, NULL, 0, -128, '2024-12-10 14:19:35', 0, 0),
(31, 'child text', 'text', '', '', 30, 'form_dac2a', NULL, NULL, '[{\"childIndID\":31,\"parentIndID\":30,\"selectedOp\":\"==\",\"selectedParentValue\":\"3\",\"selectedChildValue\":\"\",\"selectedOutcome\":\"show\",\"crosswalkFile\":\"\",\"crosswalkHasHeader\":false,\"level2IndID\":null,\"childFormat\":\"text\",\"parentFormat\":\"dropdown\"}]', NULL, 1, -128, '2024-12-10 14:19:47', 0, 0),
(32, 'nested sub question', 'text', '', '', 31, 'form_dac2a', NULL, NULL, NULL, NULL, 1, -128, '2024-12-10 14:20:07', 0, 0);

DROP TABLE IF EXISTS `notes`;
CREATE TABLE `notes` (
Expand Down
43 changes: 42 additions & 1 deletion API-tests/form_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,13 @@ func TestForm_FilterChildkeys(t *testing.T) {
}

func TestForm_GetProgress_ReturnValue(t *testing.T) {
/* Setup form_7664a. 11 required questions with different formats (format influences logic).
/* Setup form_7664a, with staple form_dac2a.
form_7664a has 11 required questions with different formats (format influences logic).
17p controls 18c. 18c has subquestions 19, 20. 18 is visible if 17 is '2'
22p controls 23c. 23c has subquestions 24, 25, (26p, 27c, 28). 23 is visible if 22 is >= '42'
-26p controls 27c. 27c has subquestion 28. 27 is visible if 26 includes 'E & "F"'
form_dac2a has 2 required questions
30p (not required) controls 31c. 31c has subquestion 32. 31 is visisble if 30p is 3
Format information is noted when data is posted */

//create the new request and get the recordID for progress and domodify urls, check intial progress.
Expand Down Expand Up @@ -385,4 +388,42 @@ func TestForm_GetProgress_ReturnValue(t *testing.T) {
if !cmp.Equal(got, want) {
t.Errorf("progress check got = %v, want = %v", got, want)
}

//fill staple 30 to display 31c, 32 (11/13)
postData = url.Values{}
postData.Set("CSRFToken", CsrfToken)
postData.Set("30", "3") //dropdown 1,2,3
res, err = client.PostForm(urlPostDoModify, postData)
if err != nil {
t.Error(urlPostDoModify + "Error sending post request")
}
got, res = httpGet(urlGetProgress)
want = `"85"`
if !cmp.Equal(got, want) {
t.Errorf("progress check got = %v, want = %v", got, want)
}
postData = url.Values{}
postData.Set("CSRFToken", CsrfToken)
postData.Set("31", "test 31") //text
res, err = client.PostForm(urlPostDoModify, postData)
if err != nil {
t.Error(urlPostDoModify + "Error sending post request")
}
got, res = httpGet(urlGetProgress)
want = `"92"`
if !cmp.Equal(got, want) {
t.Errorf("progress check got = %v, want = %v", got, want)
}
postData = url.Values{}
postData.Set("CSRFToken", CsrfToken)
postData.Set("32", "test 32") //text
res, err = client.PostForm(urlPostDoModify, postData)
if err != nil {
t.Error(urlPostDoModify + "Error sending post request")
}
got, res = httpGet(urlGetProgress)
want = `"100"`
if !cmp.Equal(got, want) {
t.Errorf("progress check got = %v, want = %v", got, want)
}
}

0 comments on commit 04232a1

Please sign in to comment.