1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.samplu.mainmenu.test;
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.openqa.selenium.By;
25
26 import java.io.File;
27
28
29
30
31
32
33 public class PeopleFlowCreateNewNotesAndAttachmentsSmokeTest extends PeopleFlowCreateNewSTJUnitBase {
34
35
36
37
38 @Rule
39 public TemporaryFolder temporaryFolder = new TemporaryFolder();
40
41 private static final String NOTES_AND_ATTACHMENTS_PREFIX = UifPropertyPaths.NEW_COLLECTION_LINES
42 + "['"
43 + KRADConstants.DOCUMENT_PROPERTY_NAME
44 + "."
45 + KRADConstants.NOTES_PROPERTY_NAME
46 + "']";
47
48 @Override
49 public String getBookmarkUrl() {
50 return BOOKMARK_URL;
51 }
52
53 @Override
54 public String getTestUrl() {
55 return BOOKMARK_URL;
56 }
57
58
59
60
61
62
63 @Test
64 public void testPeopleFlowCreateNewNotesAndAttachments_DefaultAttachment() throws Exception {
65 navigateToPeopleFlowNotesAndAttachments();
66
67 waitAndTypeByName(NOTES_AND_ATTACHMENTS_PREFIX + "." + KRADConstants.NOTE_TEXT_PROPERTY_NAME,
68 "Attachment_Note");
69 waitAndAddAttachment("attachment.txt", "Testing123");
70 waitAndClick(By.cssSelector("button[title='Add a Note']"));
71
72 Thread.sleep(2000);
73
74 assertTextPresent("Attachment_Note");
75 assertTextPresent("attachment.txt");
76 assertTextNotPresent("Note Text is a required field.");
77 }
78
79
80
81
82
83
84 @Test
85 public void testPeopleFlowCreateNewNotesAndAttachments_DefaultNoAttachment() throws Exception {
86 navigateToPeopleFlowNotesAndAttachments();
87
88 waitAndTypeByName(NOTES_AND_ATTACHMENTS_PREFIX + "." + KRADConstants.NOTE_TEXT_PROPERTY_NAME,
89 "Attachment_Note");
90 waitAndClick(By.cssSelector("button[title='Add a Note']"));
91
92 Thread.sleep(2000);
93
94 assertTextPresent("Attachment_Note");
95 assertTextNotPresent("Note Text is a required field.");
96 }
97
98
99
100
101
102
103 @Test
104 public void testPeopleFlowCreateNewNotesAndAttachments_NoNoteText() throws Exception {
105 navigateToPeopleFlowNotesAndAttachments();
106
107 waitAndAddAttachment("attachment.txt", "Testing123");
108 waitAndClick(By.cssSelector("button[title='Add a Note']"));
109
110 Thread.sleep(2000);
111
112 assertTextPresent("Note Text is a required field.");
113 assertTextNotPresent("attachment.txt");
114 }
115
116 private void navigateToPeopleFlowNotesAndAttachments() throws Exception {
117 selectFrameIframePortlet();
118
119 waitAndClickByLinkText("Create New");
120 waitForElementPresent(
121 "div[data-header_for='PeopleFlow-MaintenanceView'] div[data-label='Document Number'] > span");
122
123 waitAndClickByLinkText("Notes and Attachments (0)");
124 }
125
126 private void waitAndAddAttachment(String fileName, String content) throws Exception {
127 File file = temporaryFolder.newFile(fileName);
128 FileUtils.writeStringToFile(file, content);
129 String path = file.getAbsolutePath().toString();
130 driver.findElement(By.name("attachmentFile")).sendKeys(path);
131 }
132 }