This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
/
ContactAdminTest.java
84 lines (67 loc) · 2.89 KB
/
ContactAdminTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package org.zanata.feature.misc;
import java.util.List;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.subethamail.wiser.WiserMessage;
import org.zanata.feature.Feature;
import org.zanata.feature.testharness.ZanataTestCase;
import org.zanata.feature.testharness.TestPlan.DetailedTest;
import org.zanata.page.dashboard.DashboardBasePage;
import org.zanata.page.utility.ContactAdminFormPage;
import org.zanata.page.utility.HelpPage;
import org.zanata.util.AddUsersRule;
import org.zanata.util.Constants;
import org.zanata.util.HasEmailRule;
import org.zanata.util.PropertiesHolder;
import org.zanata.workflow.LoginWorkFlow;
import static org.assertj.core.api.Assertions.assertThat;
import static org.zanata.util.FunctionalTestHelper.loosely;
/**
* @author Patrick Huang <a
* href="mailto:pahuang@redhat.com">pahuang@redhat.com</a>
*/
@Category(DetailedTest.class)
public class ContactAdminTest extends ZanataTestCase {
@Rule
public AddUsersRule addUsersRule = new AddUsersRule();
@Rule
public HasEmailRule emailRule = new HasEmailRule();
@Feature(summary = "The user can contact the site administrator",
tcmsTestPlanIds = 5316, tcmsTestCaseIds = 181717)
@Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION)
public void testContactAdmin() {
DashboardBasePage dashboard =
new LoginWorkFlow().signIn("translator", "translator");
ContactAdminFormPage contactAdminFormPage =
dashboard.goToHelp().clickContactAdmin();
HelpPage helpPage = contactAdminFormPage
.inputSubject("hello admin")
.inputMessage("I love Zanata")
.send();
assertThat(helpPage.expectNotification("Your message has been sent " +
"to the administrator"))
.isTrue()
.as("An email sent notification shows");
List<WiserMessage> messages = emailRule.getMessages();
assertThat(messages.size())
.isEqualTo(1)
.as("One email was sent");
WiserMessage wiserMessage = messages.get(0);
assertThat(wiserMessage.getEnvelopeReceiver())
.isEqualTo("admin@example.com")
.as("The email recipient is the administrator");
String content = HasEmailRule.getEmailContent(wiserMessage);
assertThat(content)
.contains("You are receiving this mail because:")
.contains("You are an administrator")
.contains("I love Zanata");
// contains instance url (without last slash)
String instanceUrl = PropertiesHolder.getProperty(
Constants.zanataInstance.value()).replaceAll("/$", "");
assertThat(content)
.contains(instanceUrl)
.as("The email origin (server) is correct");
}
}