1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.main;
17
18 import org.apache.commons.io.FileUtils;
19 import org.junit.Rule;
20 import org.junit.Test;
21 import org.junit.rules.TemporaryFolder;
22 import org.kuali.rice.krad.uif.UifPropertyPaths;
23 import org.kuali.rice.krad.util.KRADConstants;
24 import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
25 import org.kuali.rice.testtools.selenium.WebDriverUtils;
26 import org.openqa.selenium.By;
27
28 import java.io.File;
29
30
31
32
33
34
35 public class PeopleFlowCreateNewNotesAndAttachmentsAft extends PeopleFlowCreateNewAftBase {
36
37
38
39
40
41
42 public static final String BOOKMARK_URL = WebDriverUtils.getBaseUrlString() + "/kr-krad/peopleFlowMaintenance?" +
43 "viewTypeName=MAINTENANCE&returnLocation=" + AutomatedFunctionalTestUtils.PORTAL_URL_ENCODED + "&methodToCall=start&" +
44 "dataObjectClassName=org.kuali.rice.kew.impl.peopleflow.PeopleFlowBo";
45
46
47
48
49 @Rule
50 public TemporaryFolder temporaryFolder = new TemporaryFolder();
51
52 private static final String NOTES_AND_ATTACHMENTS_PREFIX = UifPropertyPaths.NEW_COLLECTION_LINES
53 + "['"
54 + KRADConstants.DOCUMENT_PROPERTY_NAME
55 + "."
56 + KRADConstants.NOTES_PROPERTY_NAME
57 + "']";
58
59 @Override
60 public String getBookmarkUrl() {
61 return BOOKMARK_URL;
62 }
63
64
65
66
67
68
69 @Test
70 public void testPeopleFlowCreateNewNotesAndAttachments_DefaultAttachmentBookmark() throws Exception {
71 testDefaultAttachement();
72 }
73
74
75
76
77
78
79 @Test
80 public void testPeopleFlowCreateNewNotesAndAttachments_DefaultAttachmentNav() throws Exception {
81 navigateToCreateNew();
82
83 testDefaultAttachement();
84 }
85
86 protected void testDefaultAttachement() throws Exception {
87 navigateToNotesAndAttachments();
88 waitAndTypeByName(NOTES_AND_ATTACHMENTS_PREFIX + "." + KRADConstants.NOTE_TEXT_PROPERTY_NAME,
89 "Attachment_Note");
90 waitAndAddAttachment("attachment.txt", "Testing123");
91 waitAndClick(By.cssSelector("button[title='Add a Note']"));
92
93 Thread.sleep(2000);
94
95 waitForTextPresent("Attachment_Note");
96 assertTextPresent("attachment.txt");
97 assertTextNotPresent("Note Text is a required field.");
98 passed();
99 }
100
101
102
103
104
105
106 @Test
107 public void testPeopleFlowCreateNewNotesAndAttachments_DefaultNoAttachmentBookmark() throws Exception {
108 testDefaultNoAttachment();
109 }
110
111
112
113
114
115
116 @Test
117 public void testPeopleFlowCreateNewNotesAndAttachments_DefaultNoAttachmentNav() throws Exception {
118 navigateToCreateNew();
119
120 testDefaultNoAttachment();
121 }
122
123 protected void testDefaultNoAttachment() throws InterruptedException {
124 navigateToNotesAndAttachments();
125 waitAndTypeByName(NOTES_AND_ATTACHMENTS_PREFIX + "." + KRADConstants.NOTE_TEXT_PROPERTY_NAME,
126 "Attachment_Note");
127 waitAndClick(By.cssSelector("button[title='Add a Note']"));
128
129 waitForTextPresent("Attachment_Note");
130 assertTextNotPresent("Note Text is a required field");
131 passed();
132 }
133
134
135
136
137
138
139 @Test
140 public void testPeopleFlowCreateNewNotesAndAttachments_NoNoteTextBookmark() throws Exception {
141 testNoNoteText();
142 }
143
144
145
146
147
148
149 @Test
150 public void testPeopleFlowCreateNewNotesAndAttachments_NoNoteTextNav() throws Exception {
151 navigateToCreateNew();
152
153 testNoNoteText();
154 }
155
156 protected void testNoNoteText() throws Exception {
157 navigateToNotesAndAttachments();
158 waitAndAddAttachment("attachment.txt", "Testing123");
159 waitAndClick(By.cssSelector("button[title='Add a Note']"));
160
161 Thread.sleep(2000);
162 waitForTextPresent("Note Text is a required field");
163 assertTextNotPresent("attachment.txt");
164 passed();
165 }
166
167 protected void navigateToCreateNew() throws Exception {
168 selectFrameIframePortlet();
169 waitAndClickByLinkText("Create New");
170 }
171
172 private void navigateToNotesAndAttachments() throws InterruptedException {
173 waitForElementPresent(
174 "div[data-header_for='PeopleFlow-MaintenanceView'] div[data-label='Document Number'] > span");
175
176 waitAndClickByLinkText("Notes and Attachments (0)");
177 }
178
179 private void waitAndAddAttachment(String fileName, String content) throws Exception {
180 File file = temporaryFolder.newFile(fileName);
181 FileUtils.writeStringToFile(file, content);
182 String path = file.getAbsolutePath().toString();
183 waitAndTypeByName("attachmentFile", path);
184 }
185 }