1 package org.itracker.selenium;
2
3 import com.dumbster.smtp.SimpleSmtpServer;
4 import com.dumbster.smtp.SmtpMessage;
5
6 import java.io.IOException;
7 import java.util.Iterator;
8
9 import org.junit.Test;
10
11
12
13
14
15
16 public class EditIssueTest extends AbstractSeleniumTestCase {
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 @Test
35 public void testEditIssue1FromViewIssue() throws Exception {
36 log.info("running testEditIssue1FromViewIssue");
37 closeSession();
38 selenium.open("http://" + applicationHost + ":" + applicationPort + "/"
39 + applicationPath);
40
41 assertTrue(selenium.isElementPresent("//.[@name='login']"));
42 assertTrue(selenium.isElementPresent("//.[@name='password']"));
43 assertTrue(selenium.isElementPresent("//.[@value='Login']"));
44 selenium.type("//.[@name='login']", "admin_test1");
45 selenium.type("//.[@name='password']", "admin_test1");
46 selenium.click("//.[@value='Login']");
47 selenium.waitForPageToLoad(SE_TIMEOUT);
48
49 selenium.click("listprojects");
50 selenium.waitForPageToLoad(SE_TIMEOUT);
51
52
53 assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'project.')]/td[3][text()='test_name']/../td[1]/a[1]"));
54 selenium.click("//tr[starts-with(@id, 'project.')]/td[3][text()='test_name']/../td[1]/a[1]");
55 selenium.waitForPageToLoad(SE_TIMEOUT);
56
57 assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'issue.')]/td[3][text()='1']/../td[11][text()='test_description']/../td[1]/a[1]"));
58 selenium.click("//tr[starts-with(@id, 'issue.')]/td[3][text()='1']/../td[11][text()='test_description']/../td[1]/a[1]");
59 selenium.waitForPageToLoad(SE_TIMEOUT);
60
61 assertTrue(selenium.isElementPresent("//td[@id='actions']/a[2]"));
62 selenium.click("//td[@id='actions']/a[2]");
63 selenium.waitForPageToLoad(SE_TIMEOUT);
64
65 assertTrue(selenium.isElementPresent("description"));
66 assertTrue(selenium.isElementPresent("ownerId"));
67 assertTrue(selenium.isElementPresent("//input[@type='submit']"));
68
69 selenium.type("description", "test_description (updated)");
70
71
72 startSMTP();
73 try {
74 selenium.click("//input[@type='submit']");
75 selenium.waitForPageToLoad(SE_TIMEOUT);
76
77 assertEquals("smtpServer.receivedEmailSize", 1, smtpServer.getReceivedEmailSize());
78 final Iterator<SmtpMessage> iter =
79 (Iterator<SmtpMessage>) smtpServer.getReceivedEmail();
80
81 final SmtpMessage smtpMessage = iter.next();
82 final String smtpMessageBody = smtpMessage.getBody();
83 assertTrue(smtpMessageBody.contains("test_description (updated)"));
84
85 } finally {
86 stopSMTP();
87 }
88
89
90 assertTrue(selenium.isElementPresent("issues"));
91 assertEquals(4, selenium.getXpathCount("//tr[starts-with(@id, 'issue.')]"));
92 assertFalse(selenium.isElementPresent("//tr[starts-with(@id, 'issue.')]/td[3][text()='1']/../td[11][text()='test_description']/../td[13][contains(text(),'A. admin lastname')]"));
93 assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'issue.')]/td[3][text()='1']/../td[11][text()='test_description (updated)']/../td[13][contains(text(),'A. admin lastname')]"));
94 }
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 @Test
112 public void testEditIssue1FromIssueList() throws Exception {
113 log.info("running testEditIssue1FromIssueList");
114 closeSession();
115 selenium.open("http://" + applicationHost + ":" + applicationPort + "/"
116 + applicationPath);
117
118 assertTrue(selenium.isElementPresent("//.[@name='login']"));
119 assertTrue(selenium.isElementPresent("//.[@name='password']"));
120 assertTrue(selenium.isElementPresent("//.[@value='Login']"));
121 selenium.type("//.[@name='login']", "admin_test1");
122 selenium.type("//.[@name='password']", "admin_test1");
123 selenium.click("//.[@value='Login']");
124 selenium.waitForPageToLoad(SE_TIMEOUT);
125
126 selenium.click("listprojects");
127 selenium.waitForPageToLoad(SE_TIMEOUT);
128
129
130 assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'project.')]/td[3][text()='test_name']/../td[1]/a[1]"));
131 selenium.click("//tr[starts-with(@id, 'project.')]/td[3][text()='test_name']/../td[1]/a[1]");
132 selenium.waitForPageToLoad(SE_TIMEOUT);
133
134 assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'issue.')]/td[3][text()='1']/../td[11][text()='test_description']/../td[1]/a[2]"));
135 selenium.click("//tr[starts-with(@id, 'issue.')]/td[3][text()='1']/../td[11][text()='test_description']/../td[1]/a[2]");
136 selenium.waitForPageToLoad(SE_TIMEOUT);
137
138 assertTrue(selenium.isElementPresent("description"));
139 assertTrue(selenium.isElementPresent("ownerId"));
140 assertTrue(selenium.isElementPresent("//input[@type='submit']"));
141
142 selenium.type("description", "test_description (updated)");
143
144 startSMTP();
145 try {
146 selenium.click("//input[@type='submit']");
147 selenium.waitForPageToLoad(SE_TIMEOUT);
148
149 assertEquals("smtpServer.receivedEmailSize", 1, smtpServer.getReceivedEmailSize());
150 final Iterator<SmtpMessage> iter =
151 (Iterator<SmtpMessage>) smtpServer.getReceivedEmail();
152
153 final SmtpMessage smtpMessage = iter.next();
154 final String smtpMessageBody = smtpMessage.getBody();
155 assertTrue(smtpMessageBody.contains("test_description (updated)"));
156
157 } finally {
158 stopSMTP();
159 }
160
161
162 assertTrue(selenium.isElementPresent("issues"));
163 assertEquals(4, selenium.getXpathCount("//tr[starts-with(@id, 'issue.')]"));
164 assertFalse(selenium.isElementPresent("//tr[starts-with(@id, 'issue.')]/td[3][text()='1']/../td[11][text()='test_description']/../td[13][contains(text(),'A. admin lastname')]"));
165 assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'issue.')]/td[3][text()='1']/../td[11][text()='test_description (updated)']/../td[13][contains(text(),'A. admin lastname')]"));
166 }
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182 @Test
183 public void testMoveIssue1() throws Exception {
184 log.info("running testMoveIssue1");
185 closeSession();
186 selenium.open("http://" + applicationHost + ":" + applicationPort + "/"
187 + applicationPath);
188
189 assertTrue(selenium.isElementPresent("//.[@name='login']"));
190 assertTrue(selenium.isElementPresent("//.[@name='password']"));
191 assertTrue(selenium.isElementPresent("//.[@value='Login']"));
192 selenium.type("//.[@name='login']", "admin_test1");
193 selenium.type("//.[@name='password']", "admin_test1");
194 selenium.click("//.[@value='Login']");
195 selenium.waitForPageToLoad(SE_TIMEOUT);
196
197 selenium.click("listprojects");
198 selenium.waitForPageToLoad(SE_TIMEOUT);
199
200
201 assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'project.')]/td[3][text()='test_name']/../td[1]/a[1]"));
202 selenium.click("//tr[starts-with(@id, 'project.')]/td[3][text()='test_name']/../td[1]/a[1]");
203 selenium.waitForPageToLoad(SE_TIMEOUT);
204
205 assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'issue.')]/td[3][text()='1']/../td[11][text()='test_description']/../td[1]/a[1]"));
206 selenium.click("//tr[starts-with(@id, 'issue.')]/td[3][text()='1']/../td[11][text()='test_description']/../td[1]/a[1]");
207 selenium.waitForPageToLoad(SE_TIMEOUT);
208
209 assertTrue(selenium.isElementPresent("//td[@id='actions']/a[3]"));
210 selenium.click("//td[@id='actions']/a[3]");
211 selenium.waitForPageToLoad(SE_TIMEOUT);
212
213 assertTrue(selenium.isElementPresent("projectId"));
214 selenium.select("projectId", "label=test_name2");
215
216
217 startSMTP();
218 try {
219 selenium.click("//input[@type='submit']");
220 selenium.waitForPageToLoad(SE_TIMEOUT);
221
222 assertEquals("smtpServer.getReceivedEmailSize :?", 0, smtpServer.getReceivedEmailSize());
223
224
225
226
227
228
229
230
231 assertTrue(selenium.isElementPresent("//td[@id='actions']/a[1]"));
232 selenium.click("//td[@id='actions']/a[1]");
233 selenium.waitForPageToLoad(SE_TIMEOUT);
234 } finally {
235 stopSMTP();
236 }
237 assertTrue(selenium.isElementPresent("issues"));
238 assertEquals(1, selenium.getXpathCount("//tr[starts-with(@id, 'issue.')]"));
239 assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'issue.')]/td[3][text()='1']/../td[11][text()='test_description']/../td[13][contains(text(),'A. admin lastname')]"));
240 }
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258 @Test
259 public void testEditIssue2FromViewIssue() throws Exception {
260 log.info("running testEditIssue2FromViewIssue");
261 closeSession();
262 selenium.open("http://" + applicationHost + ":" + applicationPort + "/"
263 + applicationPath);
264
265 assertTrue(selenium.isElementPresent("//.[@name='login']"));
266 assertTrue(selenium.isElementPresent("//.[@name='password']"));
267 assertTrue(selenium.isElementPresent("//.[@value='Login']"));
268 selenium.type("//.[@name='login']", "admin_test1");
269 selenium.type("//.[@name='password']", "admin_test1");
270 selenium.click("//.[@value='Login']");
271 selenium.waitForPageToLoad(SE_TIMEOUT);
272
273 selenium.click("listprojects");
274 selenium.waitForPageToLoad(SE_TIMEOUT);
275
276
277 assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'project.')]/td[3][text()='test_name']/../td[1]/a[1]"));
278 selenium.click("//tr[starts-with(@id, 'project.')]/td[3][text()='test_name']/../td[1]/a[1]");
279 selenium.waitForPageToLoad(SE_TIMEOUT);
280
281 assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'issue.')]/td[3][text()='2']/../td[11][text()='test_description 2']/../td[1]/a[1]"));
282 selenium.click("//tr[starts-with(@id, 'issue.')]/td[3][text()='2']/../td[11][text()='test_description 2']/../td[1]/a[1]");
283 selenium.waitForPageToLoad(SE_TIMEOUT);
284
285 assertEquals("test_description 2", selenium.getText("description"));
286 assertEquals("admin firstname admin lastname", selenium.getText("ownerName"));
287
288 assertTrue(selenium.isElementPresent("//td[@id='actions']/a[2]"));
289 selenium.click("//td[@id='actions']/a[2]");
290 selenium.waitForPageToLoad(SE_TIMEOUT);
291
292 assertTrue("no description", selenium.isElementPresent("description"));
293 assertTrue("no owner", selenium.isElementPresent("ownerId"));
294 assertTrue("no submit", selenium.isElementPresent("//input[@type='submit']"));
295
296 selenium.type("description", "test_description 2 (updated)");
297
298 startSMTP();
299 try {
300 selenium.click("//input[@type='submit']");
301 selenium.waitForPageToLoad(SE_TIMEOUT);
302 assertEquals("smtpServer.receivedEmailSize", 1, smtpServer.getReceivedEmailSize());
303 final Iterator<SmtpMessage> iter =
304 (Iterator<SmtpMessage>) smtpServer.getReceivedEmail();
305
306 final SmtpMessage smtpMessage1 = iter.next();
307 final String smtpMessageBody1 = smtpMessage1.getBody();
308 assertTrue("smtpMessageBody1", smtpMessageBody1.contains("test_description 2 (updated)"));
309
310
311 } finally {
312 stopSMTP();
313 }
314
315 assertTrue(selenium.isElementPresent("issues"));
316 assertEquals(4, selenium.getXpathCount("//tr[starts-with(@id, 'issue.')]"));
317 assertFalse(selenium.isElementPresent("//tr[starts-with(@id, 'issue.')]/td[3][text()='2']/../td[11][text()='test_description 2']/../td[13][contains(text(),'A. admin lastname')]"));
318 assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'issue.')]/td[3][text()='2']/../td[11][text()='test_description 2 (updated)']/../td[13][contains(text(),'A. admin lastname')]"));
319 }
320
321 @Override
322 protected String[] getDataSetFiles
323 () {
324 return new String[]{
325 "dataset/languagebean_init_dataset.xml",
326 "dataset/languagebean_dataset.xml",
327 "dataset/userpreferencesbean_dataset.xml",
328 "dataset/userbean_dataset.xml",
329 "dataset/projectbean_dataset.xml",
330 "dataset/permissionbean_dataset.xml",
331 "dataset/versionbean_dataset.xml",
332 "dataset/issuebean_dataset.xml",
333 "dataset/issueversionrel_dataset.xml",
334 "dataset/issueactivitybean_dataset.xml",
335 "dataset/issuehistorybean_dataset.xml"
336 };
337 }
338
339 @Override
340 protected String[] getConfigLocations
341 () {
342 return new String[]{"application-context.xml"};
343 }
344 }