Assert.assertTrue("New invitation is not listed as pending in the footer.",
getSenderPage().getFooter().myPendingInvitations() == 1);
// Now switch to guest.
getUtil().forceGuestUser();
InvitationGuestActionsPage guestPage =
InvitationGuestActionsPage.gotoPage(htmlMessage, InvitationGuestActionsPage.Action.DECLINE);
guestPage.setMemo("I'm not interested thank you.");
guestPage.confirm();
Assert.assertTrue("Failed to decline invitation",
getDriver().getPageSource().contains("This invitation has successfully been declined."));
// Switch to admin
getUtil().setSession(admin);
// Go to invitation sender.
setSenderPage(InvitationSenderPage.gotoPage());
Assert.assertTrue("Declined invitation is still listed as pending in the footer.",
getSenderPage().getFooter().spamReports() == 0);
// View declined invitation.
InspectInvitationsPage inspectPage = getSenderPage().getFooter().inspectMyInvitations();
InspectInvitationsPage.OneMessage inspect = inspectPage.getMessageWhere("Status", "Declined");
Assert.assertTrue("Not showing message box to say the invitation has been declined",
inspect.getStatusAndMemo().equals("Declined with message: I'm not interested thank you."));
// Insure the message history table is correct.
TableElement messageHistoryTable = inspect.clickMessageHistory();
List<WebElement> row2 = messageHistoryTable.getRow(2);
Assert.assertTrue("Message history table not showing correctly.",
row2.get(0).getText().equals("Declined"));
Assert.assertTrue("Message history table not showing correctly.",
row2.get(2).getText().equals("I'm not interested thank you."));
// Make sure a guest can't accept the invitation now.
getUtil().forceGuestUser();
guestPage = InvitationGuestActionsPage.gotoPage(htmlMessage, InvitationGuestActionsPage.Action.ACCEPT);
Assert.assertTrue("After a message is declined a user can still accept it!",
guestPage.getMessage().equals("This invitation has been declined and cannot be accepted now."));
// Try to decline the invitation.
guestPage = InvitationGuestActionsPage.gotoPage(htmlMessage, InvitationGuestActionsPage.Action.DECLINE);
Assert.assertTrue("User was allowed to decline an invitation twice.",
guestPage.getMessage().equals("This invitation has already been declined and "
+ "cannot be declined again."));
// Prove that the message can still be reported as spam
guestPage = InvitationGuestActionsPage.gotoPage(htmlMessage, InvitationGuestActionsPage.Action.REPORT);
Assert.assertTrue("After the invitation was declined it now cannot be reported as spam.",
guestPage.getMessage().equals(""));
} finally {
stopGreenMail();
getUtil().setSession(admin);
}
}