/**
  * Checks the forward e-mail feature. In this test, user 1 sends an e-mail
  * to user 2, who forward to user 3
  *
  * CTV3-758
  * http://comunidadeexpresso.serpro.gov.br/testlink/linkto.php?tprojectPrefix=CTV3&item=testcase&id=CTV3-758
  */
 public function test_CTV3_758_SendReceiveFowardOpenMail()
 {
     //load test data
     $USER_1_LOGIN = $this->getGlobalValue('user.1.login');
     $USER_1_PASSWORD = $this->getGlobalValue('user.1.password');
     $USER_2_LOGIN = $this->getGlobalValue('user.2.login');
     $USER_2_PASSWORD = $this->getGlobalValue('user.2.password');
     $USER_2_MAIL = $this->getGlobalValue('user.2.email');
     $USER_3_LOGIN = $this->getGlobalValue('user.3.login');
     $USER_3_PASSWORD = $this->getGlobalValue('user.3.password');
     $USER_3_MAIL = $this->getGlobalValue('user.3.email');
     $USER_3_BADGE = $this->getGlobalValue('user.3.badge');
     $MAIL_SUBJECT = $this->getTestValue('mail.subject');
     $ORIGINAL_MAIL_CONTENT = $this->getTestValue('original.mail.content');
     $FORWARD_MAIL_CONTENT = $this->getTestValue('forward.mail.content');
     //testStart
     $loginPage = new LoginPage($this);
     $loginPage->doLogin($USER_1_LOGIN, $USER_1_PASSWORD);
     $mailPage = new MailPage($this);
     $mailPage->sendMail(array($USER_2_MAIL), $MAIL_SUBJECT, $ORIGINAL_MAIL_CONTENT);
     $mailPage->clickLogout();
     $loginPage->doLogin($USER_2_LOGIN, $USER_2_PASSWORD);
     $mailPage->waitForEmailToArrive($MAIL_SUBJECT);
     $mailPage->clickOnHeadlineBySubject($MAIL_SUBJECT);
     $widgetMessages = $mailPage->getWidgetMessages();
     $messageUnit = $widgetMessages->getSingleMessageUnitInConversation();
     $messageUnit->clickMenuOptionForward();
     $widgetCompose = $mailPage->getWidgetCompose();
     $FORWARD_SUBJECT = 'Fwd: ' . $MAIL_SUBJECT;
     $widgetCompose->clickOnRecipientField();
     $widgetCompose->type($USER_3_MAIL);
     $widgetCompose->typeEnter();
     $widgetCompose->typeMessageBodyBeforeSignature($FORWARD_MAIL_CONTENT);
     $this->assertEquals(array($USER_3_BADGE), $widgetCompose->getArrayOfCurrentBadges(), 'Forward window did not show the expected recipient');
     $this->assertEquals($FORWARD_SUBJECT, $widgetCompose->getSubject(), 'Forward window did not the expected subject');
     $this->assertContains($ORIGINAL_MAIL_CONTENT, $widgetCompose->getMessageBodyText());
     $widgetCompose->clickSendMailButton();
     $this->waitForAjaxAndAnimations();
     $mailPage->clickLayoutBackButton();
     $this->waitForAjaxAndAnimations();
     $mailPage->clickLogout();
     $loginPage->doLogin($USER_3_LOGIN, $USER_3_PASSWORD);
     $mailPage = new MailPage($this);
     $mailPage->waitForEmailToArrive($FORWARD_SUBJECT);
     $mailPage->clickOnHeadlineBySubject($FORWARD_SUBJECT);
     $widgetMessages = $mailPage->getWidgetMessages();
     $messageUnit = $widgetMessages->getSingleMessageUnitInConversation();
     $this->assertContains($FORWARD_MAIL_CONTENT, $messageUnit->getContent(), 'The forwarded message content was not found in the forward body');
     $this->assertTrue($messageUnit->hasShowQuoteButton(), 'The forwarded message did not show the Show Quote button');
     $messageUnit->clickShowQuoteButton();
     $this->assertContains($ORIGINAL_MAIL_CONTENT, $messageUnit->getQuoteText(), 'The original message content was not found in the mail quote section');
 }
 /**
  * Description:
  * - This test checks the reading of an e-mail with a citation in its body.
  *   It performs the following verifications: 1) checks if the message content
  *   matches the original reply from the other user; 2) Checks if there is a
  *   "Show Quote" button; 3) Checks if the citation content matches the content
  *   of the original e-mail
  *
  * - CTV3-1047
  *   http://comunidadeexpresso.serpro.gov.br/testlink/linkto.php?tprojectPrefix=CTV3&item=testcase&id=CTV3-1047
  */
 public function test_CTV3_1047_ReadCitationMail()
 {
     //load test data
     $USER_1_LOGIN = $this->getGlobalValue('user.1.login');
     $USER_1_PASSWORD = $this->getGlobalValue('user.1.password');
     $USER_2_LOGIN = $this->getGlobalValue('user.2.login');
     $USER_2_PASSWORD = $this->getGlobalValue('user.2.password');
     $USER_2_MAIL = $this->getGlobalValue('user.2.email');
     $MAIL_SUBJECT = $this->getTestValue('mail.subject');
     $ORIGINAL_MAIL_CONTENT = $this->getTestValue('original.mail.content');
     $REPLY_MAIL_CONTENT = $this->getTestValue('reply.mail.content');
     //testStart - part one
     $this->doLogin($USER_1_LOGIN, $USER_1_PASSWORD);
     $mailPage = new MailPage($this);
     $mailPage->sendMail(array($USER_2_MAIL), $MAIL_SUBJECT, $ORIGINAL_MAIL_CONTENT);
     $mailPage->clickLogout();
     // Second user
     $this->doLogin($USER_2_LOGIN, $USER_2_PASSWORD);
     $mailPage->waitForEmailToArrive($MAIL_SUBJECT);
     $mailPage->clickOnHeadlineBySubject($MAIL_SUBJECT);
     $widgetMessages = $mailPage->getWidgetMessages();
     $messageUnit = $widgetMessages->getSingleMessageUnitInConversation();
     $messageUnit->clickMenuOptionReply();
     $widgetCompose = $mailPage->getWidgetCompose();
     $REPLY_SUBJECT = 'Re: ' . $MAIL_SUBJECT;
     $widgetCompose->typeMessageBodyBeforeSignature($REPLY_MAIL_CONTENT);
     $widgetCompose->clickSendMailButton();
     $this->waitForAjaxAndAnimations();
     $mailPage->clickLayoutBackButton();
     $mailPage->clickLogout();
     $this->doLogin($USER_1_LOGIN, $USER_1_PASSWORD);
     $mailPage->waitForEmailToArrive($REPLY_SUBJECT);
     $mailPage->clickOnHeadlineBySubject($REPLY_SUBJECT);
     $widgetMessages = $mailPage->getWidgetMessages();
     $messageUnit = $widgetMessages->getSingleMessageUnitInConversation();
     $this->waitForAjaxAndAnimations();
     $this->assertContains($REPLY_MAIL_CONTENT, $messageUnit->getContent(), 'The replied message content was not found in the reply body');
     $this->assertTrue($messageUnit->hasShowQuoteButton(), 'The replied message did not show the Show Quote button');
     $messageUnit->clickShowQuoteButton();
     $this->assertContains($ORIGINAL_MAIL_CONTENT, $messageUnit->getQuoteText(), 'The original message content was not found in the mail quote section');
 }
 /**
  * In this test, the e-mail was created and saved in draft folder. Checks if
  * turn on the important flag.
  *
  * CTV3-843
  * http://comunidadeexpresso.serpro.gov.br/testlink/linkto.php?tprojectPrefix=CTV3&item=testcase&id=CTV3-843
  */
 public function test_CTV3_843_Save_Draft_Important_Flag()
 {
     $mailPage = new MailPage($this);
     //load test data
     $MAIL_RECIPIENT = $this->getGlobalValue('user.1.email');
     $MAIL_SUBJECT = $this->getTestValue('mail.subject');
     $MAIL_CONTENT = $this->getTestValue('mail.content');
     //testStart
     $mailPage->clickWriteEmailButton();
     $widgetCompose = $mailPage->getWidgetCompose();
     $widgetCompose->clickOnRecipientField();
     $widgetCompose->type($MAIL_RECIPIENT);
     $widgetCompose->typeEnter();
     $widgetCompose->typeSubject($MAIL_SUBJECT);
     $widgetCompose->typeMessageBodyBeforeSignature($MAIL_CONTENT);
     $widgetCompose->clickImportantRadio();
     $widgetCompose->clickSaveDraftButton();
     $this->assertFalse($widgetCompose->isDisplayed(), 'Compose Window should have been closed, but it is still visible');
     $mailPage->clickOnFolderByName('Rascunhos');
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $this->assertTrue($headlinesEntry->hasImportantIcon(), 'Headline should have been listed as important, but it was not');
     $headlinesEntry->click();
     $this->waitForAjaxAndAnimations();
     $widgetCompose = $mailPage->getWidgetCompose();
     $this->assertTrue($widgetCompose->isImportantCheckboxChecked(), 'Checkbox was marked as important, but it was not');
 }
 /**
  * Creates a test scenario to create a message in draft folder
  *
  * @param ExpressoLiteTest $test The test case that will create the scenario
  * @param stdObj $params A object containing all the necessary parameters for this scenario.
  * This object must have the following fields.
  *
  * senderLogin => login of the user that will create the draft
  * senderPassword => password of the user that will create the draft
  * recipentMail => the draft recipent's e-mail address
  * subject => subject of the draft
  * content => content of the draft
  */
 public static function createMessageDraft(ExpressoLiteTest $test, $params)
 {
     $test->doLogin($params->senderLogin, $params->senderPassword);
     $mailPage = new MailPage($test);
     $mailPage->clickWriteEmailButton();
     $widgetCompose = $mailPage->getWidgetCompose();
     $widgetCompose->clickOnRecipientField();
     $widgetCompose->type($params->recipentMail);
     $widgetCompose->typeEnter();
     $widgetCompose->typeSubject($params->subject);
     $widgetCompose->typeMessageBodyBeforeSignature($params->content);
     $widgetCompose->clickSaveDraftButton();
     $widgetCompose->waitForAjaxAndAnimations();
     $mailPage->clickLogout();
 }
 /**
  * Tests sending a simple e-mail,with cc and checking if the e-mail composition
  * screen opens and close as expected. Also checks if the recipients copy receives
  * the e-mail.
  *
  *   CTV3-1052
  *   http://comunidadeexpresso.serpro.gov.br/testlink/linkto.php?tprojectPrefix=CTV3&item=testcase&id=CTV3-1052
  */
 public function test_CTV3_1052_Send_Bcc_Mail()
 {
     $mailPage = new MailPage($this);
     //load test data
     $MAIL_BCC_RECIPIENT = $this->getGlobalValue('user.2.email');
     $MAIL_SENDER = $this->getGlobalValue('user.2.email');
     $MAIL_SUBJECT = $this->getTestValue('mail.subject');
     $MAIL_CONTENT = $this->getTestValue('mail.content');
     //testStart
     $mailPage->clickWriteEmailButton();
     $widgetCompose = $mailPage->getWidgetCompose();
     $this->assertTrue($widgetCompose->isDisplayed(), 'Compose Window should be displayed, but it is not');
     $widgetCompose->clickOnBccToggleButton();
     $this->waitForAjaxAndAnimations();
     $widgetCompose->type($MAIL_BCC_RECIPIENT);
     $widgetCompose->typeEnter();
     $widgetCompose->typeSubject($MAIL_SUBJECT);
     $widgetCompose->typeMessageBodyBeforeSignature($MAIL_CONTENT);
     $widgetCompose->clickSendMailButton();
     $this->waitForAjaxAndAnimations();
     $this->assertFalse($widgetCompose->isDisplayed(), 'Compose Window should have been closed, but it is still visible');
     $mailPage->clickRefreshButton();
     $this->waitForAjaxAndAnimations();
     $mailPage->waitForEmailToArrive($MAIL_SUBJECT);
     $headlinesEntry = $mailPage->clickOnHeadlineBySubject($MAIL_SUBJECT);
     $widgetMessages = $mailPage->getWidgetMessages();
     $messageUnit = $widgetMessages->getSingleMessageUnitInConversation();
     $this->assertContains('(ninguém)', $messageUnit->getToAddresses(), 'The to address content differs from the expected');
     $this->assertFalse($messageUnit->isBccAddressesDisplayed(), 'Bcc tag should not have been displayed, but it was');
     $mailPage->clickLayoutBackButton();
     $this->waitForAjaxAndAnimations();
     $mailPage->clickOnFolderByName('Enviados');
     $this->waitForAjaxAndAnimations();
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $this->assertNotNull($headlinesEntry, "A mail with subject {$MAIL_SUBJECT} was sent, but it could not be found on Sent folder");
     $headlinesEntry->click();
     $this->waitForAjaxAndAnimations();
     $widgetMessages = $mailPage->getWidgetMessages();
     $messageUnit = $widgetMessages->getSingleMessageUnitInConversation();
     $this->assertContains('(ninguém)', $messageUnit->getToAddresses(), 'The to address content differs from the expected');
     $this->assertEquals("({$MAIL_SENDER})", $messageUnit->getFromMail(), 'Message sender mail does not match');
     $this->assertContains("{$MAIL_SENDER}", $messageUnit->getBccAddresses(), 'Message bcc recipient mail does not match');
 }
 public function test_CTV3_845_Send_Draft()
 {
     $USER_LOGIN = $this->getGlobalValue('user.1.login');
     $USER_PASSWORD = $this->getGlobalValue('user.1.password');
     $RECIPIENT_1_MAIL = $this->getGlobalValue('user.2.email');
     $MAIL_SUBJECT = $this->getTestValue('mail.subject');
     $MAIL_CONTENT = $this->getTestValue('mail.content');
     TestScenarios::createMessageDraft($this, (object) array('senderLogin' => $USER_LOGIN, 'senderPassword' => $USER_PASSWORD, 'recipentMail' => $RECIPIENT_1_MAIL, 'subject' => $MAIL_SUBJECT, 'content' => $MAIL_CONTENT));
     $this->doLogin($USER_LOGIN, $USER_PASSWORD);
     $mailPage = new MailPage($this);
     $mailPage->clickOnFolderByName('Rascunhos');
     $mailPage->clickOnHeadlineBySubject($MAIL_SUBJECT);
     $this->waitForAjaxAndAnimations();
     $widgetCompose = $mailPage->getWidgetCompose();
     $widgetCompose->clickSendMailButton();
     $this->waitForAjaxAndAnimations();
     $this->assertFalse($widgetCompose->isDisplayed(), 'Compose draft window should have been closed, but it is still visible');
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $this->assertNull($headlinesEntry, "A mail with subject {$MAIL_SUBJECT} was not sent, but it could be found on Draft folder");
     $mailPage->clickOnFolderByName('Enviados');
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $this->assertNotNull($headlinesEntry, "A mail with subject {$MAIL_SUBJECT} was sent, but it could not be found on Sent folder");
 }