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.openqa.selenium.By;
25  
26  import java.io.File;
27  
28  
29  
30  
31  
32  
33  public class PeopleFlowCreateNewNotesAndAttachmentsAft extends PeopleFlowCreateNewAftBase {
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      
54  
55  
56  
57  
58      @Test
59      public void testPeopleFlowCreateNewNotesAndAttachments_DefaultAttachmentNav() throws Exception {
60          navigateToPeopleFlowNotesAndAttachments();
61  
62          waitAndTypeByName(NOTES_AND_ATTACHMENTS_PREFIX + "." + KRADConstants.NOTE_TEXT_PROPERTY_NAME,
63                  "Attachment_Note");
64          waitAndAddAttachment("attachment.txt", "Testing123");
65          waitAndClick(By.cssSelector("button[title='Add a Note']"));
66  
67          Thread.sleep(2000);
68  
69          waitForTextPresent("Attachment_Note");
70          assertTextPresent("attachment.txt");
71          assertTextNotPresent("Note Text is a required field.");
72          passed();
73      }
74  
75      
76  
77  
78  
79  
80      @Test
81      public void testPeopleFlowCreateNewNotesAndAttachments_DefaultNoAttachmentNav() throws Exception {
82          navigateToPeopleFlowNotesAndAttachments();
83  
84          waitAndTypeByName(NOTES_AND_ATTACHMENTS_PREFIX + "." + KRADConstants.NOTE_TEXT_PROPERTY_NAME,
85                  "Attachment_Note");
86          waitAndClick(By.cssSelector("button[title='Add a Note']"));
87  
88          waitForTextPresent("Attachment_Note");
89          assertTextNotPresent("Note Text is a required field");
90          passed();
91      }
92  
93      
94  
95  
96  
97  
98      @Test
99      public void testPeopleFlowCreateNewNotesAndAttachments_NoNoteTextNav() throws Exception {
100         navigateToPeopleFlowNotesAndAttachments();
101 
102         waitAndAddAttachment("attachment.txt", "Testing123");
103         waitAndClick(By.cssSelector("button[title='Add a Note']"));
104 
105         Thread.sleep(2000);
106         waitForTextPresent("Note Text is a required field");
107         assertTextNotPresent("attachment.txt");
108         passed();
109     }
110 
111     private void navigateToPeopleFlowNotesAndAttachments() throws Exception {
112         selectFrameIframePortlet();
113 
114         waitAndClickByLinkText("Create New");
115         waitForElementPresent(
116                 "div[data-header_for='PeopleFlow-MaintenanceView'] div[data-label='Document Number'] > span");
117 
118         waitAndClickByLinkText("Notes and Attachments (0)");
119     }
120 
121     private void waitAndAddAttachment(String fileName, String content) throws Exception {
122         File file = temporaryFolder.newFile(fileName);
123         FileUtils.writeStringToFile(file, content);
124         String path = file.getAbsolutePath().toString();
125         waitAndTypeByName("attachmentFile", path);
126     }
127 }