Search in sources :

Example 1 with InvitationActionConfirmationElement

use of org.xwiki.invitation.test.po.InvitationActionConfirmationElement in project xwiki-platform by xwiki.

the class InvitationTest method testCancelInvitation.

/**
 * This test proves that:
 * 1. A user can cancel an invitation after sending it, leaving a message for the recipient should they try to
 *    accept.
 * 2. A canceled invitation cannot be accepted and the guest will see an explaination with the message left when
 *    the sender canceled.
 * 3. A canceled invitation cannot be declined, the guest gets the sender's note.
 * 4. A canceled invitation can still be reported as spam.
 */
@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testCancelInvitation() throws Exception {
    TestUtils.Session admin = getUtil().getSession();
    try {
        startGreenMail();
        getSenderPage().send();
        getGreenMail().waitForIncomingEmail(10000, 1);
        MimeMessage[] messages = getGreenMail().getReceivedMessages();
        String htmlMessage = getMessageContent(messages[0]).get("htmlPart");
        Assert.assertTrue("New invitation is not listed as pending in the footer.", getSenderPage().getFooter().myPendingInvitations() == 1);
        InspectInvitationsPage.OneMessage message = getSenderPage().getFooter().inspectMyInvitations().getMessageWhere("Subject", "Admin has invited you to join localhost This is a subject line.");
        InvitationActionConfirmationElement confirm = message.cancel();
        Assert.assertEquals("leave a message in case the invitee(s) try to register.", confirm.getLabel().toLowerCase());
        confirm.setMemo("Sorry, wrong email address.");
        Assert.assertEquals("Invitation successfully rescinded.", confirm.confirm());
        // Now switch to guest.
        getUtil().forceGuestUser();
        String commonPart = "\nAdministrator left you this message when rescinding the invitation.\n" + "Sorry, wrong email address.";
        // Prove that invitation cannot be accepted
        InvitationGuestActionsPage guestPage = InvitationGuestActionsPage.gotoPage(htmlMessage, InvitationGuestActionsPage.Action.ACCEPT);
        Assert.assertFalse("Guest was able to accept a message which had been canceled.", guestPage.getMessage().equals(""));
        Assert.assertEquals("We're sorry but this invitation has been rescinded." + commonPart, guestPage.getMessage());
        // Prove that invitation cannot be declined
        guestPage = InvitationGuestActionsPage.gotoPage(htmlMessage, InvitationGuestActionsPage.Action.DECLINE);
        Assert.assertFalse("Guest was able to decline a message which had been canceled.", guestPage.getMessage().equals(""));
        Assert.assertEquals("This invitation has been rescinded and thus cannot be declined." + commonPart, guestPage.getMessage());
        // Prove that the message report spam page still shows up.
        guestPage = InvitationGuestActionsPage.gotoPage(htmlMessage, InvitationGuestActionsPage.Action.REPORT);
        Assert.assertTrue("Guest was not able to report canceled invitation as spam", guestPage.getMessage().equals(""));
        guestPage.setMemo("Canceled message is spam.");
        Assert.assertEquals("Your report has been logged and the situation will " + "be investigated as soon as possible, we apologize for the inconvenience.", guestPage.confirm());
    } finally {
        stopGreenMail();
        getUtil().setSession(admin);
    }
}
Also used : InvitationGuestActionsPage(org.xwiki.invitation.test.po.InvitationGuestActionsPage) TestUtils(org.xwiki.test.ui.TestUtils) InspectInvitationsPage(org.xwiki.invitation.test.po.InspectInvitationsPage) MimeMessage(javax.mail.internet.MimeMessage) InvitationActionConfirmationElement(org.xwiki.invitation.test.po.InvitationActionConfirmationElement) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Aggregations

MimeMessage (javax.mail.internet.MimeMessage)1 Test (org.junit.Test)1 InspectInvitationsPage (org.xwiki.invitation.test.po.InspectInvitationsPage)1 InvitationActionConfirmationElement (org.xwiki.invitation.test.po.InvitationActionConfirmationElement)1 InvitationGuestActionsPage (org.xwiki.invitation.test.po.InvitationGuestActionsPage)1 AbstractTest (org.xwiki.test.ui.AbstractTest)1 TestUtils (org.xwiki.test.ui.TestUtils)1 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)1