Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make UI tests delete feature more readable #28825

Merged
merged 1 commit into from
Aug 29, 2017
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
53 changes: 53 additions & 0 deletions tests/ui/features/bootstrap/FilesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
class FilesContext extends RawMinkContext implements Context
{
private $filesPage;

/**
* Table of all files and folders that should have been deleted stored so
* that other steps can use the list to check if the deletion happened correctly
* table headings: must be: |name|
*
* @var TableNode
*/
private $deletedElementsTable;

public function __construct(FilesPage $filesPage)
{
Expand Down Expand Up @@ -163,6 +172,50 @@ public function iDeleteTheFollowingFile(TableNode $namePartsTable) {
$this->filesPage->deleteFile($fileNameParts, $this->getSession());
}

/**
* @When I delete the elements
* @param TableNode $table table of file names
* table headings: must be: |name|
* @return void
*/
public function iDeleteTheElements(TableNode $table) {
$this->deletedElementsTable = $table;
foreach ($this->deletedElementsTable as $file) {
$this->iDeleteTheFile($file['name']);
}
}

/**
* @Then the deleted elements should not be listed
* @return void
*/
public function theDeletedElementsShouldNotBeListed() {
foreach ($this->deletedElementsTable as $file) {
$this->theFileFolderShouldNotBeListed($file['name']);
}
}

/**
* @Then the deleted elements should not be listed after a page reload
* @return void
*/
public function theDeletedElementsShouldNotBeListedAfterPageReload() {
$this->theFilesPageIsReloaded();
$this->theDeletedElementsShouldNotBeListed();
}

/**
* @When I batch delete these files
* @param TableNode $files table of file names
* table headings: must be: |name|
* @return void
*/
public function iBatchDeleteTheseFiles(TableNode $files) {
$this->deletedElementsTable = $files;
$this->iMarkTheseFilesForBatchAction($files);
$this->iBatchDeleteTheMarkedFiles();
}

/**
* @When I batch delete the marked files
* @return void
Expand Down
92 changes: 40 additions & 52 deletions tests/ui/features/files/delete.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,66 +6,54 @@ Feature: delete
And I am on the files page

Scenario: Delete files & folders one by one and check its existence after page reload
When I delete the folder "simple-folder"
Then the folder "simple-folder" should not be listed
When I delete the file "lorem.txt"
Then the file "lorem.txt" should not be listed
When I delete the folder "strängé नेपाली folder"
Then the folder "strängé नेपाली folder" should not be listed
When I delete the file "strängé filename (duplicate #2).txt"
Then the file "strängé filename (duplicate #2).txt" should not be listed
When the files page is reloaded
Then the folder "simple-folder" should not be listed
And the folder "strängé नेपाली folder" should not be listed
And the file "lorem.txt" should not be listed
And the file "strängé filename (duplicate #2).txt" should not be listed
When I delete the elements
| name |
| simple-folder |
| lorem.txt |
| strängé नेपाली folder |
| strängé filename (duplicate #2).txt |
Then the deleted elements should not be listed
And the deleted elements should not be listed after a page reload

Scenario: Delete a file with problematic characters
When I rename the following file to
|from-name-parts |to-name-parts |
|lorem.txt |'single' |
| |"double" quotes|
| |question? |
| |&and#hash |
| from-name-parts | to-name-parts |
| lorem.txt | 'single' |
| | "double" quotes |
| | question? |
| | &and#hash |
And the files page is reloaded
Then the following file should be listed
|name-parts |
|'single' |
|"double" quotes|
|question? |
|&and#hash |
| name-parts |
| 'single' |
| "double" quotes |
| question? |
| &and#hash |
And I delete the following file
|name-parts |
|'single' |
|"double" quotes|
|question? |
|&and#hash |
| name-parts |
| 'single' |
| "double" quotes |
| question? |
| &and#hash |
Then the following file should not be listed
|name-parts |
|'single' |
|"double" quotes|
|question? |
|&and#hash |
| name-parts |
| 'single' |
| "double" quotes |
| question? |
| &and#hash |
And the files page is reloaded
Then the following file should not be listed
|name-parts |
|'single' |
|"double" quotes|
|question? |
|&and#hash |
| name-parts |
| 'single' |
| "double" quotes |
| question? |
| &and#hash |

Scenario: Delete multiple files at once
When I mark these files for batch action
|name |
|data.zip|
|lorem.txt|
|simple-folder|
And I batch delete the marked files
Then the folder "simple-folder" should not be listed
And the file "data.zip" should not be listed
And the file "lorem.txt" should not be listed
When the files page is reloaded
Then the folder "simple-folder" should not be listed
And the file "data.zip" should not be listed
And the file "lorem.txt" should not be listed

When I batch delete these files
| name |
| data.zip |
| lorem.txt |
| simple-folder |
Then the deleted elements should not be listed
And the deleted elements should not be listed after a page reload