/**
  * 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();
 }
 /**
  * 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');
 }
 /**
  * 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');
 }