/**
  * Overview:
  *
  * - This teste checks if the message changes its highlight status.
  *
  * - CTV3-892
  *   http://comunidadeexpresso.serpro.gov.br/testlink/linkto.php?tprojectPrefix=CTV3&item=testcase&id=CTV3-892
  *
  */
 public function test_CTV3_892_ToggleHighlightMail()
 {
     $mailPage = new MailPage($this);
     //load test data
     $MAIL_RECIPENT = $this->getGlobalValue('user.1.email');
     $MAIL_SUBJECT = $this->getTestValue('mail.subject');
     //testStart
     $mailPage->sendMail(array($MAIL_RECIPENT), $MAIL_SUBJECT, 'Changes its highlight');
     $this->waitForAjaxAndAnimations();
     $mailPage->clickRefreshButton();
     $mailPage->waitForEmailToArrive($MAIL_SUBJECT);
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $headlinesEntry->toggleCheckbox();
     $mailPage->clickMenuOptionHighlight();
     $this->waitForAjaxAndAnimations();
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $this->assertTrue($headlinesEntry->hasHighlightIcon(), 'Headline should have been listed as highlight, but it was not (BEFORE a refresh)');
     $mailPage->clickRefreshButton();
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $this->assertTrue($headlinesEntry->hasHighlightIcon(), 'Headline should have been listed as highlight, but it was not (AFTER a refresh)');
     $headlinesEntry->toggleCheckbox();
     $mailPage->clickMenuOptionHighlight();
     $this->waitForAjaxAndAnimations();
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $this->assertFalse($headlinesEntry->hasHighlightIcon(), 'Headline should not have been listed as highlight, but it was (BEFORE a refresh)');
     $mailPage->clickRefreshButton();
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $this->assertFalse($headlinesEntry->hasHighlightIcon(), 'Headline should not have been listed as highlight, but it was(AFTER a refresh)');
 }
 /**
  * Overview:
  *
  * - Deletes an opened email message. Sends an e-mail to youself, then checks
  *   if the message is in the Sent folder and then deletes it with option
  *   "Apagar" of the message menu. After that, it checks if the message was
  *   sent to the thash box.
  *
  * - CTV3-751
  *   http://comunidadeexpresso.serpro.gov.br/testlink/linkto.php?tprojectPrefix=CTV3&item=testcase&id=CTV3-751
  */
 public function test_CTV3_751_Delete_Open_Mail()
 {
     //load test data
     $USER_LOGIN = $this->getGlobalValue('user.1.login');
     $USER_PASSWORD = $this->getGlobalValue('user.1.password');
     $USER_MAIL = $this->getGlobalValue('user.1.email');
     $MAIL_SUBJECT = $this->getTestValue('mail.subject');
     $MAIL_CONTENT = $this->getTestValue('mail.content');
     $this->doLogin($USER_LOGIN, $USER_PASSWORD);
     $mailPage = new MailPage($this);
     $mailPage->sendMail(array($USER_MAIL), $MAIL_SUBJECT, $MAIL_CONTENT);
     //testStart
     $this->waitForAjaxAndAnimations();
     $mailPage->clickRefreshButton();
     $mailPage->waitForEmailToArrive($MAIL_SUBJECT);
     $mailPage->clickOnHeadlineBySubject($MAIL_SUBJECT);
     $widgetMessages = $mailPage->getWidgetMessages();
     $messageUnit = $widgetMessages->getSingleMessageUnitInConversation();
     $this->waitForAjaxAndAnimations();
     $messageUnit->clickMenuOptionDelete();
     $this->waitForAjaxAndAnimations();
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $this->assertNull($headlinesEntry, 'Mail was deleted, but it was not removed from headlines listing');
     $mailPage->clickOnFolderByName('Lixeira');
     $this->waitForAjaxAndAnimations();
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $this->assertNotNull($headlinesEntry, 'Mail was deleted, but could not be found in the trash bin');
 }
 /**
  * Overview:
  *
  * - This test opens the details of a message and uses option "Mover para...
  *   Modelos" of the message menu to move the message to that folder. After
  *   that, checks if the message is no longer in Inbox and is now in Modelos folder.
  *
  * - CTV3-1019
  *   http://comunidadeexpresso.serpro.gov.br/testlink/linkto.php?tprojectPrefix=CTV3&item=testcase&id=CTV3-1019
  *
  */
 public function test_CTV3_1019_Move_Open_Mail()
 {
     $mailPage = new MailPage($this);
     //load test data
     $MAIL_RECIPIENT = $this->getGlobalValue('user.1.email');
     $MAIL_SUBJECT = $this->getTestValue('mail.subject');
     //testStart
     $mailPage->sendMail(array($MAIL_RECIPIENT), $MAIL_SUBJECT, 'Move open email to Modelos folder');
     $this->waitForAjaxAndAnimations();
     $mailPage->clickRefreshButton();
     $mailPage->waitForEmailToArrive($MAIL_SUBJECT);
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $headlinesEntry->click();
     $this->waitForAjaxAndAnimations();
     $widgetMessages = $mailPage->getWidgetMessages();
     $messageUnit = $widgetMessages->getSingleMessageUnitInConversation();
     $messageUnit->clickMenuOptionMove('Modelos');
     $this->waitForAjaxAndAnimations();
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $this->assertNull($headlinesEntry, 'A mail with subject $MAIL_SUBJECT was moved, it could still be found in the inbox folder');
     $mailPage->clickOnFolderByName('Modelos');
     $this->waitForAjaxAndAnimations();
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $this->assertNotNull($headlinesEntry, 'A mail with subject $MAIL_SUBJECT was moved, but it could not be found on Modelos folder');
 }
 /**
  * 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');
 }
 /**
  * Overview:
  * This test ,it is open and close the message.Selects and marks a message and
  * clicks the "Marcar como não lida" in menu option. Checks if the message was
  * really marked as unread
  *
  * - CTV3-1057
  *   http://comunidadeexpresso.serpro.gov.br/testlink/linkto.php?tprojectPrefix=CTV3&item=testcase&id=CTV3-1057
  */
 public function test_CTV3_1057_MarkUnreadOpenMail()
 {
     $mailPage = new MailPage($this);
     //load test data
     $MAIL_RECIPENT = $this->getGlobalValue('user.1.email');
     $MAIL_SUBJECT = $this->getTestValue('mail.subject');
     //testStart
     $mailPage->sendMail(array($MAIL_RECIPENT), $MAIL_SUBJECT, 'Marcando como não lido');
     $this->waitForAjaxAndAnimations();
     $mailPage->clickRefreshButton();
     $mailPage->waitForEmailToArrive($MAIL_SUBJECT);
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $headlinesEntry->click();
     $this->waitForAjaxAndAnimations();
     $widgetMessages = $mailPage->getWidgetMessages();
     $messageUnit = $widgetMessages->getSingleMessageUnitInConversation();
     $messageUnit->clickMenuOptionMove('Marcar como não lida');
     $this->waitForAjaxAndAnimations();
     $headlinesEntry = $mailPage->getHeadlinesEntryBySubject($MAIL_SUBJECT);
     $this->assertEquals(HeadlinesEntry::UNREAD_STATUS, $headlinesEntry->getReadStatus(), 'The message was marked as "Unread", but it was not changed');
 }