Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/Codeception/_support/Step/Acceptance/Administrator/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,31 @@ public function seeSystemMessage($text, $timeout = null)
$I->waitForText($text, $timeout, AdminPage::$systemMessageContainer);
$I->see($text, AdminPage::$systemMessageContainer);
}

/**
* Method to confirm and close an appearing system message.
*
* @param string $text The text of message
* @param int $timeout Number of seconds to wait
*
* @return void
*
* @since 4.0.0
*
* @throws Exception
*/
public function seeAndCloseSystemMessage($text, $timeout = null)
{
$I = $this;

if (is_null($timeout))
{
$timeout = $I->getConfig('timeout');
}

$I->waitForText($text, $timeout, AdminPage::$systemMessageContainer);
$I->see($text, AdminPage::$systemMessageContainer);
$I->executeJS('Joomla.removeMessages()');
$I->wait(2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public function uploadSingleFileUsingToolbarButton(Media $I)
$I->amOnPage(MediaListPage::$url . $this->testDirectory);
$I->waitForJsOnPageLoad();
$I->uploadFile('com_media/' . $testFileName);
$I->seeSystemMessage('Item uploaded.');
$I->seeAndCloseSystemMessage('Item uploaded.');
$I->seeContents([$testFileName]);
$I->click($testFileItem);
$I->click(MediaListPage::$toolbarDeleteButton);
Expand All @@ -290,12 +290,12 @@ public function uploadSingleFileUsingToolbarButton(Media $I)

// Ensure the modal has closed
$I->wait(1);
$I->seeSystemMessage('Item deleted.');
$I->seeAndCloseSystemMessage('Item deleted.');
$I->waitForElementNotVisible($testFileItem);
}

/**
* Test the upload of a single file using toolbar button.
* Test the upload of an existing file using toolbar button.
*
* @skip We need to skip this test, because of a bug in acceptPopup in chrome.
* It throws a Facebook\WebDriver\Exception\UnexpectedAlertOpenException and does not accept the popup.
Expand All @@ -314,13 +314,13 @@ public function uploadExistingFileUsingToolbarButton(Media $I)
$I->amOnPage(MediaListPage::$url . $this->testDirectory);
$I->waitForJsOnPageLoad();
$I->uploadFile('com_media/' . $testFileName);
$I->seeSystemMessage('Item uploaded.');
$I->seeAndCloseSystemMessage('Item uploaded.');
$I->uploadFile('com_media/' . $testFileName);
$I->seeContents([$testFileName]);
$I->waitForMediaLoaded();
$I->seeInPopup($testFileName . ' already exists. Do you want to replace it?');
$I->acceptPopup();
$I->seeSystemMessage('Item uploaded.');
$I->seeAndCloseSystemMessage('Item uploaded.');
$I->seeContents([$testFileName]);
}

Expand Down Expand Up @@ -401,6 +401,7 @@ public function deleteSingleFileUsingToolbar(Media $I)
$I->wantToTest('that it is possible to delete a single file.');
$I->amOnPage(MediaListPage::$url . $this->testDirectory);
$I->uploadFile('com_media/' . $testFileName);
$I->seeAndCloseSystemMessage('Item uploaded.');
$I->waitForElement($testFileItem);
$I->waitForJsOnPageLoad();
$I->click($testFileItem);
Expand Down Expand Up @@ -473,15 +474,15 @@ public function deleteMultipleFiles(Media $I)
$I->wantToTest('that it is possible to delete multiple files.');
$I->amOnPage(MediaListPage::$url . $this->testDirectory);
$I->uploadFile('com_media/' . $testFileName1);
$I->waitForText('Item uploaded.');
$I->seeAndCloseSystemMessage('Item uploaded.');
$I->wait(10);
$I->waitForElement($testFileItem1);

// We have to clear the file input, otherwise our method of uploading the file via Codeception will upload it twice
$I->executeJS('document.getElementsByName(\'file\')[0].value = \'\'');
$I->waitForMediaLoaded();
$I->uploadFile('com_media/' . $testFileName2);
$I->waitForText('Item uploaded.');
$I->seeAndCloseSystemMessage('Item uploaded.');
$I->wait(10);
$I->waitForMediaLoaded();
$I->waitForElement($testFileItem2);
Expand Down