/**
  * Creates a test scenario in which 2 users send each other e-mails
  * to create a conversation. It does the following steps:
  * 1 - User 1 logs in and sends an e-mail;
  * 2 - User 2 logs in and replies the e-mail back to user 1;
  * 3 - User 1 logs in again and re-replies the e-mail back to user 2.
  * At the end of this procedures, there will be the following situation:
  * a) System will be at the login screen and
  * b) User 2 will have a 2 message conversation in his Inbox 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.
  * "user1" => login for first user,
  * "password1" => password for first user,
  * "user2" => login for second user,
  * "password1" => password for second user,
  * "mail2" => e-mail address for the second user,
  * "subject" => subject of the e-mails of the conversation
  * "content" => content of the e-mails of the conversation
  */
 public static function create2MessageConversation(ExpressoLiteTest $test, $params)
 {
     //testStart - part one
     $test->doLogin($params->user1, $params->password1);
     $mailPage = new MailPage($test);
     $mailPage->sendMail(array($params->mail2), $params->subject, $params->content);
     $mailPage->clickLogout();
     // Second user
     $test->doLogin($params->user2, $params->password2);
     $mailPage->waitForEmailToArrive($params->subject);
     $mailPage->clickOnHeadlineBySubject($params->subject);
     $widgetMessages = $mailPage->getWidgetMessages();
     $messageUnit = $widgetMessages->getSingleMessageUnitInConversation();
     $messageUnit->clickMenuOptionReply();
     $widgetCompose = $mailPage->getWidgetCompose();
     $widgetCompose->typeMessageBodyBeforeSignature('Reply Content: ' . $params->content);
     $widgetCompose->clickSendMailButton();
     $widgetCompose->waitForAjaxAndAnimations();
     $mailPage->clickLayoutBackButton();
     $mailPage->clickLogout();
     // Re-login of sender
     $test->doLogin($params->user1, $params->password1);
     $reSubject = 'Re: ' . $params->subject;
     $mailPage->waitForEmailToArrive($reSubject);
     $mailPage->clickOnHeadlineBySubject($reSubject);
     $widgetMessages = $mailPage->getWidgetMessages();
     $messageUnit = $widgetMessages->getSingleMessageUnitInConversation();
     $messageUnit->clickMenuOptionReply();
     $widgetCompose = $mailPage->getWidgetCompose();
     $widgetCompose->typeMessageBodyBeforeSignature('Reply of Reply Content: ' . $params->content);
     $widgetCompose->clickSendMailButton();
     $widgetCompose->waitForAjaxAndAnimations();
     $mailPage->clickLayoutBackButton();
     $mailPage->clickLogout();
 }
 /**
  * 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 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:
  *
  * - 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');
 }
 /**
  * Overview:
  *
  * - This teste checks if the message has the search criteria in the folder.
  *
  * - CTV3-893
  *   http://comunidadeexpresso.serpro.gov.br/testlink/linkto.php?tprojectPrefix=CTV3&item=testcase&id=CTV3-893
  */
 public function test_CTV3_893_Find_Search_Text()
 {
     $mailPage = new MailPage($this);
     //load test data
     $MAIL_RECIPENT = $this->getGlobalValue('user.1.email');
     $MAIL1_SUBJECT = $this->getTestValue('mail1.subject');
     $MAIL1_CONTENT = $this->getTestValue('mail1.content');
     $MAIL2_SUBJECT = $this->getTestValue('mail2.subject');
     $MAIL2_CONTENT = $this->getTestValue('mail2.content');
     $MAIL3_SUBJECT = $this->getTestValue('mail3.subject');
     $MAIL3_CONTENT = $this->getTestValue('mail3.content');
     $COMMON_TEXT_FRAGMENT = $this->getTestValue('common.text.fragment');
     $INEXISTENT_TEXT_FRAGMENT = $this->getTestValue('inexistent.text.fragment');
     //testStart
     $mailPage->sendMail(array($MAIL_RECIPENT), $MAIL1_SUBJECT, $MAIL1_CONTENT);
     $this->waitForAjaxAndAnimations();
     $mailPage->sendMail(array($MAIL_RECIPENT), $MAIL2_SUBJECT, $MAIL2_CONTENT);
     $this->waitForAjaxAndAnimations();
     $mailPage->sendMail(array($MAIL_RECIPENT), $MAIL2_SUBJECT, $MAIL2_CONTENT);
     $this->waitForAjaxAndAnimations();
     $mailPage->sendMail(array($MAIL_RECIPENT), $MAIL3_SUBJECT, $MAIL3_CONTENT);
     $this->waitForAjaxAndAnimations();
     $mailPage->waitForEmailToArrive($MAIL1_SUBJECT);
     $mailPage->waitForEmailToArrive($MAIL2_SUBJECT);
     $mailPage->waitForEmailToArrive($MAIL3_SUBJECT);
     $mailPage->typeSearchText($COMMON_TEXT_FRAGMENT);
     $mailPage->clickSearchButton();
     $this->waitForAjaxAndAnimations();
     $messages = $mailPage->getArrayOfHeadlinesEntries();
     $this->assertEquals(3, count($messages), 'There are diferent number of messages after find criteria applied');
     $mailPage->clearSearchField();
     $mailPage->clickSearchButton();
     $this->waitForAjaxAndAnimations();
     $mailPage->typeSearchText($INEXISTENT_TEXT_FRAGMENT);
     $mailPage->clickSearchButton();
     $this->waitForAjaxAndAnimations();
     $messages = $mailPage->getArrayOfHeadlinesEntries();
     $this->assertEquals(0, count($messages), 'The total of messages differs from zero after find criteria applied');
 }
 /**
  * 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');
 }
 /**
  * Checks the reply e-mail feature. In this test, user 1 sends an e-mail
  * to new user and this recipient is saved in the personal catalog
  *
  * CTV3-1015
  * http://comunidadeexpresso.serpro.gov.br/testlink/linkto.php?tprojectPrefix=CTV3&item=testcase&id=CTV3-1015
  */
 public function test_CTV3_1015_Send_Mail_Saved_Recipient()
 {
     //load test data
     $SENDER_LOGIN = $this->getGlobalValue('user.1.login');
     $SENDER_PASSWORD = $this->getGlobalValue('user.1.password');
     $RECIPIENT_MAIL = $this->getTestValue('recipient.mail');
     $RECIPIENT_NAME = $this->getTestValue('recipient.name');
     $MAIL_SUBJECT = $this->getTestValue('mail.subject');
     $MAIL_CONTENT = $this->getTestValue('mail.content');
     //testStart
     $loginPage = new LoginPage($this);
     $loginPage->doLogin($SENDER_LOGIN, $SENDER_PASSWORD);
     $mailPage = new MailPage($this);
     $mailPage->sendMail(array($RECIPIENT_MAIL), $MAIL_SUBJECT, $MAIL_CONTENT);
     $mailPage->clickAddressbook();
     $addressbookPage = new AddressbookPage($this);
     $addressbookPage->clickPersonalCatalog();
     $this->waitForAjaxAndAnimations();
     $contactListItem = $addressbookPage->getCatalogEntryByName($RECIPIENT_NAME);
     $this->assertEquals($RECIPIENT_NAME, $contactListItem->getNameFromContact(), 'Mail was send but, the new recipient is not created in personal catalog ');
 }
 public function test_Ctv3_1027_Check_Edit_Personal_Contact()
 {
     $USER_LOGIN = $this->getGlobalValue('user.1.login');
     $USER_PASSWORD = $this->getGlobalValue('user.1.password');
     $CONTACT_1_EMAIL = $this->getTestValue('contact.1.mail');
     $CONTACT_1_NAME = $this->getTestValue('contact.1.name');
     $FIELD_COMPANY = $this->getTestValue('field.company');
     $MAIL_SUBJECT = $this->getTestValue('mail.subject');
     $MAIL_CONTENT = $this->getTestValue('mail.content');
     //testStart
     $loginPage = new LoginPage($this);
     $loginPage->doLogin($USER_LOGIN, $USER_PASSWORD);
     //Sending an e-mail to generate the personal contact to be used in the test
     $mailPage = new MailPage($this);
     $mailPage->sendMail(array($CONTACT_1_EMAIL), $MAIL_SUBJECT, $MAIL_CONTENT);
     $mailPage->clickAddressbook();
     $addressbookPage = new AddressbookPage($this);
     $addressbookPage->clickPersonalCatalog();
     $this->waitForAjaxAndAnimations();
     $mailPage->clearSearchField();
     $mailPage->typeSearchText($CONTACT_1_NAME);
     $mailPage->clickSearchButton();
     $this->waitForAjaxAndAnimations();
     $contactListItem = $addressbookPage->getCatalogEntryByName($CONTACT_1_NAME);
     $contactListItem->click();
     $this->waitForAjaxAndAnimations();
     $widgetContactDetails = $addressbookPage->getWidgetContactDetails();
     // Checking other fields will only be possible when the system allows personal contact edition
     $this->assertEquals('true', $widgetContactDetails->isReadonlyField($FIELD_COMPANY), "The field '{$FIELD_COMPANY}' is not readonly");
 }
 /**
  * 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');
 }