diff options
Diffstat (limited to 'tests/acceptance/features')
46 files changed, 0 insertions, 8402 deletions
diff --git a/tests/acceptance/features/access-levels.feature b/tests/acceptance/features/access-levels.feature deleted file mode 100644 index 9d5695897c0..00000000000 --- a/tests/acceptance/features/access-levels.feature +++ /dev/null @@ -1,23 +0,0 @@ -Feature: access-levels - - Scenario: regular users cannot see admin-level items in the Settings menu - Given I am logged in - When I open the Settings menu - Then I see that the Settings menu is shown - And I see that the "Settings" item in the Settings menu is shown - And I see that the "Users" item in the Settings menu is not shown - And I see that the "Help" item in the Settings menu is shown - And I see that the "Log out" item in the Settings menu is shown - - Scenario: regular users cannot see admin-level items on the Settings page - Given I am logged in - When I visit the settings page - Then I see that the "Personal info" entry in the settings panel is shown - And I see that the "Personal" settings panel is not shown - And I see that the "Administration" settings panel is not shown - - Scenario: admin users can see admin-level items on the Settings page - Given I am logged in as the admin - When I visit the settings page - Then I see that the "Personal" settings panel is shown - And I see that the "Administration" settings panel is shown diff --git a/tests/acceptance/features/app-comments.feature b/tests/acceptance/features/app-comments.feature deleted file mode 100644 index b57883d8ba8..00000000000 --- a/tests/acceptance/features/app-comments.feature +++ /dev/null @@ -1,325 +0,0 @@ -Feature: app-comments - -# Scenario: Writing a comment -# Given I am logged in -# And I open the details view for "welcome.txt" -# And I open the "Comments" tab in the details view -# When I create a new comment with "Hello world" as message -# Then I see a comment with "Hello world" as message - -# Scenario: open the comments for a different file -# Given I am logged in -# And I create a new folder named "Folder" -# And I open the details view for "welcome.txt" -# And I open the "Comments" tab in the details view -# And I create a new comment with "Hello world" as message -# And I see a comment with "Hello world" as message -# When I open the details view for "Folder" - # The "Comments" tab should already be opened -# Then I see that there are no comments - - Scenario: write a comment in a file right after writing a comment in another file - Given I am logged in - And I create a new folder named "Folder" - And I open the details view for "Folder" - And I open the "Comments" tab in the details view - And I create a new comment with "Comment in Folder" as message - And I see a comment with "Comment in Folder" as message - And I open the details view for "welcome.txt" - # The "Comments" tab should already be opened - When I create a new comment with "Comment in welcome.txt" as message - Then I see a comment with "Comment in welcome.txt" as message - And I see that there is no comment with "Comment in Folder" as message - - - - Scenario: read a comment written by the sharer - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I rename "welcome.txt" to "shared.txt" - And I share "shared.txt" with "user0" - And I see that the file is shared with "user0" - # The details view should already be open - And I open the "Comments" tab in the details view - And I create a new comment with "Hello world" as message - And I see a comment with "Hello world" as message - When I act as Jane - # The Files app is open again to reload the file list and the comments - And I open the Files app - And I open the details view for "shared.txt" - And I open the "Comments" tab in the details view - Then I see a comment with "Hello world" as message - - Scenario: read a comment written by the sharee - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I rename "welcome.txt" to "shared.txt" - And I share "shared.txt" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I open the details view for "shared.txt" - And I open the "Comments" tab in the details view - And I create a new comment with "Hello world" as message - And I see a comment with "Hello world" as message - When I act as John - # The Files app is open again to reload the file list and the comments - And I open the Files app - And I open the details view for "shared.txt" - And I open the "Comments" tab in the details view - Then I see a comment with "Hello world" as message - - - - Scenario: unread comment icon shown for comment written by the sharer in a shared file - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I rename "welcome.txt" to "shared.txt" - And I share "shared.txt" with "user0" - And I see that the file is shared with "user0" - # The details view should already be open - And I open the "Comments" tab in the details view - And I create a new comment with "Hello world" as message - And I see a comment with "Hello world" as message - When I act as Jane - # The Files app is open again to reload the file list and the comments - And I open the Files app - Then I see that "shared.txt" has unread comments - And I open the unread comments for "shared.txt" - And I see that the details view is open - And I see a comment with "Hello world" as message - - Scenario: unread comment icon shown for comment written by the sharee in a shared file - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I rename "welcome.txt" to "shared.txt" - And I share "shared.txt" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I open the details view for "shared.txt" - And I open the "Comments" tab in the details view - And I create a new comment with "Hello world" as message - And I see a comment with "Hello world" as message - When I act as John - # The Files app is open again to reload the file list and the comments - And I open the Files app - Then I see that "shared.txt" has unread comments - And I open the unread comments for "shared.txt" - And I see that the details view is open - And I see a comment with "Hello world" as message - - Scenario: unread comment icon shown for comment written by the sharer in a shared folder - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I create a new folder named "Folder" - And I share "Folder" with "user0" - And I see that the file is shared with "user0" - # The details view should already be open - And I open the "Comments" tab in the details view - And I create a new comment with "Hello world" as message - And I see a comment with "Hello world" as message - When I act as Jane - # The Files app is open again to reload the file list and the comments - And I open the Files app - Then I see that "Folder" has unread comments - And I open the unread comments for "Folder" - And I see that the details view is open - And I see a comment with "Hello world" as message - - Scenario: unread comment icon shown for comment written by the sharee in a shared folder - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I create a new folder named "Folder" - And I share "Folder" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I open the details view for "Folder" - And I open the "Comments" tab in the details view - And I create a new comment with "Hello world" as message - And I see a comment with "Hello world" as message - When I act as John - # The Files app is open again to reload the file list and the comments - And I open the Files app - Then I see that "Folder" has unread comments - And I open the unread comments for "Folder" - And I see that the details view is open - And I see a comment with "Hello world" as message - - Scenario: unread comment icon shown for comment written by the sharer in a child folder of a shared folder - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I create a new folder named "Folder" - And I share "Folder" with "user0" - And I see that the file is shared with "user0" - And I enter in the folder named "Folder" - And I create a new folder named "Child folder" - # The details view should already be open - And I open the "Comments" tab in the details view - And I create a new comment with "Hello world" as message - And I see a comment with "Hello world" as message - When I act as Jane - # The Files app is open again to reload the file list and the comments - And I open the Files app - And I enter in the folder named "Folder" - Then I see that "Child folder" has unread comments - And I open the unread comments for "Child folder" - And I see that the details view is open - And I see a comment with "Hello world" as message - - Scenario: unread comment icon shown for comment written by the sharee in a child folder of a shared folder - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I create a new folder named "Folder" - And I share "Folder" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I enter in the folder named "Folder" - And I create a new folder named "Child folder" - # The details view should already be open - And I open the "Comments" tab in the details view - And I create a new comment with "Hello world" as message - And I see a comment with "Hello world" as message - When I act as John - And I enter in the folder named "Folder" - Then I see that "Child folder" has unread comments - And I open the unread comments for "Child folder" - And I see that the details view is open - And I see a comment with "Hello world" as message - - - - Scenario: search a comment - Given I am logged in - And I open the details view for "welcome.txt" - And I open the "Comments" tab in the details view - And I create a new comment with "Hello world" as message - And I see a comment with "Hello world" as message - When I search for "hello" - # Search results for comments also include the user that wrote the comment. - Then I see that the search result 1 is "user0Hello world" - And I see that the search result 1 was found in "welcome.txt" - - Scenario: search a comment in a child folder - Given I am logged in - And I create a new folder named "Folder" - And I enter in the folder named "Folder" - And I create a new folder named "Child folder" - And I open the details view for "Child folder" - And I open the "Comments" tab in the details view - And I create a new comment with "Hello world" as message - And I see a comment with "Hello world" as message - # The Files app is open again to reload the file list - And I open the Files app - When I search for "hello" - # Search results for comments also include the user that wrote the comment. - Then I see that the search result 1 is "user0Hello world" - And I see that the search result 1 was found in "Folder/Child folder" - - Scenario: search a comment by a another user - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I rename "welcome.txt" to "shared.txt" - And I share "shared.txt" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I open the details view for "shared.txt" - And I open the "Comments" tab in the details view - And I create a new comment with "Hello world" as message - And I see a comment with "Hello world" as message - When I act as John - And I search for "hello" - # Search results for comments also include the user that wrote the comment. - Then I see that the search result 1 is "user0Hello world" - And I see that the search result 1 was found in "shared.txt" - - Scenario: open a search result for a comment in a file - Given I am logged in - And I open the details view for "welcome.txt" - And I open the "Comments" tab in the details view - And I create a new comment with "Hello world" as message - And I see a comment with "Hello world" as message - # Force the details view to change to a different file before closing it - And I create a new folder named "Folder" - And I close the details view - When I search for "hello" - And I open the search result 1 - Then I see that the details view is open - And I see that the file name shown in the details view is "welcome.txt" - And I see a comment with "Hello world" as message - And I see that the file list is currently in "Home" - And I see that the file list contains a file named "welcome.txt" - - Scenario: open a search result for a comment in a folder named like its child folder - Given I am logged in - And I create a new folder named "Folder" - And I open the details view for "Folder" - And I open the "Comments" tab in the details view - And I create a new comment with "Hello world" as message - And I see a comment with "Hello world" as message - And I enter in the folder named "Folder" - And I create a new folder named "Folder" - # The Files app is open again to reload the file list - And I open the Files app - When I search for "hello" - And I open the search result 1 - Then I see that the details view is open - And I see that the file name shown in the details view is "Folder" - And I see a comment with "Hello world" as message - And I see that the file list is currently in "Home" - And I see that the file list contains a file named "welcome.txt" - And I see that the file list contains a file named "Folder" - - Scenario: open a search result for a comment in a child folder - Given I am logged in - And I create a new folder named "Folder" - And I enter in the folder named "Folder" - And I create a new folder named "Child folder" - And I open the details view for "Child folder" - And I open the "Comments" tab in the details view - And I create a new comment with "Hello world" as message - And I see a comment with "Hello world" as message - # The Files app is open again to reload the file list - And I open the Files app - When I search for "hello" - And I open the search result 1 - Then I see that the details view is open - And I see that the file name shown in the details view is "Child folder" - And I see a comment with "Hello world" as message - And I see that the file list is currently in "Home/Folder" - And I see that the file list contains a file named "Child folder" diff --git a/tests/acceptance/features/app-files-sharing-link.feature b/tests/acceptance/features/app-files-sharing-link.feature deleted file mode 100644 index d89c7b4289d..00000000000 --- a/tests/acceptance/features/app-files-sharing-link.feature +++ /dev/null @@ -1,248 +0,0 @@ -Feature: app-files-sharing-link - - Scenario: open the menu in a public shared link - Given I act as John - And I am logged in - And I share the link for "welcome.txt" - And I write down the shared link - When I act as Jane - And I visit the shared link I wrote down - And I see that the current page is the shared link I wrote down - And I open the Share menu - Then I see that the Share menu is shown - - Scenario: hide download in a public shared link - Given I act as John - And I am logged in - And I share the link for "welcome.txt" - And I set the download of the shared link as hidden - And I write down the shared link - When I act as Jane - And I visit the shared link I wrote down - And I see that the current page is the shared link I wrote down - Then I see that the download button is not shown - And I see that the Share menu button is not shown - - Scenario: show download again in a public shared link - Given I act as John - And I am logged in - And I share the link for "welcome.txt" - And I set the download of the shared link as hidden - And I set the download of the shared link as shown - And I write down the shared link - When I act as Jane - And I visit the shared link I wrote down - And I see that the current page is the shared link I wrote down - Then I see that the download button is shown - And I open the Share menu - And I see that the Share menu is shown - - Scenario: open a subfolder in a public shared folder - Given I act as John - And I am logged in - And I create a new folder named "Shared folder with subfolders" - And I enter in the folder named "Shared folder with subfolders" - And I create a new folder named "Subfolder" - And I enter in the folder named "Subfolder" - And I create a new folder named "Subsubfolder" - And I see that the file list contains a file named "Subsubfolder" - # The Files app is open again to reload the file list - And I open the Files app - And I share the link for "Shared folder with subfolders" - And I write down the shared link - When I act as Jane - And I visit the shared link I wrote down - And I see that the current page is the shared link I wrote down - Then I see that the file list contains a file named "Subfolder" - And I enter in the folder named "Subfolder" - And I see that the file list contains a file named "Subsubfolder" - - Scenario: creation is not possible by default in a public shared folder - Given I act as John - And I am logged in - And I create a new folder named "Shared folder" - # To share the link the "Share" inline action has to be clicked but, as the - # details view is opened automatically when the folder is created, clicking - # on the inline action could fail if it is covered by the details view due - # to its opening animation. Instead of ensuring that the animations of the - # contents and the details view have both finished it is easier to close the - # details view and wait until it is closed before continuing. - And I close the details view - And I see that the details view is closed - And I share the link for "Shared folder" - And I write down the shared link - When I act as Jane - And I visit the shared link I wrote down - And I see that the current page is the shared link I wrote down - And I see that the file list is eventually loaded - Then I see that it is not possible to create new files - - Scenario: create folder in a public editable shared folder - Given I act as John - And I am logged in - And I create a new folder named "Editable shared folder" - # To share the link the "Share" inline action has to be clicked but, as the - # details view is opened automatically when the folder is created, clicking - # on the inline action could fail if it is covered by the details view due - # to its opening animation. Instead of ensuring that the animations of the - # contents and the details view have both finished it is easier to close the - # details view and wait until it is closed before continuing. - And I close the details view - And I see that the details view is closed - And I share the link for "Editable shared folder" - And I set the shared link as editable - And I write down the shared link - When I act as Jane - And I visit the shared link I wrote down - And I see that the current page is the shared link I wrote down - And I create a new folder named "Subfolder" - Then I see that the file list contains a file named "Subfolder" - - Scenario: owner sees folder created in the public page of an editable shared folder - Given I act as John - And I am logged in - And I create a new folder named "Editable shared folder" - # To share the link the "Share" inline action has to be clicked but, as the - # details view is opened automatically when the folder is created, clicking - # on the inline action could fail if it is covered by the details view due - # to its opening animation. Instead of ensuring that the animations of the - # contents and the details view have both finished it is easier to close the - # details view and wait until it is closed before continuing. - And I close the details view - And I see that the details view is closed - And I share the link for "Editable shared folder" - And I set the shared link as editable - And I write down the shared link - And I act as Jane - And I visit the shared link I wrote down - And I see that the current page is the shared link I wrote down - And I create a new folder named "Subfolder" - And I see that the file list contains a file named "Subfolder" - When I act as John - And I enter in the folder named "Editable shared folder" - Then I see that the file list contains a file named "Subfolder" - - Scenario: set a password to a shared link - Given I am logged in - And I share the link for "welcome.txt" - When I protect the shared link with the password "abcdef" - Then I see that the password protect is disabled while loading - And I see that the link share is password protected - # As Talk is not enabled in the acceptance tests of the server the checkbox - # is never shown. - And I see that the checkbox to protect the password of the link share by Talk is not shown - - Scenario: access a shared link protected by password with a valid password - Given I act as John - And I am logged in - And I share the link for "welcome.txt" protected by the password "abcdef" - And I write down the shared link - When I act as Jane - And I visit the shared link I wrote down - And I see that the current page is the Authenticate page for the shared link I wrote down - And I authenticate with password "abcdef" - Then I see that the current page is the shared link I wrote down - And I see that the shared file preview shows the text "Welcome to your Nextcloud account!" - - Scenario: access a shared link protected by password with an invalid password - Given I act as John - And I am logged in - And I share the link for "welcome.txt" protected by the password "abcdef" - And I write down the shared link - When I act as Jane - And I visit the shared link I wrote down - And I authenticate with password "fedcba" - Then I see that the current page is the Authenticate page for the shared link I wrote down - And I see that a wrong password for the shared file message is shown - - Scenario: access a direct download shared link protected by password with a valid password - Given I act as John - And I am logged in - And I share the link for "welcome.txt" protected by the password "abcdef" - And I write down the shared link - When I act as Jane - And I visit the direct download shared link I wrote down - And I see that the current page is the Authenticate page for the direct download shared link I wrote down - And I authenticate with password "abcdef" - # download starts no page redirection - And I see that the current page is the Authenticate page for the direct download shared link I wrote down - - Scenario: sharee can not reshare by link if resharing is disabled in the settings after the share is created - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I rename "welcome.txt" to "farewell.txt" - And I see that the file list contains a file named "farewell.txt" - And I share "farewell.txt" with "user0" - And I see that the file is shared with "user0" - And I visit the settings page - And I open the "Sharing" section of the "Administration" group - And I disable resharing - And I see that resharing is disabled - When I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - Then I see that the file list contains a file named "farewell.txt" - And I open the details view for "farewell.txt" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - And I see that the file is shared with me by "admin" - And I see that resharing the file by link is not available - - Scenario: sharee can unshare a reshare by link if resharing is disabled in the settings after the reshare is created - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I rename "welcome.txt" to "farewell.txt" - And I see that the file list contains a file named "farewell.txt" - And I share "farewell.txt" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I share the link for "farewell.txt" - And I write down the shared link - And I act as John - And I visit the settings page - And I open the "Sharing" section of the "Administration" group - And I disable resharing - And I see that resharing is disabled - When I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I open the details view for "farewell.txt" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - And I unshare the link share - Then I see that resharing the file by link is not available - - Scenario: reshare by link can be accessed if resharing is disabled in the settings after the reshare is created - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I rename "welcome.txt" to "farewell.txt" - And I see that the file list contains a file named "farewell.txt" - And I share "farewell.txt" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I share the link for "farewell.txt" - And I write down the shared link - And I act as John - And I visit the settings page - And I open the "Sharing" section of the "Administration" group - And I disable resharing - And I see that resharing is disabled - When I act as Jim - And I visit the shared link I wrote down - Then I see that the current page is the shared link I wrote down - And I see that the shared file preview shows the text "Welcome to your Nextcloud account!" diff --git a/tests/acceptance/features/app-files-sharing.feature b/tests/acceptance/features/app-files-sharing.feature deleted file mode 100644 index 4f58d1d17ff..00000000000 --- a/tests/acceptance/features/app-files-sharing.feature +++ /dev/null @@ -1,484 +0,0 @@ -Feature: app-files-sharing - - Scenario: share a file with another user - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I rename "welcome.txt" to "farewell.txt" - And I see that the file list contains a file named "farewell.txt" - When I share "farewell.txt" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - Then I see that the file list contains a file named "farewell.txt" - And I open the details view for "farewell.txt" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - And I see that the file is shared with me by "admin" - - Scenario: share a file with another user that needs to accept shares - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I visit the settings page - And I open the "Sharing" section - And I disable accepting the shares by default - And I see that shares are not accepted by default - And I act as John - And I rename "welcome.txt" to "farewell.txt" - And I see that the file list contains a file named "farewell.txt" - When I share "farewell.txt" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - And I open the Files app - And I see that the file list does not contain a file named "farewell.txt" - And I accept the share for "/farewell.txt" in the notifications - # The Files app is open again to reload the file list - And I open the Files app - Then I see that the file list contains a file named "farewell.txt" - And I open the details view for "farewell.txt" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - And I see that the file is shared with me by "admin" - - Scenario: share a file with another user who already has a file with that name - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - When I share "welcome.txt" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - Then I see that the file list contains a file named "welcome (2).txt" - And I open the details view for "welcome (2).txt" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - And I see that the file is shared with me by "admin" - - Scenario: share a skeleton file with another user before first login - # If a file is shared with a user before her first login the skeleton would - # not have been created, so if the shared file has the same name as one from - # the skeleton the shared file will take its place and the skeleton file - # will not be added. - Given I act as John - And I am logged in as the admin - When I share "welcome.txt" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - And I am logged in - Then I see that the file list contains a file named "welcome.txt" - And I open the details view for "welcome.txt" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - And I see that the file is shared with me by "admin" - - Scenario: reshare a file with another user - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as Jim - And I am logged in as "user1" - And I act as John - And I rename "welcome.txt" to "farewell.txt" - And I see that the file list contains a file named "farewell.txt" - And I share "farewell.txt" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - When I share "farewell.txt" with "user1" - And I see that the file is shared with "user1" - And I act as Jim - # The Files app is open again to reload the file list - And I open the Files app - Then I see that the file list contains a file named "farewell.txt" - And I open the details view for "farewell.txt" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - And I see that the file is shared with me by "user0" - - Scenario: owner sees reshares with other users - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I rename "welcome.txt" to "farewell.txt" - And I see that the file list contains a file named "farewell.txt" - And I share "farewell.txt" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I share "farewell.txt" with "user1" - And I see that the file is shared with "user1" - When I act as John - # The Files app is open again to reload the file list and the shares - And I open the Files app - And I open the details view for "farewell.txt" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - Then I see that the file is shared with "user0" - And I see that the file is shared with "user1" - - Scenario: share an empty folder with another user - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I create a new folder named "Shared folder" - And I see that the file list contains a file named "Shared folder" - When I share "Shared folder" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - Then I see that the file list contains a file named "Shared folder" - And I open the details view for "Shared folder" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - And I see that the file is shared with me by "admin" - - Scenario: sharee sees a folder created by the owner in a shared folder - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I create a new folder named "Shared folder" - And I see that the file list contains a file named "Shared folder" - And I share "Shared folder" with "user0" - And I see that the file is shared with "user0" - And I enter in the folder named "Shared folder" - And I create a new folder named "Subfolder" - And I see that the file list contains a file named "Subfolder" - When I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I enter in the folder named "Shared folder" - Then I see that the file list contains a file named "Subfolder" - - Scenario: owner sees a folder created by the sharee in a shared folder - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I create a new folder named "Shared folder" - And I see that the file list contains a file named "Shared folder" - And I share "Shared folder" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I enter in the folder named "Shared folder" - And I create a new folder named "Subfolder" - And I see that the file list contains a file named "Subfolder" - When I act as John - And I enter in the folder named "Shared folder" - Then I see that the file list contains a file named "Subfolder" - - Scenario: resharee sees a folder created by the owner in a shared folder - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as Jim - And I am logged in as "user1" - And I act as John - And I create a new folder named "Shared folder" - And I see that the file list contains a file named "Shared folder" - And I share "Shared folder" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I share "Shared folder" with "user1" - And I act as John - And I enter in the folder named "Shared folder" - And I create a new folder named "Subfolder" - And I see that the file list contains a file named "Subfolder" - When I act as Jim - # The Files app is open again to reload the file list - And I open the Files app - And I enter in the folder named "Shared folder" - Then I see that the file list contains a file named "Subfolder" - - Scenario: owner sees a folder created by the resharee in a shared folder - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as Jim - And I am logged in as "user1" - And I act as John - And I create a new folder named "Shared folder" - And I see that the file list contains a file named "Shared folder" - And I share "Shared folder" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I share "Shared folder" with "user1" - And I act as Jim - # The Files app is open again to reload the file list - And I open the Files app - And I enter in the folder named "Shared folder" - And I create a new folder named "Subfolder" - And I see that the file list contains a file named "Subfolder" - When I act as John - And I enter in the folder named "Shared folder" - Then I see that the file list contains a file named "Subfolder" - - Scenario: sharer does not see resharing option for a folder if resharing is disabled in the settings after the share is created - Given I am logged in as the admin - And I create a new folder named "Shared folder" - And I see that the file list contains a file named "Shared folder" - And I share "Shared folder" with "user0" - And I see that the file is shared with "user0" - When I visit the settings page - And I open the "Sharing" section of the "Administration" group - And I disable resharing - And I see that resharing is disabled - Then I open the Files app - And I open the details view for "Shared folder" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - And I see that resharing for "user0" is not available - - Scenario: sharee can not reshare a folder if resharing is disabled in the settings after the share is created - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I create a new folder named "Shared folder" - And I see that the file list contains a file named "Shared folder" - And I share "Shared folder" with "user0" - And I see that the file is shared with "user0" - And I visit the settings page - And I open the "Sharing" section of the "Administration" group - And I disable resharing - And I see that resharing is disabled - When I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - Then I see that the file list contains a file named "Shared folder" - And I open the details view for "Shared folder" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - And I see that the file is shared with me by "admin" - And I see that resharing the file is not allowed - - Scenario: sharee can unshare a folder if resharing is disabled in the settings after the share is created - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I create a new folder named "Shared folder" - And I see that the file list contains a file named "Shared folder" - And I share "Shared folder" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I share "Shared folder" with "user1" - And I act as John - And I visit the settings page - And I open the "Sharing" section of the "Administration" group - And I disable resharing - And I see that resharing is disabled - When I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - Then I see that the file list contains a file named "Shared folder" - And I open the details view for "Shared folder" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - And I see that the file is shared with me by "admin" - And I unshare the share with "user1" - And I see that the file is not shared with "user1" - - Scenario: resharee sees a folder created by the owner in a shared folder if resharing is disabled in the settings after the share is created - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as Jim - And I am logged in as "user1" - And I act as John - And I create a new folder named "Shared folder" - And I see that the file list contains a file named "Shared folder" - And I share "Shared folder" with "user0" - And I see that the file is shared with "user0" - And I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I share "Shared folder" with "user1" - And I act as John - And I visit the settings page - And I open the "Sharing" section of the "Administration" group - And I disable resharing - And I see that resharing is disabled - And I open the Files app - And I enter in the folder named "Shared folder" - And I create a new folder named "Subfolder" - And I see that the file list contains a file named "Subfolder" - When I act as Jim - # The Files app is open again to reload the file list - And I open the Files app - And I enter in the folder named "Shared folder" - Then I see that the file list contains a file named "Subfolder" - - Scenario: sharee can not reshare a folder if the sharer disables it - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I create a new folder named "Shared folder" - And I see that the file list contains a file named "Shared folder" - And I share "Shared folder" with "user0" - And I see that the file is shared with "user0" - And I set the share with "user0" as not reshareable - And I see that "user0" can not reshare the share - When I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - Then I see that the file list contains a file named "Shared folder" - And I open the details view for "Shared folder" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - And I see that the file is shared with me by "admin" - And I see that resharing the file is not allowed - - Scenario: sharee can not reshare a subfolder if the sharer disables it for the parent folder - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I create a new folder named "Shared folder" - And I see that the file list contains a file named "Shared folder" - And I share "Shared folder" with "user0" - And I see that the file is shared with "user0" - And I set the share with "user0" as not reshareable - And I see that "user0" can not reshare the share - And I enter in the folder named "Shared folder" - And I create a new folder named "Subfolder" - And I see that the file list contains a file named "Subfolder" - When I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I enter in the folder named "Shared folder" - Then I see that the file list contains a file named "Subfolder" - And I open the details view for "Subfolder" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - And I see that resharing the file is not allowed - - Scenario: sharee can not reshare a file with edit permission if the sharer disables it - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I rename "welcome.txt" to "farewell.txt" - And I see that the file list contains a file named "farewell.txt" - And I share "farewell.txt" with "user0" - And I see that the file is shared with "user0" - And I set the share with "user0" as not editable - And I see that "user0" can not edit the share - When I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I share "farewell.txt" with "user1" - Then I see that the file is shared with "user1" - And I see that "user1" can not edit the share - And I see that "user1" can not be allowed to edit the share - - Scenario: sharee can not reshare a folder with create permission if the sharer disables it - Given I act as John - And I am logged in as the admin - And I act as Jane - And I am logged in - And I act as John - And I create a new folder named "Shared folder" - And I see that the file list contains a file named "Shared folder" - And I share "Shared folder" with "user0" - And I see that the file is shared with "user0" - And I set the share with "user0" as not creatable - And I see that "user0" can not create in the share - When I act as Jane - # The Files app is open again to reload the file list - And I open the Files app - And I share "Shared folder" with "user1" - Then I see that the file is shared with "user1" - And I see that "user1" can not create in the share - And I see that "user1" can not be allowed to create in the share - -# TODO: disabled unreliable test -# Scenario: sharee can revoke create permission from reshare after the sharer disabled it -# Given I act as John -# And I am logged in as the admin -# And I act as Jane -# And I am logged in -# And I act as Jim -# And I am logged in as "user1" -# And I act as John -# And I create a new folder named "Shared folder" -# And I see that the file list contains a file named "Shared folder" -# And I share "Shared folder" with "user0" -# And I see that the file is shared with "user0" -# And I act as Jane -# # The Files app is open again to reload the file list -# And I open the Files app -# And I share "Shared folder" with "user1" -# And I see that the file is shared with "user1" -# And I act as John -# And I set the share with "user0" as not creatable -# And I see that "user0" can not create in the share -# And I act as Jim -# # The Files app is open again to reload the file list -# And I open the Files app -# And I enter in the folder named "Shared folder" -# # Creation is still allowed in already created reshares -# And I create a new folder named "Subfolder" -# And I see that the file list contains a file named "Subfolder" -# When I act as Jane -# # The Files app is open again to reload the file list -# And I open the Files app -# And I open the details view for "Shared folder" -# And I see that the details view is open -# And I open the "Sharing" tab in the details view -# And I see that the "Sharing" tab in the details view is eventually loaded -# And I set the share with "user1" as not creatable -# Then I see that "user1" can not create in the share -# And I see that "user1" can not be allowed to create in the share -# And I act as Jim -# # The Files app is open again to reload the file list -# And I open the Files app -# And I enter in the folder named "Shared folder" -# And I see that it is not possible to create new files diff --git a/tests/acceptance/features/app-files-tags.feature b/tests/acceptance/features/app-files-tags.feature deleted file mode 100644 index 8514a59d7d0..00000000000 --- a/tests/acceptance/features/app-files-tags.feature +++ /dev/null @@ -1,92 +0,0 @@ -@apache -Feature: app-files-tags - -# Scenario: show the input field for tags in the details view -# Given I am logged in -# And I open the details view for "welcome.txt" -# And I see that the details view is open -# When I open the input field for tags in the details view -# Then I see that the input field for tags in the details view is shown - -# Scenario: show the input field for tags in the details view after closing and opening the details view again -# Given I am logged in -# And I open the details view for "welcome.txt" -# And I see that the details view is open -# And I close the details view -# And I see that the details view is closed -# And I open the details view for "welcome.txt" -# And I see that the details view is open -# When I open the input field for tags in the details view -# Then I see that the input field for tags in the details view is shown - - Scenario: create tags using the Administration settings - Given I am logged in as the admin - And I visit the settings page - And I open the "Basic settings" section of the "Administration" group - # The "create" button does nothing before JavaScript was initialized, and - # the only way to detect that is waiting for the button to select tags to be - # shown. - And I see that the button to select tags is shown - When I create the tag "tag1" in the settings - Then I see that the dropdown for tags in the settings eventually contains the tag "tag1" - -# Scenario: add tags using the dropdown in the details view -# Given I am logged in as the admin -# And I visit the settings page -# And I open the "Basic settings" section of the "Administration" group -# # The "create" button does nothing before JavaScript was initialized, and -# # the only way to detect that is waiting for the button to select tags to be -# # shown. -# And I see that the button to select tags is shown -# And I create the tag "tag1" in the settings -# And I create the tag "tag2" in the settings -# And I create the tag "tag3" in the settings -# And I create the tag "tag4" in the settings -# And I see that the dropdown for tags in the settings eventually contains the tag "tag1" -# And I see that the dropdown for tags in the settings eventually contains the tag "tag2" -# And I see that the dropdown for tags in the settings eventually contains the tag "tag3" -# And I see that the dropdown for tags in the settings eventually contains the tag "tag4" -# And I log out -# And I am logged in -# And I open the details view for "welcome.txt" -# And I open the input field for tags in the details view -# # When the input field is opened the dropdown is also opened automatically. -# When I check the tag "tag2" in the dropdown for tags in the details view -# And I check the tag "tag4" in the dropdown for tags in the details view -# Then I see that the tag "tag2" in the dropdown for tags in the details view is checked -# And I see that the tag "tag4" in the dropdown for tags in the details view is checked -# And I see that the input field for tags in the details view contains the tag "tag2" -# And I see that the input field for tags in the details view contains the tag "tag4" -# -# Scenario: remove tags using the dropdown in the details view -# Given I am logged in as the admin -# And I visit the settings page -# And I open the "Basic settings" section of the "Administration" group -# # The "create" button does nothing before JavaScript was initialized, and -# # the only way to detect that is waiting for the button to select tags to be -# # shown. -# And I see that the button to select tags is shown -# And I create the tag "tag1" in the settings -# And I create the tag "tag2" in the settings -# And I create the tag "tag3" in the settings -# And I create the tag "tag4" in the settings -# And I see that the dropdown for tags in the settings eventually contains the tag "tag1" -# And I see that the dropdown for tags in the settings eventually contains the tag "tag2" -# And I see that the dropdown for tags in the settings eventually contains the tag "tag3" -# And I see that the dropdown for tags in the settings eventually contains the tag "tag4" -# And I log out -# And I am logged in -# And I open the details view for "welcome.txt" -# And I open the input field for tags in the details view -# # When the input field is opened the dropdown is also opened automatically. -# And I check the tag "tag2" in the dropdown for tags in the details view -# And I check the tag "tag4" in the dropdown for tags in the details view -# And I check the tag "tag3" in the dropdown for tags in the details view -# When I uncheck the tag "tag2" in the dropdown for tags in the details view -# And I uncheck the tag "tag4" in the dropdown for tags in the details view -# Then I see that the tag "tag2" in the dropdown for tags in the details view is not checked -# And I see that the tag "tag4" in the dropdown for tags in the details view is not checked -# And I see that the tag "tag3" in the dropdown for tags in the details view is checked -# And I see that the input field for tags in the details view does not contain the tag "tag2" -# And I see that the input field for tags in the details view does not contain the tag "tag4" -# And I see that the input field for tags in the details view contains the tag "tag3" diff --git a/tests/acceptance/features/app-files.feature b/tests/acceptance/features/app-files.feature deleted file mode 100644 index 793504443da..00000000000 --- a/tests/acceptance/features/app-files.feature +++ /dev/null @@ -1,299 +0,0 @@ -@apache -Feature: app-files - - Scenario: open and close the details view - Given I am logged in - When I open the details view for "welcome.txt" - And I see that the details view is open - And I close the details view - Then I see that the details view is closed - - Scenario: open and close the details view twice - Given I am logged in - And I open the details view for "welcome.txt" - And I see that the details view is open - And I close the details view - And I see that the details view is closed - When I open the details view for "welcome.txt" - And I see that the details view is open - And I close the details view - Then I see that the details view is closed - - Scenario: open and close the details view again after coming back from a different section - Given I am logged in - And I open the details view for "welcome.txt" - And I see that the details view is open - And I close the details view - And I see that the details view is closed - And I open the "Recent" section - And I see that the current section is "Recent" - And I open the details view for "welcome.txt" - And I see that the details view is open - And I close the details view - And I see that the details view is closed - When I open the "All files" section - And I see that the current section is "All files" - And I open the details view for "welcome.txt" - And I see that the details view is open - And I close the details view - Then I see that the details view is closed - -# Scenario: viewing a favorite file in its folder shows the correct sidebar view -# Given I am logged in -# And I create a new folder named "other" -# And I mark "other" as favorite -# And I mark "welcome.txt" as favorite -# And I see that "other" is marked as favorite -# And I see that "welcome.txt" is marked as favorite -# And I open the "Favorites" section -# And I open the details view for "other" -# And I see that the details view is open -# And I see that the file name shown in the details view is "other" -# When I view "welcome.txt" in folder -# Then I see that the current section is "All files" -# And I see that the details view is open -# And I see that the file name shown in the details view is "welcome.txt" -# When I open the details view for "other" -# And I see that the file name shown in the details view is "other" - - -# Scenario: viewing a favorite file in its folder does not prevent opening the details view in "All files" section -# Given I am logged in -# And I mark "welcome.txt" as favorite -# And I see that "welcome.txt" is marked as favorite -# And I open the "Favorites" section -# And I open the details view for "welcome.txt" -# And I see that the details view is open -# And I view "welcome.txt" in folder -# And I see that the current section is "All files" -# When I open the details view for "welcome.txt" -# Then I see that the details view is open - -# Scenario: show recent files -# Given I am logged in -# And I create a new folder named "Folder just created" -# When I open the "Recent" section -# Then I see that the current section is "Recent" -# Then I see that the file list contains a file named "Folder just created" - -# Scenario: show recent files for a second time -# Given I am logged in -# And I open the "Recent" section -# And I see that the current section is "Recent" -# And I open the "All files" section -# And I see that the current section is "All files" -# And I create a new folder named "Folder just created" -# When I open the "Recent" section -# Then I see that the current section is "Recent" -# Then I see that the file list contains a file named "Folder just created" - -# Scenario: show favorites -# Given I am logged in -# And I mark "welcome.txt" as favorite -# When I open the "Favorites" section -# Then I see that the current section is "Favorites" -# Then I see that the file list contains a file named "welcome.txt" - -# Scenario: show favorites for a second time -# Given I am logged in -# And I open the "Favorites" section -# And I see that the current section is "Favorites" -# And I open the "All files" section -# And I see that the current section is "All files" -# And I mark "welcome.txt" as favorite -# When I open the "Favorites" section -# Then I see that the current section is "Favorites" -# Then I see that the file list contains a file named "welcome.txt" - -# TODO: disabled unreliable test -# Scenario: show shares -# Given I am logged in -# And I share the link for "welcome.txt" -# When I open the "Shares" section -# Then I see that the current section is "Shares" -# Then I see that the file list contains a file named "welcome.txt" - -# Scenario: show shares for a second time -# Given I am logged in -# And I open the "Shares" section -# And I see that the current section is "Shares" -# And I open the "All files" section -# And I see that the current section is "All files" -# And I share the link for "welcome.txt" -# When I open the "Shares" section -# Then I see that the current section is "Shares" -# Then I see that the file list contains a file named "welcome.txt" - -# Scenario: show deleted files -# Given I am logged in -# And I delete "welcome.txt" -# When I open the "Deleted files" section -# Then I see that the current section is "Deleted files" -# Then I see that the file list contains a file named "welcome.txt" - -# Scenario: show deleted files for a second time -# Given I am logged in -# And I open the "Deleted files" section -# And I see that the current section is "Deleted files" -# And I open the "All files" section -# And I see that the current section is "All files" -# And I delete "welcome.txt" -# When I open the "Deleted files" section -# Then I see that the current section is "Deleted files" -# Then I see that the file list contains a file named "welcome.txt" - -# Scenario: move a file to another folder -# Given I am logged in -# And I create a new folder named "Destination" -# When I start the move or copy operation for "welcome.txt" -# And I select "Destination" in the file picker -# And I move to the last selected folder in the file picker -# Then I see that the file list does not contain a file named "welcome.txt" -# And I enter in the folder named "Destination" -# And I see that the file list contains a file named "welcome.txt" - -# Scenario: move a selection to another folder -# Given I am logged in -# And I create a new folder named "Folder" -# And I create a new folder named "Not selected folder" -# And I create a new folder named "Destination" -# When I select "welcome.txt" -# And I select "Folder" -# And I start the move or copy operation for the selected files -# And I select "Destination" in the file picker -# And I move to the last selected folder in the file picker -# Then I see that the file list does not contain a file named "welcome.txt" -# And I see that the file list does not contain a file named "Folder" -# And I see that the file list contains a file named "Not selected folder" -# And I enter in the folder named "Destination" -# And I see that the file list contains a file named "welcome.txt" -# And I see that the file list contains a file named "Folder" -# And I see that the file list does not contain a file named "Not selected folder" - -# Scenario: copy a file to another folder -# Given I am logged in -# And I create a new folder named "Destination" -# When I start the move or copy operation for "welcome.txt" -# And I select "Destination" in the file picker -# And I copy to the last selected folder in the file picker -# Then I enter in the folder named "Destination" -# # The file will appear in the destination once the copy operation finishes -# And I see that the file list contains a file named "welcome.txt" -# # The Files app is open again to reload the file list in the root folder -# And I open the Files app -# And I see that the file list contains a file named "welcome.txt" - -# Scenario: copy a selection to another folder -# Given I am logged in -# And I create a new folder named "Folder" -# And I create a new folder named "Not selected folder" -# And I create a new folder named "Destination" -# When I select "welcome.txt" -# And I select "Folder" -# And I start the move or copy operation for the selected files -# And I select "Destination" in the file picker -# And I copy to the last selected folder in the file picker -# Then I enter in the folder named "Destination" -# # The files will appear in the destination once the copy operation finishes -# And I see that the file list contains a file named "welcome.txt" -# And I see that the file list contains a file named "Folder" -# And I see that the file list does not contain a file named "Not selected folder" -# # The Files app is open again to reload the file list in the root folder -# And I open the Files app -# And I see that the file list contains a file named "welcome.txt" -# And I see that the file list contains a file named "Folder" -# And I see that the file list contains a file named "Not selected folder" - - Scenario: copy a file in its same folder - Given I am logged in - When I start the move or copy operation for "welcome.txt" - # No folder was explicitly selected, so the last selected folder is the - # current folder. - And I copy to the last selected folder in the file picker - Then I see that the file list contains a file named "welcome.txt" - And I see that the file list contains a file named "welcome (copy).txt" - - Scenario: copy a file twice in its same folder - Given I am logged in - And I start the move or copy operation for "welcome.txt" - # No folder was explicitly selected, so the last selected folder is the - # current folder. - And I copy to the last selected folder in the file picker - When I start the move or copy operation for "welcome.txt" - And I copy to the last selected folder in the file picker - Then I see that the file list contains a file named "welcome.txt" - And I see that the file list contains a file named "welcome (copy).txt" - And I see that the file list contains a file named "welcome (copy 2).txt" - - Scenario: copy a copy of a file in its same folder - Given I am logged in - And I start the move or copy operation for "welcome.txt" - # No folder was explicitly selected, so the last selected folder is the - # current folder. - And I copy to the last selected folder in the file picker - When I start the move or copy operation for "welcome (copy).txt" - And I copy to the last selected folder in the file picker - Then I see that the file list contains a file named "welcome.txt" - And I see that the file list contains a file named "welcome (copy).txt" - And I see that the file list contains a file named "welcome (copy 2).txt" - -# Scenario: rename a file with the details view open -# Given I am logged in -# And I open the details view for "welcome.txt" -# When I rename "welcome.txt" to "farewell.txt" -# Then I see that the file list contains a file named "farewell.txt" -# And I see that the file name shown in the details view is "farewell.txt" - - Scenario: marking a file as favorite causes the file list to be sorted again - Given I am logged in - And I create a new folder named "A name alphabetically lower than welcome.txt" - And I see that "A name alphabetically lower than welcome.txt" precedes "welcome.txt" in the file list - # To mark the file as favorite the file actions menu has to be shown but, as - # the details view is opened automatically when the folder is created, - # clicking on the menu trigger could fail if it is covered by the details - # view due to its opening animation. Instead of ensuring that the animations - # of the contents and the details view have both finished it is easier to - # close the details view and wait until it is closed before continuing. - And I close the details view - And I see that the details view is closed - When I mark "welcome.txt" as favorite - Then I see that "welcome.txt" is marked as favorite - And I see that "welcome.txt" precedes "A name alphabetically lower than welcome.txt" in the file list - - Scenario: unmarking a file as favorite causes the file list to be sorted again - Given I am logged in - And I create a new folder named "A name alphabetically lower than welcome.txt" - And I see that "A name alphabetically lower than welcome.txt" precedes "welcome.txt" in the file list - # To mark the file as favorite the file actions menu has to be shown but, as - # the details view is opened automatically when the folder is created, - # clicking on the menu trigger could fail if it is covered by the details - # view due to its opening animation. Instead of ensuring that the animations - # of the contents and the details view have both finished it is easier to - # close the details view and wait until it is closed before continuing. - And I close the details view - And I see that the details view is closed - And I mark "welcome.txt" as favorite - And I see that "welcome.txt" is marked as favorite - And I see that "welcome.txt" precedes "A name alphabetically lower than welcome.txt" in the file list - When I unmark "welcome.txt" as favorite - Then I see that "welcome.txt" is not marked as favorite - And I see that "A name alphabetically lower than welcome.txt" precedes "welcome.txt" in the file list - - Scenario: mark a file as favorite in the details view - Given I am logged in - And I open the details view for "welcome.txt" - And I see that the details view is open - When I mark the file as favorite in the details view - Then I see that "welcome.txt" is marked as favorite - And I see that the file is marked as favorite in the details view - - Scenario: unmark a file as favorite in the details view - Given I am logged in - And I open the details view for "welcome.txt" - And I see that the details view is open - And I mark the file as favorite in the details view - And I see that "welcome.txt" is marked as favorite - And I see that the file is marked as favorite in the details view - When I unmark the file as favorite in the details view - Then I see that "welcome.txt" is not marked as favorite - And I see that the file is not marked as favorite in the details view diff --git a/tests/acceptance/features/app-theming.feature b/tests/acceptance/features/app-theming.feature deleted file mode 100644 index 01c7d8df8dd..00000000000 --- a/tests/acceptance/features/app-theming.feature +++ /dev/null @@ -1,27 +0,0 @@ -@apache -Feature: app-theming - - Scenario: changing the color updates the header color - Given I am logged in as the admin - And I visit the settings page - And I open the "Theming" section - And I see that the color selector in the Theming app has loaded - # The "eventually" part is not really needed here, as the colour is not - # being animated at this point, but there is no need to create a specific - # step just for this. - And I see that the header color is eventually "#0082C9" - When I set the "Color" parameter in the Theming app to "#C9C9C9" - Then I see that the parameters in the Theming app are eventually saved - And I see that the header color is eventually "#C9C9C9" - - Scenario: resetting the color updates the header color - Given I am logged in as the admin - And I visit the settings page - And I open the "Theming" section - And I see that the color selector in the Theming app has loaded - And I set the "Color" parameter in the Theming app to "#C9C9C9" - And I see that the parameters in the Theming app are eventually saved - And I see that the header color is eventually "#C9C9C9" - When I reset the "Color" parameter in the Theming app to its default value - Then I see that the parameters in the Theming app are eventually saved - And I see that the header color is eventually "#0082C9" diff --git a/tests/acceptance/features/apps.feature b/tests/acceptance/features/apps.feature deleted file mode 100644 index 0fc2f2a686d..00000000000 --- a/tests/acceptance/features/apps.feature +++ /dev/null @@ -1,92 +0,0 @@ -@apache -Feature: apps - - Scenario: enable an installed app - Given I act as Jane - And I am logged in as the admin - And I open the Apps management - When I enable the "QA testing" app - Then I see that the "QA testing" app has been enabled - - Scenario: disable a installed app - Given I act as Jane - And I am logged in as the admin - And I open the Apps management - When I disable the "Update notification" app - Then I see that the "Update notification" app has been disabled - - Scenario: Browse enabled apps - Given I act as Jane - And I am logged in as the admin - And I open the Apps management - When I open the "Active apps" section - Then I see that the current section is "Active apps" - And I see that there are only enabled apps - - Scenario: Browse disabled apps - Given I act as Jane - And I am logged in as the admin - And I open the Apps management - When I open the "Disabled apps" section - Then I see that the current section is "Disabled apps" - And I see that there are only disabled apps - - Scenario: Browse app bundles - Given I act as Jane - And I am logged in as the admin - And I open the Apps management - When I open the "App bundles" section - Then I see that the current section is "App bundles" - And I see the app bundles - And I see that the "Enterprise bundle" is disabled - -# Enabling an app bundle fails when not all apps have a matching version available -# Scenario: Enable an app bundle -# Given I act as Jane -# And I am logged in as the admin -# And I open the Apps management -# And I open the "App bundles" section -# When I enable all apps from the "Enterprise bundle" -# Then I see that the "Auditing / Logging" app has been enabled -# And I see that the "LDAP user and group backend" app has been enabled - - Scenario: View app details - Given I act as Jane - And I am logged in as the admin - And I open the Apps management - When I click on the "QA testing" app - Then I see that the app details are shown - - # TODO: Improve testing with app store as external API - # The following scenarios require the files_antivirus and calendar app - # being present in the app store with support for the current server version - # Ideally we would have either a dummy app store endpoint with some test apps - # or even an app store instance running somewhere to properly test this. - # This is also a requirement to properly test updates of apps - - Scenario: Show section from app store - Given I act as Jane - And I am logged in as the admin - And I open the Apps management - And I see that the current section is "Your apps" - #When I open the "Files" section - #Then I see that there some apps listed from the app store - #And I see that the current section is "Files" - -# Scenario: View app details for app store apps -# Given I act as Jane -# And I am logged in as the admin -# And I open the Apps management -# And I open the "Tools" section -# When I click on the "Antivirus for files" app -# Then I see that the app details are shown - -# Scenario: Install an app from the app store -# Given I act as Jane -# And I am logged in as the admin -# And I open the Apps management -# And I open the "Tools" section -# And I click on the "Antivirus for files" app -# And I see that the app details are shown -# Then I download and enable the "Antivirus for files" app -# And I see that the "Antivirus for files" app has been enabled diff --git a/tests/acceptance/features/bootstrap/AppNavigationContext.php b/tests/acceptance/features/bootstrap/AppNavigationContext.php deleted file mode 100644 index df6ed228960..00000000000 --- a/tests/acceptance/features/bootstrap/AppNavigationContext.php +++ /dev/null @@ -1,143 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class AppNavigationContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function appNavigation() { - return Locator::forThe()->xpath("//*[@id=\"app-navigation\" or contains(@class, 'app-navigation')]")-> - describedAs("App navigation"); - } - - /** - * @return Locator - */ - public static function appNavigationSectionItemFor($sectionText) { - return Locator::forThe()->xpath("//li/a[normalize-space() = '$sectionText']/..")-> - descendantOf(self::appNavigation())-> - describedAs($sectionText . " section item in App Navigation"); - } - - /** - * @return Locator - */ - public static function appNavigationSectionItemInFor($caption, $sectionText) { - return Locator::forThe()->xpath("//li[normalize-space() = '$caption']/following-sibling::li/a[normalize-space() = '$sectionText']/..")-> - descendantOf(self::appNavigation())-> - describedAs($sectionText . " section item of the $caption group in App Navigation"); - } - - /** - * @return Locator - */ - public static function appNavigationCurrentSectionItem() { - return Locator::forThe()->css(".active")-> - descendantOf(self::appNavigation())-> - describedAs("Current section item in App Navigation"); - } - - /** - * @return Locator - */ - public static function buttonForTheSection($class, $section) { - return Locator::forThe()->css("." . $class)-> - descendantOf(self::appNavigationSectionItemFor($section))-> - describedAs("The $class button on the $section section in App Navigation"); - } - - /** - * @return Locator - */ - public static function counterForTheSection($section) { - return Locator::forThe()->css(".app-navigation-entry-utils-counter")-> - descendantOf(self::appNavigationSectionItemFor($section))-> - describedAs("The counter for the $section section in App Navigation"); - } - - /** - * @Given I open the :section section - */ - public function iOpenTheSection($section) { - $this->actor->find(self::appNavigationSectionItemFor($section), 10)->click(); - } - - /** - * @Given I open the :section section of the :caption group - */ - public function iOpenTheSectionOf($caption, $section) { - $this->actor->find(self::appNavigationSectionItemInFor($caption, $section), 10)->click(); - } - - /** - * @Given I click the :class button on the :section section - */ - public function iClickTheButtonInTheSection($class, $section) { - $this->actor->find(self::buttonForTheSection($class, $section), 10)->click(); - } - - /** - * @Then I see that the current section is :section - */ - public function iSeeThatTheCurrentSectionIs($section) { - PHPUnit_Framework_Assert::assertEquals($this->actor->find(self::appNavigationCurrentSectionItem(), 10)->getText(), $section); - } - - /** - * @Then I see that the section :section is shown - */ - public function iSeeThatTheSectionIsShown($section) { - WaitFor::elementToBeEventuallyShown($this->actor, self::appNavigationSectionItemFor($section)); - } - - /** - * @Then I see that the section :section is not shown - */ - public function iSeeThatTheSectionIsNotShown($section) { - WaitFor::elementToBeEventuallyNotShown($this->actor, self::appNavigationSectionItemFor($section)); - } - - /** - * @Then I see that the section :section has a count of :count - */ - public function iSeeThatTheSectionHasACountOf($section, $count) { - PHPUnit_Framework_Assert::assertEquals($this->actor->find(self::counterForTheSection($section), 10)->getText(), $count); - } - - /** - * @Then I see that the section :section does not have a count - */ - public function iSeeThatTheSectionDoesNotHaveACount($section) { - if (!WaitFor::elementToBeEventuallyNotShown( - $this->actor, - self::counterForTheSection($section), - $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The counter for section $section is still shown after $timeout seconds"); - } - } -} diff --git a/tests/acceptance/features/bootstrap/AppSettingsContext.php b/tests/acceptance/features/bootstrap/AppSettingsContext.php deleted file mode 100644 index b2b6744a36b..00000000000 --- a/tests/acceptance/features/bootstrap/AppSettingsContext.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class AppSettingsContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function appSettings() { - return Locator::forThe()->id("app-settings")-> - describedAs("App settings"); - } - /** - * @return Locator - */ - public static function appSettingsContent() { - return Locator::forThe()->id("app-settings-content")-> - descendantOf(self::appSettings())-> - describedAs("App settings"); - } - - /** - * @return Locator - */ - public static function appSettingsOpenButton() { - return Locator::forThe()->xpath("//div[@id = 'app-settings-header']/button")-> - descendantOf(self::appSettings())-> - describedAs("The button to open the app settings"); - } - - /** - * @return Locator - */ - public static function checkboxInTheSettings($id) { - return Locator::forThe()->xpath("//input[@id = '$id']")-> - descendantOf(self::appSettingsContent())-> - describedAs("The $id checkbox in the settings"); - } - - /** - * @return Locator - */ - public static function checkboxLabelInTheSettings($id) { - return Locator::forThe()->xpath("//label[@for = '$id']")-> - descendantOf(self::appSettingsContent())-> - describedAs("The label for the $id checkbox in the settings"); - } - - /** - * @Given I open the settings - */ - public function iOpenTheSettings() { - $this->actor->find(self::appSettingsOpenButton())->click(); - } - - /** - * @Given I toggle the :id checkbox in the settings - */ - public function iToggleTheCheckboxInTheSettingsTo($id) { - $locator = self::CheckboxInTheSettings($id); - - // If locator is not visible, fallback to label - if (!$this->actor->find(self::CheckboxInTheSettings($id))->isVisible()) { - $locator = self::checkboxLabelInTheSettings($id); - } - - $this->actor->find($locator)->click(); - } - - /** - * @Then I see that the settings are opened - */ - public function iSeeThatTheSettingsAreOpened() { - WaitFor::elementToBeEventuallyShown($this->actor, self::appSettingsContent()); - } -} diff --git a/tests/acceptance/features/bootstrap/AppsManagementContext.php b/tests/acceptance/features/bootstrap/AppsManagementContext.php deleted file mode 100644 index 1f3b2dbe28a..00000000000 --- a/tests/acceptance/features/bootstrap/AppsManagementContext.php +++ /dev/null @@ -1,229 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net> - * - * @author Julius Härtl <jus@bitgrid.net> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class AppsManagementContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function enableButtonForApp($app) { - return Locator::forThe()->button("Enable")-> - descendantOf(self::rowForApp($app))-> - describedAs("Enable button in the app list for $app"); - } - - /** - * @return Locator - */ - public static function downloadAndEnableButtonForApp($app) { - return Locator::forThe()->button("Download and enable")-> - descendantOf(self::rowForApp($app))-> - describedAs("Download & enable button in the app list for $app"); - } - - /** - * @return Locator - */ - public static function disableButtonForApp($app) { - return Locator::forThe()->button("Disable")-> - descendantOf(self::rowForApp($app))-> - describedAs("Disable button in the app list for $app"); - } - - /** - * @return Locator - */ - public static function bundleButton($bundle) { - return Locator::forThe()->xpath("//main[@id='app-content' or contains(@class, 'app-content')]//div[@class='apps-header']/h2[normalize-space() = '$bundle']/input")-> - describedAs("Button to enable / disable bundles"); - } - - /** - * @return Locator - */ - public static function rowForApp($app) { - return Locator::forThe()->xpath("//main[@id='app-content' or contains(@class, 'app-content')]//div[@class='app-name'][normalize-space() = '$app']/..")-> - describedAs("Row for app $app in Apps Management"); - } - - /** - * @return Locator - */ - public static function emptyAppList() { - return Locator::forThe()->xpath("//main[@id='app-content' or contains(@class, 'app-content')]//div[@id='apps-list-empty']")-> - describedAs("Empty apps list view"); - } - - /** - * @return Locator - */ - public static function appEntries() { - return Locator::forThe()->xpath("//main[@id='app-content' or contains(@class, 'app-content')]//div[@class='section']")-> - describedAs("Entries in apps list"); - } - - /** - * @return Locator - */ - public static function disabledAppEntries() { - return Locator::forThe()->button("Disable")-> - descendantOf(self::appEntries())-> - describedAs("Disable button in the app list"); - } - - /** - * @return Locator - */ - public static function enabledAppEntries() { - return Locator::forThe()->button("Enable")-> - descendantOf(self::appEntries())-> - describedAs("Enable button in the app list"); - } - - /** - * @return Locator - */ - public static function sidebar() { - return Locator::forThe()->xpath("//*[@id=\"app-sidebar\" or contains(@class, 'app-sidebar')]")-> - describedAs("Sidebar in apps management"); - } - - - /** - * @When I enable the :app app - */ - public function iEnableTheApp($app) { - $this->actor->find(self::enableButtonForApp($app), 10)->click(); - } - - /** - * @When I download and enable the :app app - */ - public function iDownloadAndEnableTheApp($app) { - $this->actor->find(self::downloadAndEnableButtonForApp($app), 10)->click(); - } - - /** - * @When I disable the :app app - */ - public function iDisableTheApp($app) { - $this->actor->find(self::disableButtonForApp($app), 10)->click(); - } - - /** - * @Then I see that the :app app has been enabled - */ - public function iSeeThatTheAppHasBeenEnabled($app) { - // TODO: Find a way to check if the enable button is removed - $this->actor->find(self::disableButtonForApp($app), 10); - } - - /** - * @Then I see that the :app app has been disabled - */ - public function iSeeThatTheAppHasBeenDisabled($app) { - // TODO: Find a way to check if the disable button is removed - $this->actor->find(self::enableButtonForApp($app), 10); - } - - /** - * @Then /^I see that there are no available updates$/ - */ - public function iSeeThatThereAreNoAvailableUpdates() { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::emptyAppList(), 10)->isVisible() - ); - } - - /** - * @Then /^I see that there some apps listed from the app store$/ - */ - public function iSeeThatThereSomeAppsListedFromTheAppStore() { - WaitFor::elementToBeEventuallyShown($this->actor, self::appEntries(), 10); - } - - /** - * @When /^I click on the "([^"]*)" app$/ - */ - public function iClickOnTheApp($app) { - $this->actor->find(self::rowForApp($app), 10)->click(); - } - - /** - * @Given /^I see that there are only disabled apps$/ - */ - public function iSeeThatThereAreOnlyDisabledApps() { - $buttons = $this->actor->getSession()->getDriver()->find("//input[@value = 'Disable']"); - PHPUnit\Framework\Assert::assertEmpty($buttons, 'Found disabled apps'); - } - - /** - * @Given /^I see that there are only enabled apps$/ - */ - public function iSeeThatThereAreOnlyEnabledApps() { - $buttons = $this->actor->getSession()->getDriver()->find("//input[@value = 'Enable']"); - PHPUnit\Framework\Assert::assertEmpty($buttons, 'Found disabled apps'); - } - - /** - * @Given /^I see the app bundles$/ - */ - public function iSeeTheAppBundles() { - $this->actor->find(self::rowForApp('Auditing / Logging'), 2); - $this->actor->find(self::rowForApp('LDAP user and group backend'), 2); - } - - /** - * @When /^I enable all apps from the "([^"]*)"$/ - */ - public function iEnableAllAppsFromThe($bundle) { - $this->actor->find(self::bundleButton($bundle), 2)->click(); - } - - /** - * @Given /^I see that the "([^"]*)" is disabled$/ - */ - public function iSeeThatTheIsDisabled($bundle) { - PHPUnit\Framework\Assert::assertEquals('Enable all', $this->actor->find(self::bundleButton($bundle))->getValue()); - } - - /** - * @Given /^I see that the app details are shown$/ - */ - public function iSeeThatTheAppDetailsAreShown() { - // The sidebar always exists in the DOM, so it has to be explicitly - // waited for it to be visible instead of relying on the implicit wait - // made to find the element. - if (!WaitFor::elementToBeEventuallyShown( - $this->actor, - self::sidebar(), - $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The sidebar was not shown yet after $timeout seconds"); - } - } -} diff --git a/tests/acceptance/features/bootstrap/CommentsAppContext.php b/tests/acceptance/features/bootstrap/CommentsAppContext.php deleted file mode 100644 index 57e60afa60e..00000000000 --- a/tests/acceptance/features/bootstrap/CommentsAppContext.php +++ /dev/null @@ -1,112 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class CommentsAppContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function newCommentField() { - return Locator::forThe()->css("div.newCommentRow .message")-> - descendantOf(FilesAppContext::detailsView())-> - describedAs("New comment field in details view in Files app"); - } - - /** - * @return Locator - */ - public static function submitNewCommentButton() { - return Locator::forThe()->css("div.newCommentRow .submit")-> - descendantOf(FilesAppContext::detailsView())-> - describedAs("Submit new comment button in details view in Files app"); - } - - /** - * @return Locator - */ - public static function commentList() { - return Locator::forThe()->css("ul.comments")-> - descendantOf(FilesAppContext::detailsView())-> - describedAs("Comment list in details view in Files app"); - } - - /** - * @return Locator - */ - public static function commentWithText($text) { - return Locator::forThe()->xpath("//div[normalize-space() = '$text']/ancestor::li")-> - descendantOf(self::commentList())-> - describedAs("Comment with text \"$text\" in details view in Files app"); - } - - /** - * @return Locator - */ - public static function emptyContent() { - return Locator::forThe()->css(".emptycontent")-> - descendantOf(FilesAppContext::detailsView())-> - describedAs("Empty content in details view in Files app"); - } - - /** - * @When /^I create a new comment with "([^"]*)" as message$/ - */ - public function iCreateANewCommentWithAsMessage($commentText) { - $this->actor->find(self::newCommentField(), 10)->setValue($commentText); - $this->actor->find(self::submitNewCommentButton())->click(); - } - - /** - * @Then /^I see that there are no comments$/ - */ - public function iSeeThatThereAreNoComments() { - if (!WaitFor::elementToBeEventuallyShown( - $this->actor, - self::emptyContent(), - $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The no comments message is not visible yet after $timeout seconds"); - } - } - - /** - * @Then /^I see a comment with "([^"]*)" as message$/ - */ - public function iSeeACommentWithAsMessage($commentText) { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::commentWithText($commentText), 10)->isVisible()); - } - - /** - * @Then /^I see that there is no comment with "([^"]*)" as message$/ - */ - public function iSeeThatThereIsNoCommentWithAsMessage($commentText) { - try { - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::commentWithText($commentText))->isVisible()); - } catch (NoSuchElementException $exception) { - } - } -} diff --git a/tests/acceptance/features/bootstrap/ContactsMenuContext.php b/tests/acceptance/features/bootstrap/ContactsMenuContext.php deleted file mode 100644 index 860e84fa950..00000000000 --- a/tests/acceptance/features/bootstrap/ContactsMenuContext.php +++ /dev/null @@ -1,145 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv) (skjnldsv@protonmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class ContactsMenuContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function contactsMenuButton() { - return Locator::forThe()->xpath("//*[@id = 'header']//*[@id = 'contactsmenu']")-> - describedAs("Contacts menu button"); - } - - /** - * @return Locator - */ - public static function contactsMenu() { - return Locator::forThe()->css(".menu")-> - descendantOf(self::contactsMenuButton())-> - describedAs("Contacts menu"); - } - - /** - * @return Locator - */ - public static function contactsMenuSearchInput() { - return Locator::forThe()->id("contactsmenu-search")-> - descendantOf(self::contactsMenu())-> - describedAs("Contacts menu search input"); - } - - /** - * @return Locator - */ - public static function noResultsMessage() { - return Locator::forThe()->xpath("//*[@class = 'emptycontent' and normalize-space() = 'No contacts found']")-> - descendantOf(self::contactsMenu())-> - describedAs("No results message in Contacts menu"); - } - - /** - * @return Locator - */ - private static function menuItemFor($contactName) { - return Locator::forThe()->xpath("//*[@class = 'full-name' and normalize-space() = '$contactName']")-> - descendantOf(self::contactsMenu())-> - describedAs($contactName . " contact in Contacts menu"); - } - - /** - * @When I open the Contacts menu - */ - public function iOpenTheContactsMenu() { - $this->actor->find(self::contactsMenuButton(), 10)->click(); - } - - /** - * @When I search for the user :user - */ - public function iSearchForTheUser($user) { - $this->actor->find(self::contactsMenuSearchInput(), 10)->setValue($user . "\r"); - } - - /** - * @Then I see that the Contacts menu is shown - */ - public function iSeeThatTheContactsMenuIsShown() { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::contactsMenu(), 10)->isVisible()); - } - - /** - * @Then I see that the Contacts menu search input is shown - */ - public function iSeeThatTheContactsMenuSearchInputIsShown() { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::contactsMenuSearchInput(), 10)->isVisible()); - } - - /** - * @Then I see that the no results message in the Contacts menu is shown - */ - public function iSeeThatTheNoResultsMessageInTheContactsMenuIsShown() { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::noResultsMessage(), 10)->isVisible()); - } - - /** - * @Then I see that the contact :contactName in the Contacts menu is shown - */ - public function iSeeThatTheContactInTheContactsMenuIsShown($contactName) { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::menuItemFor($contactName), 10)->isVisible()); - } - - /** - * @Then I see that the contact :contactName in the Contacts menu is not shown - */ - public function iSeeThatTheContactInTheContactsMenuIsNotShown($contactName) { - $this->iSeeThatThecontactsMenuIsShown(); - - try { - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::menuItemFor($contactName))->isVisible()); - } catch (NoSuchElementException $exception) { - } - } - - /** - * @Then I see that the contact :contactName in the Contacts menu is eventually not shown - */ - public function iSeeThatTheContactInTheContactsMenuIsEventuallyNotShown($contactName) { - $this->iSeeThatThecontactsMenuIsShown(); - - if (!WaitFor::elementToBeEventuallyNotShown( - $this->actor, - self::menuItemFor($contactName), - $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The $contactName contact in Contacts menu is still shown after $timeout seconds"); - } - } -} diff --git a/tests/acceptance/features/bootstrap/DialogContext.php b/tests/acceptance/features/bootstrap/DialogContext.php deleted file mode 100644 index f9d2d6244e9..00000000000 --- a/tests/acceptance/features/bootstrap/DialogContext.php +++ /dev/null @@ -1,66 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class DialogContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function theDialog() { - return Locator::forThe()->css(".oc-dialog")-> - describedAs("The dialog"); - } - - /** - * @return Locator - */ - public static function theDialogButton($text) { - return Locator::forThe()->xpath("//button[normalize-space() = '$text']")-> - descendantOf(self::theDialog())-> - describedAs($text . " button of the dialog"); - } - - /** - * @Given I click the :text button of the confirmation dialog - */ - public function iClickTheDialogButton($text) { - $this->actor->find(self::theDialogButton($text), 10)->click(); - } - - /** - * @Then I see that the confirmation dialog is shown - */ - public function iSeeThatTheConfirmationDialogIsShown() { - WaitFor::elementToBeEventuallyShown($this->actor, self::theDialog()); - } - - /** - * @Then I see that the confirmation dialog is not shown - */ - public function iSeeThatTheConfirmationDialogIsNotShown() { - WaitFor::elementToBeEventuallyNotShown($this->actor, self::theDialog()); - } -} diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php deleted file mode 100644 index 72798ea98f7..00000000000 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class FeatureContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @When I visit the Home page - */ - public function iVisitTheHomePage() { - $this->actor->getSession()->visit($this->actor->locatePath("/")); - } -} diff --git a/tests/acceptance/features/bootstrap/FileListAncestorSetter.php b/tests/acceptance/features/bootstrap/FileListAncestorSetter.php deleted file mode 100644 index af8534f012c..00000000000 --- a/tests/acceptance/features/bootstrap/FileListAncestorSetter.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Hook\Scope\BeforeScenarioScope; - -/** - * Helper trait to set the ancestor of the file list. - * - * The FileListContext provides steps to interact with and check the behaviour - * of a file list. However, the FileListContext does not know the right file - * list ancestor that has to be used by the file list steps; this has to be set - * from other contexts, for example, when the Files app or the public page for a - * shared folder is opened. - * - * Contexts that "know" that certain file list ancestor has to be used by the - * FileListContext steps should use this trait and call - * "setFileListAncestorForActor" when needed. - */ -trait FileListAncestorSetter { - - /** - * @var FileListContext - */ - private $fileListContext; - - /** - * @BeforeScenario - */ - public function getSiblingFileListContext(BeforeScenarioScope $scope) { - $environment = $scope->getEnvironment(); - - $this->fileListContext = $environment->getContext("FileListContext"); - } - - /** - * Sets the file list ancestor to be used in the file list steps performed - * by the given actor. - * - * @param null|Locator $fileListAncestor the file list ancestor - * @param Actor $actor the actor - */ - private function setFileListAncestorForActor($fileListAncestor, Actor $actor) { - $this->fileListContext->setFileListAncestorForActor($fileListAncestor, $actor); - } -} diff --git a/tests/acceptance/features/bootstrap/FileListContext.php b/tests/acceptance/features/bootstrap/FileListContext.php deleted file mode 100644 index 0b0c80bc272..00000000000 --- a/tests/acceptance/features/bootstrap/FileListContext.php +++ /dev/null @@ -1,585 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class FileListContext implements Context, ActorAwareInterface { - - /** - * @var Actor - */ - private $actor; - - /** - * @var array - */ - private $fileListAncestorsByActor; - - /** - * @var Locator - */ - private $fileListAncestor; - - /** - * @BeforeScenario - */ - public function initializeFileListAncestors() { - $this->fileListAncestorsByActor = []; - $this->fileListAncestor = null; - } - - /** - * @param Actor $actor - */ - public function setCurrentActor(Actor $actor) { - $this->actor = $actor; - - if (array_key_exists($actor->getName(), $this->fileListAncestorsByActor)) { - $this->fileListAncestor = $this->fileListAncestorsByActor[$actor->getName()]; - } else { - $this->fileListAncestor = null; - } - } - - /** - * Sets the file list ancestor to be used in the steps performed by the - * given actor from that point on (until changed again). - * - * This is meant to be called from other contexts, for example, when the - * Files app or the public page for a shared folder are opened. - * - * The FileListAncestorSetter trait can be used to reduce the boilerplate - * needed to set the file list ancestor from other contexts. - * - * @param null|Locator $fileListAncestor the file list ancestor - * @param Actor $actor the actor - */ - public function setFileListAncestorForActor($fileListAncestor, Actor $actor) { - $this->fileListAncestorsByActor[$actor->getName()] = $fileListAncestor; - } - - /** - * @return Locator - */ - public static function mainWorkingIcon($fileListAncestor) { - return Locator::forThe()->css(".mask.icon-loading")-> - descendantOf($fileListAncestor)-> - describedAs("Main working icon in file list"); - } - - /** - * @return Locator - */ - public static function breadcrumbs($fileListAncestor) { - return Locator::forThe()->css("#controls .breadcrumb")-> - descendantOf($fileListAncestor)-> - describedAs("Breadcrumbs in file list"); - } - - /** - * @return Locator - */ - public static function createMenuButton($fileListAncestor) { - return Locator::forThe()->css("#controls .button.new")-> - descendantOf($fileListAncestor)-> - describedAs("Create menu button in file list"); - } - - /** - * @return Locator - */ - private static function createMenuItemFor($fileListAncestor, $newType) { - return Locator::forThe()->xpath("//div[contains(concat(' ', normalize-space(@class), ' '), ' newFileMenu ')]//span[normalize-space() = '$newType']/ancestor::li")-> - descendantOf($fileListAncestor)-> - describedAs("Create $newType menu item in file list"); - } - - /** - * @return Locator - */ - public static function createNewFolderMenuItem($fileListAncestor) { - return self::createMenuItemFor($fileListAncestor, "New folder"); - } - - /** - * @return Locator - */ - public static function createNewFolderMenuItemNameInput($fileListAncestor) { - return Locator::forThe()->css(".filenameform input")-> - descendantOf(self::createNewFolderMenuItem($fileListAncestor))-> - describedAs("Name input in create new folder menu item in file list"); - } - - /** - * @return Locator - */ - public static function fileListHeader($fileListAncestor) { - return Locator::forThe()->css("thead")-> - descendantOf($fileListAncestor)-> - describedAs("Header in file list"); - } - - /** - * @return Locator - */ - public static function selectedFilesActionsMenuButton($fileListAncestor) { - return Locator::forThe()->css(".actions-selected")-> - descendantOf(self::fileListHeader($fileListAncestor))-> - describedAs("Selected files actions menu button in file list"); - } - - /** - * @return Locator - */ - public static function selectedFilesActionsMenu() { - return Locator::forThe()->css(".filesSelectMenu")-> - describedAs("Selected files actions menu in file list"); - } - - /** - * @return Locator - */ - private static function selectedFilesActionsMenuItemFor($itemText) { - return Locator::forThe()->xpath("//a[normalize-space() = '$itemText']")-> - descendantOf(self::selectedFilesActionsMenu())-> - describedAs($itemText . " item in selected files actions menu in file list"); - } - - /** - * @return Locator - */ - public static function moveOrCopySelectedFilesMenuItem() { - return self::selectedFilesActionsMenuItemFor("Move or copy"); - } - - /** - * @return Locator - */ - public static function rowForFile($fileListAncestor, $fileName) { - return Locator::forThe()->xpath("//*[@id = 'fileList']//span[contains(concat(' ', normalize-space(@class), ' '), ' nametext ') and normalize-space() = '$fileName']/ancestor::tr")-> - descendantOf($fileListAncestor)-> - describedAs("Row for file $fileName in file list"); - } - - /** - * @return Locator - */ - public static function rowForFilePreceding($fileListAncestor, $fileName1, $fileName2) { - return Locator::forThe()->xpath("//preceding-sibling::tr//span[contains(concat(' ', normalize-space(@class), ' '), ' nametext ') and normalize-space() = '$fileName1']/ancestor::tr")-> - descendantOf(self::rowForFile($fileListAncestor, $fileName2))-> - describedAs("Row for file $fileName1 preceding $fileName2 in file list"); - } - - /** - * @return Locator - */ - public static function selectionCheckboxForFile($fileListAncestor, $fileName) { - // Note that the element that the user interacts with is the label, not - // the checbox itself. - return Locator::forThe()->css(".selection label")-> - descendantOf(self::rowForFile($fileListAncestor, $fileName))-> - describedAs("Selection checkbox for file $fileName in file list"); - } - - /** - * @return Locator - */ - public static function selectionCheckboxInputForFile($fileListAncestor, $fileName) { - return Locator::forThe()->css(".selection input[type=checkbox]")-> - descendantOf(self::rowForFile($fileListAncestor, $fileName))-> - describedAs("Selection checkbox input for file $fileName in file list"); - } - - /** - * @return Locator - */ - public static function favoriteMarkForFile($fileListAncestor, $fileName) { - return Locator::forThe()->css(".favorite-mark")-> - descendantOf(self::rowForFile($fileListAncestor, $fileName))-> - describedAs("Favorite mark for file $fileName in file list"); - } - - /** - * @return Locator - */ - public static function notFavoritedStateIconForFile($fileListAncestor, $fileName) { - return Locator::forThe()->css(".icon-star")-> - descendantOf(self::favoriteMarkForFile($fileListAncestor, $fileName))-> - describedAs("Not favorited state icon for file $fileName in file list"); - } - - /** - * @return Locator - */ - public static function favoritedStateIconForFile($fileListAncestor, $fileName) { - return Locator::forThe()->css(".icon-starred")-> - descendantOf(self::favoriteMarkForFile($fileListAncestor, $fileName))-> - describedAs("Favorited state icon for file $fileName in file list"); - } - - /** - * @return Locator - */ - public static function mainLinkForFile($fileListAncestor, $fileName) { - return Locator::forThe()->css(".name")-> - descendantOf(self::rowForFile($fileListAncestor, $fileName))-> - describedAs("Main link for file $fileName in file list"); - } - - /** - * @return Locator - */ - public static function renameInputForFile($fileListAncestor, $fileName) { - return Locator::forThe()->css("input.filename")-> - descendantOf(self::rowForFile($fileListAncestor, $fileName))-> - describedAs("Rename input for file $fileName in file list"); - } - - /** - * @return Locator - */ - public static function commentActionForFile($fileListAncestor, $fileName) { - return Locator::forThe()->css(".action-comment")-> - descendantOf(self::rowForFile($fileListAncestor, $fileName))-> - describedAs("Comment action for file $fileName in file list"); - } - - /** - * @return Locator - */ - public static function shareActionForFile($fileListAncestor, $fileName) { - return Locator::forThe()->css(".action-share")-> - descendantOf(self::rowForFile($fileListAncestor, $fileName))-> - describedAs("Share action for file $fileName in file list"); - } - - /** - * @return Locator - */ - public static function fileActionsMenuButtonForFile($fileListAncestor, $fileName) { - return Locator::forThe()->css(".action-menu")-> - descendantOf(self::rowForFile($fileListAncestor, $fileName))-> - describedAs("File actions menu button for file $fileName in file list"); - } - - /** - * @return Locator - */ - public static function fileActionsMenu() { - return Locator::forThe()->css(".fileActionsMenu")-> - describedAs("File actions menu in file list"); - } - - /** - * @return Locator - */ - private static function fileActionsMenuItemFor($itemText) { - return Locator::forThe()->xpath("//a[normalize-space() = '$itemText']")-> - descendantOf(self::fileActionsMenu())-> - describedAs($itemText . " item in file actions menu in file list"); - } - - /** - * @return Locator - */ - public static function addToFavoritesMenuItem() { - return self::fileActionsMenuItemFor("Add to favorites"); - } - - /** - * @return Locator - */ - public static function removeFromFavoritesMenuItem() { - return self::fileActionsMenuItemFor("Remove from favorites"); - } - - /** - * @return Locator - */ - public static function detailsMenuItem() { - return self::fileActionsMenuItemFor("Details"); - } - - /** - * @return Locator - */ - public static function renameMenuItem() { - return self::fileActionsMenuItemFor("Rename"); - } - - /** - * @return Locator - */ - public static function moveOrCopyMenuItem() { - return self::fileActionsMenuItemFor("Move or copy"); - } - - /** - * @return Locator - */ - public static function viewFileInFolderMenuItem() { - return self::fileActionsMenuItemFor("View in folder"); - } - - /** - * @return Locator - */ - public static function deleteMenuItem() { - return self::fileActionsMenuItemFor("Delete"); - } - - /** - * @Given I create a new folder named :folderName - */ - public function iCreateANewFolderNamed($folderName) { - $this->actor->find(self::createMenuButton($this->fileListAncestor), 10)->click(); - - $this->actor->find(self::createNewFolderMenuItem($this->fileListAncestor), 2)->click(); - $this->actor->find(self::createNewFolderMenuItemNameInput($this->fileListAncestor), 2)->setValue($folderName . "\r"); - } - - /** - * @Given I enter in the folder named :folderName - */ - public function iEnterInTheFolderNamed($folderName) { - $this->actor->find(self::mainLinkForFile($this->fileListAncestor, $folderName), 10)->click(); - } - - /** - * @Given I select :fileName - */ - public function iSelect($fileName) { - $this->iSeeThatIsNotSelected($fileName); - - $this->actor->find(self::selectionCheckboxForFile($this->fileListAncestor, $fileName), 10)->click(); - } - - /** - * @Given I start the move or copy operation for the selected files - */ - public function iStartTheMoveOrCopyOperationForTheSelectedFiles() { - $this->actor->find(self::selectedFilesActionsMenuButton($this->fileListAncestor), 10)->click(); - - $this->actor->find(self::moveOrCopySelectedFilesMenuItem(), 2)->click(); - } - - /** - * @Given I open the details view for :fileName - */ - public function iOpenTheDetailsViewFor($fileName) { - $this->openFileActionsMenuForFile($fileName); - - $this->actor->find(self::detailsMenuItem(), 2)->click(); - } - - /** - * @Given I rename :fileName1 to :fileName2 - */ - public function iRenameTo($fileName1, $fileName2) { - $this->openFileActionsMenuForFile($fileName1); - - $this->actor->find(self::renameMenuItem(), 2)->click(); - - // For reference, due to a bug in the Firefox driver of Selenium and/or - // maybe in Firefox itself, as a range is selected in the rename input - // (the name of the file, without its extension) when the value is set - // the window must be in the foreground. Otherwise, if the window is in - // the background, instead of setting the value in the whole field it - // would be set only in the selected range. - // This should not be a problem, though, as the default behaviour is to - // bring the browser window to the foreground when switching to a - // different actor. - $this->actor->find(self::renameInputForFile($this->fileListAncestor, $fileName1), 10)->setValue($fileName2 . "\r"); - } - - /** - * @Given I start the move or copy operation for :fileName - */ - public function iStartTheMoveOrCopyOperationFor($fileName) { - $this->openFileActionsMenuForFile($fileName); - - $this->actor->find(self::moveOrCopyMenuItem(), 2)->click(); - } - - /** - * @Given I mark :fileName as favorite - */ - public function iMarkAsFavorite($fileName) { - $this->iSeeThatIsNotMarkedAsFavorite($fileName); - - $this->openFileActionsMenuForFile($fileName); - - $this->actor->find(self::addToFavoritesMenuItem(), 2)->click(); - } - - /** - * @Given I unmark :fileName as favorite - */ - public function iUnmarkAsFavorite($fileName) { - $this->iSeeThatIsMarkedAsFavorite($fileName); - - $this->openFileActionsMenuForFile($fileName); - - $this->actor->find(self::removeFromFavoritesMenuItem(), 2)->click(); - } - - /** - * @When I view :fileName in folder - */ - public function iViewInFolder($fileName) { - $this->openFileActionsMenuForFile($fileName); - - $this->actor->find(self::viewFileInFolderMenuItem(), 2)->click(); - } - - /** - * @When I delete :fileName - */ - public function iDelete($fileName) { - $this->openFileActionsMenuForFile($fileName); - - $this->actor->find(self::deleteMenuItem(), 2)->click(); - } - - /** - * @When I open the unread comments for :fileName - */ - public function iOpenTheUnreadCommentsFor($fileName) { - $this->actor->find(self::commentActionForFile($this->fileListAncestor, $fileName), 10)->click(); - } - - /** - * @Then I see that the file list is eventually loaded - */ - public function iSeeThatTheFileListIsEventuallyLoaded() { - if (!WaitFor::elementToBeEventuallyNotShown( - $this->actor, - self::mainWorkingIcon($this->fileListAncestor), - $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The main working icon for the file list is still shown after $timeout seconds"); - } - } - - /** - * @Then I see that the file list is currently in :path - */ - public function iSeeThatTheFileListIsCurrentlyIn($path) { - // The text of the breadcrumbs is the text of all the crumbs separated - // by white spaces. - PHPUnit_Framework_Assert::assertEquals( - str_replace('/', ' ', $path), $this->actor->find(self::breadcrumbs($this->fileListAncestor), 10)->getText()); - } - - /** - * @Then I see that it is not possible to create new files - */ - public function iSeeThatItIsNotPossibleToCreateNewFiles() { - // Once a file list is loaded the "Create" menu button is always in the - // DOM, so it is checked if it is visible or not. - PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::createMenuButton($this->fileListAncestor))->isVisible()); - } - - /** - * @Then I see that the file list contains a file named :fileName - */ - public function iSeeThatTheFileListContainsAFileNamed($fileName) { - PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::rowForFile($this->fileListAncestor, $fileName), 10)); - } - - /** - * @Then I see that the file list does not contain a file named :fileName - */ - public function iSeeThatTheFileListDoesNotContainAFileNamed($fileName) { - if (!WaitFor::elementToBeEventuallyNotShown( - $this->actor, - self::rowForFile($this->fileListAncestor, $fileName), - $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The file list still contains a file named $fileName after $timeout seconds"); - } - } - - /** - * @Then I see that :fileName1 precedes :fileName2 in the file list - */ - public function iSeeThatPrecedesInTheFileList($fileName1, $fileName2) { - PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::rowForFilePreceding($this->fileListAncestor, $fileName1, $fileName2), 10)); - } - - /** - * @Then I see that :fileName is not selected - */ - public function iSeeThatIsNotSelected($fileName) { - PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::selectionCheckboxInputForFile($this->fileListAncestor, $fileName), 10)->isChecked()); - } - - /** - * @Then I see that :fileName is marked as favorite - */ - public function iSeeThatIsMarkedAsFavorite($fileName) { - PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::favoritedStateIconForFile($this->fileListAncestor, $fileName), 10)); - } - - /** - * @Then I see that :fileName is not marked as favorite - */ - public function iSeeThatIsNotMarkedAsFavorite($fileName) { - PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::notFavoritedStateIconForFile($this->fileListAncestor, $fileName), 10)); - } - - /** - * @Then I see that :fileName has unread comments - */ - public function iSeeThatHasUnreadComments($fileName) { - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::commentActionForFile($this->fileListAncestor, $fileName), 10)->isVisible()); - } - - private function waitForRowForFileToBeFullyOpaque($fileName) { - $actor = $this->actor; - $fileRowXpathExpression = $this->actor->find(self::rowForFile($this->fileListAncestor, $fileName), 10)->getWrappedElement()->getXpath(); - - $fileRowIsFullyOpaqueCallback = function () use ($actor, $fileRowXpathExpression) { - $opacity = $actor->getSession()->evaluateScript("return window.getComputedStyle(document.evaluate(\"" . $fileRowXpathExpression . "\", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue).opacity;"); - if ($opacity === "1") { - return true; - } - - return false; - }; - - if (!Utils::waitFor($fileRowIsFullyOpaqueCallback, $timeout = 2 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) { - PHPUnit_Framework_Assert::fail("The row for file $fileName in file list is not fully opaque after $timeout seconds"); - } - } - - private function openFileActionsMenuForFile($fileName) { - // When a row is added to the file list the opacity of the file row is - // animated from transparent to fully opaque. As the file actions menu - // is a descendant of the row but overflows it when the row is not fully - // opaque clicks on the menu entries "fall-through" and are received - // instead by the rows behind. Therefore it should be waited until the - // row of the file is fully opaque before using the menu. - $this->waitForRowForFileToBeFullyOpaque($fileName); - - $this->actor->find(self::fileActionsMenuButtonForFile($this->fileListAncestor, $fileName), 10)->click(); - } -} diff --git a/tests/acceptance/features/bootstrap/FilePickerContext.php b/tests/acceptance/features/bootstrap/FilePickerContext.php deleted file mode 100644 index b9d82090eaa..00000000000 --- a/tests/acceptance/features/bootstrap/FilePickerContext.php +++ /dev/null @@ -1,125 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class FilePickerContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function dialog() { - return Locator::forThe()->css(".oc-dialog")-> - describedAs("File picker dialog"); - } - - /** - * @return Locator - */ - public static function fileListContainer() { - return Locator::forThe()->css("#oc-dialog-filepicker-content")-> - descendantOf(self::dialog())-> - describedAs("File list container in the file picker dialog"); - } - - /** - * @return Locator - */ - public static function rowForFile($fileName) { - // File names in the file picker are split in two span elements, so - // their texts need to be concatenated to get the full file name. - return Locator::forThe()->xpath("//*[@id = 'picker-filestable']//*[contains(concat(' ', normalize-space(@class), ' '), ' filename-parts ') and concat(span[1], span[2]) = '$fileName']/ancestor::tr")-> - descendantOf(self::fileListContainer())-> - describedAs("Row for file $fileName in the file picker dialog"); - } - - /** - * @return Locator - */ - public static function buttonRow() { - return Locator::forThe()->css(".oc-dialog-buttonrow")-> - descendantOf(self::dialog())-> - describedAs("Button row in the file picker dialog"); - } - - /** - * @return Locator - */ - private static function buttonFor($buttonText) { - // "Copy" and "Move" buttons text is set to "Copy to XXX" and "Move to - // XXX" when a folder is selected. - return Locator::forThe()->xpath("//button[starts-with(normalize-space(), '$buttonText')]")-> - descendantOf(self::buttonRow())-> - describedAs($buttonText . " button in the file picker dialog"); - } - - /** - * @return Locator - */ - public static function copyButton() { - return self::buttonFor("Copy"); - } - - /** - * @return Locator - */ - public static function moveButton() { - return self::buttonFor("Move"); - } - - /** - * @return Locator - */ - public static function chooseButton() { - return self::buttonFor("Choose"); - } - - /** - * @When I select :fileName in the file picker - */ - public function iSelectInTheFilePicker($fileName) { - $this->actor->find(self::rowForFile($fileName), 10)->click(); - } - - /** - * @When I copy to the last selected folder in the file picker - */ - public function iCopyToTheLastSelectedFolderInTheFilePicker() { - $this->actor->find(self::copyButton(), 10)->click(); - } - - /** - * @When I move to the last selected folder in the file picker - */ - public function iMoveToTheLastSelectedFolderInTheFilePicker() { - $this->actor->find(self::moveButton(), 10)->click(); - } - - /** - * @When I choose the last selected file in the file picker - */ - public function iChooseTheLastSelectedFileInTheFilePicker() { - $this->actor->find(self::chooseButton(), 10)->click(); - } -} diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php deleted file mode 100644 index 906a57b9e61..00000000000 --- a/tests/acceptance/features/bootstrap/FilesAppContext.php +++ /dev/null @@ -1,415 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class FilesAppContext implements Context, ActorAwareInterface { - use ActorAware; - use FileListAncestorSetter; - - /** - * @return array - */ - public static function sections() { - return [ "All files" => "files", - "Recent" => "recent", - "Favorites" => "favorites", - "Shared with you" => "sharingin", - "Shared with others" => "sharingout", - "Shared by link" => "sharinglinks", - "Tags" => "systemtagsfilter", - "Deleted files" => "trashbin" ]; - } - - /** - * @return Locator - */ - private static function appMenu() { - return Locator::forThe()->id("appmenu")-> - describedAs("App menu in header"); - } - - /** - * @return Locator - */ - public static function filesItemInAppMenu() { - return Locator::forThe()->xpath("/li[@data-id = 'files']")-> - descendantOf(self::appMenu())-> - describedAs("Files item in app menu in header"); - } - - /** - * @return Locator - */ - public static function mainViewForSection($section) { - $sectionId = self::sections()[$section]; - - return Locator::forThe()->id("app-content-$sectionId")-> - describedAs("Main view for section $section in Files app"); - } - - /** - * @return Locator - */ - public static function currentSectionMainView() { - return Locator::forThe()->xpath("//*[starts-with(@id, 'app-content-') and not(contains(concat(' ', normalize-space(@class), ' '), ' hidden '))]")-> - describedAs("Current section main view in Files app"); - } - - /** - * @return Locator - */ - public static function detailsView() { - return Locator::forThe()->xpath("//*[@id=\"app-sidebar\" or contains(@class, 'app-sidebar')]")-> - describedAs("Details view in Files app"); - } - - /** - * @return Locator - */ - public static function closeDetailsViewButton() { - return Locator::forThe()->css(".icon-close")-> - descendantOf(self::detailsView())-> - describedAs("Close details view in Files app"); - } - - /** - * @return Locator - */ - public static function fileNameInDetailsView() { - return Locator::forThe()->css(".app-sidebar-header__title")-> - descendantOf(self::detailsView())-> - describedAs("File name in details view in Files app"); - } - - /** - * @return Locator - */ - public static function favoriteActionInFileDetailsInDetailsView() { - return Locator::forThe()->css(".app-sidebar-header__star")-> - descendantOf(self::fileDetailsInDetailsView())-> - describedAs("Favorite action in file details in details view in Files app"); - } - - /** - * @return Locator - */ - public static function notFavoritedStateIconInFileDetailsInDetailsView() { - return Locator::forThe()->css(".icon-star")-> - descendantOf(self::favoriteActionInFileDetailsInDetailsView())-> - describedAs("Not favorited state icon in file details in details view in Files app"); - } - - /** - * @return Locator - */ - public static function favoritedStateIconInFileDetailsInDetailsView() { - return Locator::forThe()->css(".icon-starred")-> - descendantOf(self::favoriteActionInFileDetailsInDetailsView())-> - describedAs("Favorited state icon in file details in details view in Files app"); - } - - /** - * @return Locator - */ - public static function fileDetailsInDetailsViewWithText($fileDetailsText) { - return Locator::forThe()->xpath("//span[normalize-space() = '$fileDetailsText']")-> - descendantOf(self::fileDetailsInDetailsView())-> - describedAs("File details with text \"$fileDetailsText\" in details view in Files app"); - } - - /** - * @return Locator - */ - private static function fileDetailsInDetailsView() { - return Locator::forThe()->css(".app-sidebar-header__desc")-> - descendantOf(self::detailsView())-> - describedAs("File details in details view in Files app"); - } - - /** - * @return Locator - */ - public static function inputFieldForTagsInDetailsView() { - return Locator::forThe()->css(".systemTagsInfoView")-> - descendantOf(self::detailsView())-> - describedAs("Input field for tags in details view in Files app"); - } - - /** - * @return Locator - */ - public static function itemInInputFieldForTagsInDetailsViewForTag($tag) { - return Locator::forThe()->xpath("//span[normalize-space() = '$tag']")-> - descendantOf(self::inputFieldForTagsInDetailsView())-> - describedAs("Item in input field for tags in details view for tag $tag in Files app"); - } - - /** - * @return Locator - */ - public static function itemInDropdownForTag($tag) { - return Locator::forThe()->xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' select2-result-label ')]//span[normalize-space() = '$tag']/ancestor::li")-> - descendantOf(self::select2Dropdown())-> - describedAs("Item in dropdown for tag $tag in Files app"); - } - - /** - * @return Locator - */ - public static function checkmarkInItemInDropdownForTag($tag) { - return Locator::forThe()->css(".checkmark")-> - descendantOf(self::itemInDropdownForTag($tag))-> - describedAs("Checkmark in item in dropdown for tag $tag in Files app"); - } - - /** - * @return Locator - */ - private static function select2Dropdown() { - return Locator::forThe()->css("#select2-drop")-> - describedAs("Select2 dropdown in Files app"); - } - - /** - * @return Locator - */ - public static function tabHeaderInDetailsViewNamed($tabHeaderName) { - return Locator::forThe()->xpath("//li[normalize-space() = '$tabHeaderName']")-> - descendantOf(self::tabHeadersInDetailsView())-> - describedAs("Tab header named $tabHeaderName in details view in Files app"); - } - - /** - * @return Locator - */ - private static function tabHeadersInDetailsView() { - return Locator::forThe()->css(".app-sidebar-tabs__nav")-> - descendantOf(self::detailsView())-> - describedAs("Tab headers in details view in Files app"); - } - - /** - * @return Locator - */ - public static function tabInDetailsViewNamed($tabName) { - return Locator::forThe()->xpath("//div[contains(concat(' ', normalize-space(@class), ' '), ' app-sidebar-tabs__content ')]/section[@aria-labelledby = '$tabName' and @role = 'tabpanel']")-> - descendantOf(self::detailsView())-> - describedAs("Tab named $tabName in details view in Files app"); - } - - /** - * @return Locator - */ - public static function loadingIconForTabInDetailsViewNamed($tabName) { - return Locator::forThe()->css(".icon-loading")-> - descendantOf(self::tabInDetailsViewNamed($tabName))-> - describedAs("Loading icon for tab named $tabName in details view in Files app"); - } - - /** - * @Given I open the Files app - */ - public function iOpenTheFilesApp() { - $this->actor->find(self::filesItemInAppMenu(), 10)->click(); - } - - /** - * @Given I close the details view - */ - public function iCloseTheDetailsView() { - $this->actor->find(self::closeDetailsViewButton(), 10)->click(); - } - - /** - * @Given I open the input field for tags in the details view - */ - public function iOpenTheInputFieldForTagsInTheDetailsView() { - $this->actor->find(self::fileDetailsInDetailsViewWithText("Tags"), 10)->click(); - } - - /** - * @Given I open the :tabName tab in the details view - */ - public function iOpenTheTabInTheDetailsView($tabName) { - $this->actor->find(self::tabHeaderInDetailsViewNamed($tabName), 10)->click(); - } - - /** - * @When I mark the file as favorite in the details view - */ - public function iMarkTheFileAsFavoriteInTheDetailsView() { - $this->iSeeThatTheFileIsNotMarkedAsFavoriteInTheDetailsView(); - - $this->actor->find(self::favoriteActionInFileDetailsInDetailsView(), 10)->click(); - } - - /** - * @When I unmark the file as favorite in the details view - */ - public function iUnmarkTheFileAsFavoriteInTheDetailsView() { - $this->iSeeThatTheFileIsMarkedAsFavoriteInTheDetailsView(); - - $this->actor->find(self::favoriteActionInFileDetailsInDetailsView(), 10)->click(); - } - - /** - * @When I check the tag :tag in the dropdown for tags in the details view - */ - public function iCheckTheTagInTheDropdownForTagsInTheDetailsView($tag) { - $this->iSeeThatTheTagInTheDropdownForTagsInTheDetailsViewIsNotChecked($tag); - - $this->actor->find(self::itemInDropdownForTag($tag), 10)->click(); - } - - /** - * @When I uncheck the tag :tag in the dropdown for tags in the details view - */ - public function iUncheckTheTagInTheDropdownForTagsInTheDetailsView($tag) { - $this->iSeeThatTheTagInTheDropdownForTagsInTheDetailsViewIsChecked($tag); - - $this->actor->find(self::itemInDropdownForTag($tag), 10)->click(); - } - - /** - * @Then I see that the current page is the Files app - */ - public function iSeeThatTheCurrentPageIsTheFilesApp() { - PHPUnit_Framework_Assert::assertStringStartsWith( - $this->actor->locatePath("/apps/files/"), - $this->actor->getSession()->getCurrentUrl()); - - $this->setFileListAncestorForActor(self::currentSectionMainView(), $this->actor); - } - - /** - * @Then I see that the details view is open - */ - public function iSeeThatTheDetailsViewIsOpen() { - // The sidebar always exists in the DOM, so it has to be explicitly - // waited for it to be visible instead of relying on the implicit wait - // made to find the element. - if (!WaitFor::elementToBeEventuallyShown( - $this->actor, - self::detailsView(), - $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The details view is not open yet after $timeout seconds"); - } - } - - /** - * @Then I see that the details view is closed - */ - public function iSeeThatTheDetailsViewIsClosed() { - if (!WaitFor::elementToBeEventuallyNotShown( - $this->actor, - self::detailsView(), - $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The details view is not closed yet after $timeout seconds"); - } - } - - /** - * @Then I see that the file name shown in the details view is :fileName - */ - public function iSeeThatTheFileNameShownInTheDetailsViewIs($fileName) { - PHPUnit_Framework_Assert::assertEquals( - $this->actor->find(self::fileNameInDetailsView(), 10)->getText(), $fileName); - } - - /** - * @Then I see that the file is marked as favorite in the details view - */ - public function iSeeThatTheFileIsMarkedAsFavoriteInTheDetailsView() { - PHPUnit_Framework_Assert::assertNotNull( - $this->actor->find(self::favoritedStateIconInFileDetailsInDetailsView(), 10)); - } - - /** - * @Then I see that the file is not marked as favorite in the details view - */ - public function iSeeThatTheFileIsNotMarkedAsFavoriteInTheDetailsView() { - PHPUnit_Framework_Assert::assertNotNull( - $this->actor->find(self::notFavoritedStateIconInFileDetailsInDetailsView(), 10)); - } - - /** - * @Then I see that the input field for tags in the details view is shown - */ - public function iSeeThatTheInputFieldForTagsInTheDetailsViewIsShown() { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::inputFieldForTagsInDetailsView(), 10)->isVisible()); - } - - /** - * @Then I see that the input field for tags in the details view contains the tag :tag - */ - public function iSeeThatTheInputFieldForTagsInTheDetailsViewContainsTheTag($tag) { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::itemInInputFieldForTagsInDetailsViewForTag($tag), 10)->isVisible()); - } - - /** - * @Then I see that the input field for tags in the details view does not contain the tag :tag - */ - public function iSeeThatTheInputFieldForTagsInTheDetailsViewDoesNotContainTheTag($tag) { - $this->iSeeThatTheInputFieldForTagsInTheDetailsViewIsShown(); - - try { - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::itemInInputFieldForTagsInDetailsViewForTag($tag))->isVisible()); - } catch (NoSuchElementException $exception) { - } - } - - /** - * @Then I see that the tag :tag in the dropdown for tags in the details view is checked - */ - public function iSeeThatTheTagInTheDropdownForTagsInTheDetailsViewIsChecked($tag) { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::checkmarkInItemInDropdownForTag($tag), 10)->isVisible()); - } - - /** - * @Then I see that the tag :tag in the dropdown for tags in the details view is not checked - */ - public function iSeeThatTheTagInTheDropdownForTagsInTheDetailsViewIsNotChecked($tag) { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::itemInDropdownForTag($tag), 10)->isVisible()); - - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::checkmarkInItemInDropdownForTag($tag))->isVisible()); - } - - /** - * @When I see that the :tabName tab in the details view is eventually loaded - */ - public function iSeeThatTheTabInTheDetailsViewIsEventuallyLoaded($tabName) { - if (!WaitFor::elementToBeEventuallyNotShown( - $this->actor, - self::loadingIconForTabInDetailsViewNamed($tabName), - $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The $tabName tab in the details view has not been loaded after $timeout seconds"); - } - } -} diff --git a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php deleted file mode 100644 index 07ebbba1a36..00000000000 --- a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php +++ /dev/null @@ -1,798 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class FilesAppSharingContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function sharedByLabel() { - return Locator::forThe()->css(".sharing-entry__reshare")-> - descendantOf(FilesAppContext::detailsView())-> - describedAs("Shared by label in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function shareWithInput() { - return Locator::forThe()->css(".sharing-input .multiselect__input")-> - descendantOf(FilesAppContext::detailsView())-> - describedAs("Share with input in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function shareWithInputResults() { - return Locator::forThe()->css(".sharing-input .multiselect__content-wrapper")-> - descendantOf(FilesAppContext::detailsView())-> - describedAs("Share with input results list in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function shareWithInputResult($result) { - return Locator::forThe()->xpath("//li[contains(concat(' ', normalize-space(@class), ' '), ' multiselect__element ')]//span[normalize-space() = '$result']/ancestor::li")-> - descendantOf(self::shareWithInputResults())-> - describedAs("Share with input result from the results list in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function shareeList() { - return Locator::forThe()->css(".sharing-sharee-list")-> - descendantOf(FilesAppContext::detailsView())-> - describedAs("Sharee list in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function sharedWithRow($sharedWithName) { - // "username" class is used for any type of share, not only for shares - // with users. - return Locator::forThe()->xpath("//li[contains(concat(' ', normalize-space(@class), ' '), ' sharing-entry ')]//h5[normalize-space() = '$sharedWithName']/ancestor::li")-> - descendantOf(self::shareeList())-> - describedAs("Shared with $sharedWithName row in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function shareWithMenuTrigger($sharedWithName) { - return Locator::forThe()->css(".sharing-entry__actions .trigger")-> - descendantOf(self::sharedWithRow($sharedWithName))-> - describedAs("Share with $sharedWithName menu trigger in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function shareWithMenuButton($sharedWithName) { - return Locator::forThe()->css(".action-item__menutoggle")-> - descendantOf(self::shareWithMenuTrigger($sharedWithName))-> - describedAs("Share with $sharedWithName menu button in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function shareWithMenu($sharedWithName, $shareWithMenuTriggerElement) { - return Locator::forThe()->xpath("//*[@id = " . $shareWithMenuTriggerElement->getWrappedElement()->getXpath() . "/@aria-describedby]")-> - describedAs("Share with $sharedWithName menu in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function permissionCheckboxFor($sharedWithName, $shareWithMenuTriggerElement, $itemText) { - // forThe()->checkbox($itemText) can not be used here; that would return - // the checkbox itself, but the element that the user interacts with is - // the label. - return Locator::forThe()->xpath("//label[normalize-space() = '$itemText']")-> - descendantOf(self::shareWithMenu($sharedWithName, $shareWithMenuTriggerElement))-> - describedAs("$itemText checkbox in the share with $sharedWithName menu in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function permissionCheckboxInputFor($sharedWithName, $shareWithMenuTriggerElement, $itemText) { - return Locator::forThe()->checkbox($itemText)-> - descendantOf(self::shareWithMenu($sharedWithName, $shareWithMenuTriggerElement))-> - describedAs("$itemText checkbox input in the share with $sharedWithName menu in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function canEditCheckbox($sharedWithName, $shareWithMenuTriggerElement) { - return self::permissionCheckboxFor($sharedWithName, $shareWithMenuTriggerElement, 'Allow editing'); - } - - /** - * @return Locator - */ - public static function canEditCheckboxInput($sharedWithName, $shareWithMenuTriggerElement) { - return self::permissionCheckboxInputFor($sharedWithName, $shareWithMenuTriggerElement, 'Allow editing'); - } - - /** - * @return Locator - */ - public static function canCreateCheckbox($sharedWithName, $shareWithMenuTriggerElement) { - return self::permissionCheckboxFor($sharedWithName, $shareWithMenuTriggerElement, 'Allow creating'); - } - - /** - * @return Locator - */ - public static function canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement) { - return self::permissionCheckboxInputFor($sharedWithName, $shareWithMenuTriggerElement, 'Allow creating'); - } - - /** - * @return Locator - */ - public static function canReshareCheckbox($sharedWithName, $shareWithMenuTriggerElement) { - return self::permissionCheckboxFor($sharedWithName, $shareWithMenuTriggerElement, 'Allow resharing'); - } - - /** - * @return Locator - */ - public static function canReshareCheckboxInput($sharedWithName, $shareWithMenuTriggerElement) { - return self::permissionCheckboxInputFor($sharedWithName, $shareWithMenuTriggerElement, 'Allow resharing'); - } - - /** - * @return Locator - */ - public static function unshareButton($sharedWithName, $shareWithMenuTriggerElement) { - return Locator::forThe()->xpath("//li[contains(concat(' ', normalize-space(@class), ' '), ' action ')]//button[normalize-space() = 'Unshare']")-> - descendantOf(self::shareWithMenu($sharedWithName, $shareWithMenuTriggerElement))-> - describedAs("Unshare button in the share with $sharedWithName menu in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function shareLinkRow() { - return Locator::forThe()->css(".sharing-link-list .sharing-entry__link:first-child")-> - descendantOf(FilesAppContext::detailsView())-> - describedAs("Share link row in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function shareLinkAddNewButton() { - // When there is no link share the "Add new share" item is shown instead - // of the menu button as a direct child of ".share-menu". - return Locator::forThe()->css(".action-item.icon-add")-> - descendantOf(self::shareLinkRow())-> - describedAs("Add new share link button in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function copyLinkButton() { - return Locator::forThe()->css("a.sharing-entry__copy")-> - descendantOf(self::shareLinkRow())-> - describedAs("Copy link button in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function shareLinkMenuTrigger() { - return Locator::forThe()->css(".sharing-entry__actions .trigger")-> - descendantOf(self::shareLinkRow())-> - describedAs("Share link menu trigger in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function shareLinkMenuButton() { - return Locator::forThe()->css(".action-item__menutoggle")-> - descendantOf(self::shareLinkMenuTrigger())-> - describedAs("Share link menu button in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function shareLinkMenu($shareLinkMenuTriggerElement) { - return Locator::forThe()->xpath("//*[@id = " . $shareLinkMenuTriggerElement->getWrappedElement()->getXpath() . "/@aria-describedby]")-> - describedAs("Share link menu in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function hideDownloadCheckbox($shareLinkMenuTriggerElement) { - // forThe()->checkbox("Hide download") can not be used here; that would - // return the checkbox itself, but the element that the user interacts - // with is the label. - return Locator::forThe()->xpath("//label[normalize-space() = 'Hide download']")-> - descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> - describedAs("Hide download checkbox in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function hideDownloadCheckboxInput($shareLinkMenuTriggerElement) { - return Locator::forThe()->checkbox("Hide download")-> - descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> - describedAs("Hide download checkbox input in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function allowUploadAndEditingRadioButton($shareLinkMenuTriggerElement) { - // forThe()->radio("Allow upload and editing") can not be used here; - // that would return the radio button itself, but the element that the - // user interacts with is the label. - return Locator::forThe()->xpath("//label[normalize-space() = 'Allow upload and editing']")-> - descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> - describedAs("Allow upload and editing radio button in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function passwordProtectCheckbox($shareLinkMenuTriggerElement) { - // forThe()->checkbox("Password protect") can not be used here; that - // would return the checkbox itself, but the element that the user - // interacts with is the label. - return Locator::forThe()->xpath("//label[normalize-space() = 'Password protect']")-> - descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> - describedAs("Password protect checkbox in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function passwordProtectCheckboxInput($shareLinkMenuTriggerElement) { - return Locator::forThe()->checkbox("Password protect")-> - descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> - describedAs("Password protect checkbox input in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function passwordProtectField($shareLinkMenuTriggerElement) { - return Locator::forThe()->css(".share-link-password input.action-input__input")->descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> - describedAs("Password protect field in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function disabledPasswordProtectField($shareLinkMenuTriggerElement) { - return Locator::forThe()->css(".share-link-password input.action-input__input[disabled]")->descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> - describedAs("Disabled password protect field in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function passwordProtectByTalkCheckbox($shareLinkMenuTriggerElement) { - // forThe()->checkbox("Password protect by Talk") can not be used here; - // that would return the checkbox itself, but the element that the user - // interacts with is the label. - return Locator::forThe()->xpath("//label[normalize-space() = 'Password protect by Talk']")-> - descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> - describedAs("Password protect by Talk checkbox in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function passwordProtectByTalkCheckboxInput($shareLinkMenuTriggerElement) { - return Locator::forThe()->checkbox("Password protect by Talk")-> - descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> - describedAs("Password protect by Talk checkbox input in the details view in Files app"); - } - - /** - * @return Locator - */ - public static function unshareLinkButton($shareLinkMenuTriggerElement) { - return Locator::forThe()->xpath("//li[contains(concat(' ', normalize-space(@class), ' '), ' action ')]//button[normalize-space() = 'Unshare']")-> - descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> - describedAs("Unshare link button in the details view in Files app"); - } - - /** - * @Given I share the link for :fileName - */ - public function iShareTheLinkFor($fileName) { - $this->actor->find(FileListContext::shareActionForFile(FilesAppContext::currentSectionMainView(), $fileName), 10)->click(); - - $this->actor->find(self::shareLinkAddNewButton(), 5)->click(); - } - - /** - * @Given I share :fileName with :shareWithName - */ - public function iShareWith($fileName, $shareWithName) { - $this->actor->find(FileListContext::shareActionForFile(FilesAppContext::currentSectionMainView(), $fileName), 10)->click(); - - $this->actor->find(self::shareWithInput(), 5)->setValue($shareWithName); - // "setValue()" ends sending a tab, which unfocuses the input and causes - // the results to be hidden, so the input needs to be clicked to show - // the results again. - $this->actor->find(self::shareWithInput())->click(); - $this->actor->find(self::shareWithInputResult($shareWithName), 5)->click(); - } - - /** - * @Given I write down the shared link - */ - public function iWriteDownTheSharedLink() { - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); - - // Close the share link menu if it is open to ensure that it does not - // cover the copy link button. - if (!WaitFor::elementToBeEventuallyNotShown( - $this->actor, - self::shareLinkMenu($shareLinkMenuTriggerElement), - $timeout = 2 * $this->actor->getFindTimeoutMultiplier())) { - // It may not be possible to click on the menu button (due to the - // menu itself covering it), so "Esc" key is pressed instead. - $this->actor->find(self::shareLinkMenu($shareLinkMenuTriggerElement), 2)->getWrappedElement()->keyPress(27); - } - - $this->actor->find(self::copyLinkButton(), 10)->click(); - - // Clicking on the menu item copies the link to the clipboard, but it is - // not possible to access that value from the acceptance tests. Due to - // this the value of the attribute that holds the URL is used instead. - $this->actor->getSharedNotebook()["shared link"] = $this->actor->find(self::copyLinkButton(), 2)->getWrappedElement()->getAttribute("href"); - } - - /** - * @When I set the download of the shared link as hidden - */ - public function iSetTheDownloadOfTheSharedLinkAsHidden() { - $this->showShareLinkMenuIfNeeded(); - - $this->iSeeThatTheDownloadOfTheLinkShareIsShown(); - - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); - $this->actor->find(self::hideDownloadCheckbox($shareLinkMenuTriggerElement), 2)->click(); - } - - /** - * @When I set the download of the shared link as shown - */ - public function iSetTheDownloadOfTheSharedLinkAsShown() { - $this->showShareLinkMenuIfNeeded(); - - $this->iSeeThatTheDownloadOfTheLinkShareIsHidden(); - - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); - $this->actor->find(self::hideDownloadCheckbox($shareLinkMenuTriggerElement), 2)->click(); - } - - /** - * @When I set the shared link as editable - */ - public function iSetTheSharedLinkAsEditable() { - $this->showShareLinkMenuIfNeeded(); - - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); - $this->actor->find(self::allowUploadAndEditingRadioButton($shareLinkMenuTriggerElement), 2)->click(); - } - - /** - * @When I protect the shared link with the password :password - */ - public function iProtectTheSharedLinkWithThePassword($password) { - $this->showShareLinkMenuIfNeeded(); - - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); - $this->actor->find(self::passwordProtectCheckbox($shareLinkMenuTriggerElement), 2)->click(); - - $this->actor->find(self::passwordProtectField($shareLinkMenuTriggerElement), 2)->setValue($password . "\r"); - } - - /** - * @When I set the password of the shared link as protected by Talk - */ - public function iSetThePasswordOfTheSharedLinkAsProtectedByTalk() { - $this->showShareLinkMenuIfNeeded(); - - $this->iSeeThatThePasswordOfTheLinkShareIsNotProtectedByTalk(); - - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); - $this->actor->find(self::passwordProtectByTalkCheckbox($shareLinkMenuTriggerElement), 2)->click(); - } - - /** - * @When I set the password of the shared link as not protected by Talk - */ - public function iSetThePasswordOfTheSharedLinkAsNotProtectedByTalk() { - $this->showShareLinkMenuIfNeeded(); - - $this->iSeeThatThePasswordOfTheLinkShareIsProtectedByTalk(); - - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); - $this->actor->find(self::passwordProtectByTalkCheckbox($shareLinkMenuTriggerElement), 2)->click(); - } - - /** - * @When I set the share with :shareWithName as not editable - */ - public function iSetTheShareWithAsNotEditable($shareWithName) { - $this->showShareWithMenuIfNeeded($shareWithName); - - $this->iSeeThatCanEditTheShare($shareWithName); - - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($shareWithName), 2); - $this->actor->find(self::canEditCheckbox($shareWithName, $shareWithMenuTriggerElement), 2)->click(); - } - - /** - * @When I set the share with :shareWithName as not creatable - */ - public function iSetTheShareWithAsNotCreatable($shareWithName) { - $this->showShareWithMenuIfNeeded($shareWithName); - - $this->iSeeThatCanCreateInTheShare($shareWithName); - - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($shareWithName), 2); - $this->actor->find(self::canCreateCheckbox($shareWithName, $shareWithMenuTriggerElement), 2)->click(); - } - - /** - * @When I set the share with :shareWithName as not reshareable - */ - public function iSetTheShareWithAsNotReshareable($shareWithName) { - $this->showShareWithMenuIfNeeded($shareWithName); - - $this->iSeeThatCanReshareTheShare($shareWithName); - - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($shareWithName), 2); - $this->actor->find(self::canReshareCheckbox($shareWithName, $shareWithMenuTriggerElement), 2)->click(); - } - - /** - * @When I unshare the share with :shareWithName - */ - public function iUnshareTheFileWith($shareWithName) { - $this->showShareWithMenuIfNeeded($shareWithName); - - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($shareWithName), 2); - $this->actor->find(self::unshareButton($shareWithName, $shareWithMenuTriggerElement), 2)->click(); - } - - /** - * @When I unshare the link share - */ - public function iUnshareTheLink() { - $this->showShareLinkMenuIfNeeded(); - - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); - $this->actor->find(self::unshareLinkButton($shareLinkMenuTriggerElement), 2)->click(); - } - - /** - * @Then I see that the file is shared with me by :sharedByName - */ - public function iSeeThatTheFileIsSharedWithMeBy($sharedByName) { - PHPUnit_Framework_Assert::assertEquals( - $this->actor->find(self::sharedByLabel(), 10)->getText(), "Shared with you by $sharedByName"); - } - - /** - * @Then I see that the file is shared with :sharedWithName - */ - public function iSeeThatTheFileIsSharedWith($sharedWithName) { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::sharedWithRow($sharedWithName), 10)->isVisible()); - } - - /** - * @Then I see that the file is not shared with :sharedWithName - */ - public function iSeeThatTheFileIsNotSharedWith($sharedWithName) { - if (!WaitFor::elementToBeEventuallyNotShown( - $this->actor, - self::sharedWithRow($sharedWithName), - $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The shared with $sharedWithName row is still shown after $timeout seconds"); - } - } - - /** - * @Then I see that resharing the file is not allowed - */ - public function iSeeThatResharingTheFileIsNotAllowed() { - PHPUnit_Framework_Assert::assertEquals( - $this->actor->find(self::shareWithInput(), 10)->getWrappedElement()->getAttribute("disabled"), "disabled"); - PHPUnit_Framework_Assert::assertEquals( - $this->actor->find(self::shareWithInput(), 10)->getWrappedElement()->getAttribute("placeholder"), "Resharing is not allowed"); - } - - /** - * @Then I see that resharing the file by link is not available - */ - public function iSeeThatResharingTheFileByLinkIsNotAvailable() { - if (!WaitFor::elementToBeEventuallyNotShown( - $this->actor, - self::shareLinkAddNewButton(), - $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The add new share link button is still shown after $timeout seconds"); - } - } - - /** - * @Then I see that :sharedWithName can not be allowed to edit the share - */ - public function iSeeThatCanNotBeAllowedToEditTheShare($sharedWithName) { - $this->showShareWithMenuIfNeeded($sharedWithName); - - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertEquals( - $this->actor->find(self::canEditCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->getWrappedElement()->getAttribute("disabled"), "disabled"); - } - - /** - * @Then I see that :sharedWithName can edit the share - */ - public function iSeeThatCanEditTheShare($sharedWithName) { - $this->showShareWithMenuIfNeeded($sharedWithName); - - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::canEditCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); - } - - /** - * @Then I see that :sharedWithName can not edit the share - */ - public function iSeeThatCanNotEditTheShare($sharedWithName) { - $this->showShareWithMenuIfNeeded($sharedWithName); - - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::canEditCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); - } - - /** - * @Then I see that :sharedWithName can not be allowed to create in the share - */ - public function iSeeThatCanNotBeAllowedToCreateInTheShare($sharedWithName) { - $this->showShareWithMenuIfNeeded($sharedWithName); - - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertEquals( - $this->actor->find(self::canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->getWrappedElement()->getAttribute("disabled"), "disabled"); - } - - /** - * @Then I see that :sharedWithName can create in the share - */ - public function iSeeThatCanCreateInTheShare($sharedWithName) { - $this->showShareWithMenuIfNeeded($sharedWithName); - - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); - } - - /** - * @Then I see that :sharedWithName can not create in the share - */ - public function iSeeThatCanNotCreateInTheShare($sharedWithName) { - $this->showShareWithMenuIfNeeded($sharedWithName); - - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); - } - - /** - * @Then I see that resharing for :sharedWithName is not available - */ - public function iSeeThatResharingForIsNotAvailable($sharedWithName) { - $this->showShareWithMenuIfNeeded($sharedWithName); - - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - if (!WaitFor::elementToBeEventuallyNotShown( - $this->actor, - self::canReshareCheckbox($sharedWithName, $shareWithMenuTriggerElement), - $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The resharing checkbox for $sharedWithName is still shown after $timeout seconds"); - } - } - - /** - * @Then I see that :sharedWithName can reshare the share - */ - public function iSeeThatCanReshareTheShare($sharedWithName) { - $this->showShareWithMenuIfNeeded($sharedWithName); - - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::canReshareCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); - } - - /** - * @Then I see that :sharedWithName can not reshare the share - */ - public function iSeeThatCanNotReshareTheShare($sharedWithName) { - $this->showShareWithMenuIfNeeded($sharedWithName); - - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::canReshareCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); - } - - /** - * @Then I see that the download of the link share is hidden - */ - public function iSeeThatTheDownloadOfTheLinkShareIsHidden() { - $this->showShareLinkMenuIfNeeded(); - - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::hideDownloadCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); - } - - /** - * @Then I see that the download of the link share is shown - */ - public function iSeeThatTheDownloadOfTheLinkShareIsShown() { - $this->showShareLinkMenuIfNeeded(); - - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); - PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::hideDownloadCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); - } - - /** - * @Then I see that the password protect is disabled while loading - */ - public function iSeeThatThePasswordProtectIsDisabledWhileLoading() { - // Due to the additional time needed to find the menu trigger element it - // could happen that the request to modify the password protect was - // completed and the field enabled again even before finding the - // disabled field started. Therefore, if the disabled field could not be - // found it is just assumed that it was already enabled again. - // Nevertheless, this check should be done anyway to ensure that the - // following scenario steps are not executed before the request to the - // server was done. - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); - - try { - $this->actor->find(self::disabledPasswordProtectField($shareLinkMenuTriggerElement), 5); - } catch (NoSuchElementException $exception) { - echo "The password protect field was not found disabled after " . (5 * $this->actor->getFindTimeoutMultiplier()) . " seconds, assumming that it was disabled and enabled again before the check started and continuing"; - - return; - } - - if (!WaitFor::elementToBeEventuallyNotShown( - $this->actor, - self::disabledPasswordProtectField($shareLinkMenuTriggerElement), - $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The password protect field is still disabled after $timeout seconds"); - } - } - - /** - * @Then I see that the link share is password protected - */ - public function iSeeThatTheLinkShareIsPasswordProtected() { - $this->showShareLinkMenuIfNeeded(); - - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked(), "Password protect checkbox is checked"); - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectField($shareLinkMenuTriggerElement), 10)->isVisible(), "Password protect field is visible"); - } - - /** - * @Then I see that the password of the link share is protected by Talk - */ - public function iSeeThatThePasswordOfTheLinkShareIsProtectedByTalk() { - $this->showShareLinkMenuIfNeeded(); - - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectByTalkCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); - } - - /** - * @Then I see that the password of the link share is not protected by Talk - */ - public function iSeeThatThePasswordOfTheLinkShareIsNotProtectedByTalk() { - $this->showShareLinkMenuIfNeeded(); - - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); - PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::passwordProtectByTalkCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); - } - - /** - * @Then I see that the checkbox to protect the password of the link share by Talk is not shown - */ - public function iSeeThatTheCheckboxToProtectThePasswordOfTheLinkShareByTalkIsNotShown() { - $this->showShareLinkMenuIfNeeded(); - - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); - try { - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::passwordProtectByTalkCheckbox($shareLinkMenuTriggerElement))->isVisible()); - } catch (NoSuchElementException $exception) { - } - } - - /** - * @Given I share the link for :fileName protected by the password :password - */ - public function iShareTheLinkForProtectedByThePassword($fileName, $password) { - $this->iShareTheLinkFor($fileName); - $this->iProtectTheSharedLinkWithThePassword($password); - $this->iSeeThatThePasswordProtectIsDisabledWhileLoading(); - } - - private function showShareLinkMenuIfNeeded() { - $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); - - // In some cases the share menu is hidden after clicking on an action of - // the menu. Therefore, if the menu is visible, wait a little just in - // case it is in the process of being hidden due to a previous action, - // in which case it is shown again. - if (WaitFor::elementToBeEventuallyNotShown( - $this->actor, - self::shareLinkMenu($shareLinkMenuTriggerElement), - $timeout = 2 * $this->actor->getFindTimeoutMultiplier())) { - $this->actor->find(self::shareLinkMenuButton(), 10)->click(); - } - } - - private function showShareWithMenuIfNeeded($shareWithName) { - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($shareWithName), 2); - - // In some cases the share menu is hidden after clicking on an action of - // the menu. Therefore, if the menu is visible, wait a little just in - // case it is in the process of being hidden due to a previous action, - // in which case it is shown again. - if (WaitFor::elementToBeEventuallyNotShown( - $this->actor, - self::shareWithMenu($shareWithName, $shareWithMenuTriggerElement), - $timeout = 2 * $this->actor->getFindTimeoutMultiplier())) { - $this->actor->find(self::shareWithMenuButton($shareWithName), 10)->click(); - } - } -} diff --git a/tests/acceptance/features/bootstrap/LoginPageContext.php b/tests/acceptance/features/bootstrap/LoginPageContext.php deleted file mode 100644 index bf44d31fb03..00000000000 --- a/tests/acceptance/features/bootstrap/LoginPageContext.php +++ /dev/null @@ -1,160 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; -use Behat\Behat\Hook\Scope\BeforeScenarioScope; - -class LoginPageContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @var FeatureContext - */ - private $featureContext; - - /** - * @var FilesAppContext - */ - private $filesAppContext; - - /** - * @return Locator - */ - public static function userNameField() { - return Locator::forThe()->field("user")-> - describedAs("User name field in Login page"); - } - - /** - * @return Locator - */ - public static function passwordField() { - return Locator::forThe()->field("password")-> - describedAs("Password field in Login page"); - } - - /** - * @return Locator - */ - public static function loginButton() { - return Locator::forThe()->id("submit-form")-> - describedAs("Login button in Login page"); - } - - /** - * @return Locator - */ - public static function wrongPasswordMessage() { - return Locator::forThe()->xpath("//*[@class = 'warning wrongPasswordMsg' and normalize-space() = 'Wrong username or password.']")-> - describedAs("Wrong password message in Login page"); - } - - /** - * @return Locator - */ - public static function userDisabledMessage() { - return Locator::forThe()->xpath("//*[@class = 'warning userDisabledMsg' and normalize-space() = 'User disabled']")-> - describedAs('User disabled message on login page'); - } - - /** - * @When I log in with user :user and password :password - */ - public function iLogInWithUserAndPassword($user, $password) { - $this->actor->find(self::userNameField(), 10)->setValue($user); - $this->actor->find(self::passwordField())->setValue($password); - $this->actor->find(self::loginButton())->click(); - } - - /** - * @Then I see that the current page is the Login page - */ - public function iSeeThatTheCurrentPageIsTheLoginPage() { - PHPUnit_Framework_Assert::assertStringStartsWith( - $this->actor->locatePath("/login"), - $this->actor->getSession()->getCurrentUrl()); - } - - /** - * @Then I see that a wrong password message is shown - */ - public function iSeeThatAWrongPasswordMessageIsShown() { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::wrongPasswordMessage(), 10)->isVisible()); - } - - /** - * @Then I see that the disabled user message is shown - */ - public function iSeeThatTheDisabledUserMessageIsShown() { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::userDisabledMessage(), 10)->isVisible()); - } - - /** - * @BeforeScenario - */ - public function getOtherRequiredSiblingContexts(BeforeScenarioScope $scope) { - $environment = $scope->getEnvironment(); - - $this->featureContext = $environment->getContext("FeatureContext"); - $this->filesAppContext = $environment->getContext("FilesAppContext"); - } - - /** - * @Given I am logged in - */ - public function iAmLoggedIn() { - $this->featureContext->iVisitTheHomePage(); - $this->iLogInWithUserAndPassword("user0", "123456acb"); - $this->filesAppContext->iSeeThatTheCurrentPageIsTheFilesApp(); - } - - /** - * @Given I am logged in as :userName - */ - public function iAmLoggedInAs($userName) { - $this->featureContext->iVisitTheHomePage(); - $this->iLogInWithUserAndPassword($userName, "123456acb"); - $this->filesAppContext->iSeeThatTheCurrentPageIsTheFilesApp(); - } - - /** - * @Given I am logged in as the admin - */ - public function iAmLoggedInAsTheAdmin() { - $this->featureContext->iVisitTheHomePage(); - $this->iLogInWithUserAndPassword("admin", "admin"); - $this->filesAppContext->iSeeThatTheCurrentPageIsTheFilesApp(); - } - - /** - * @Given I can not log in with user :user and password :password - */ - public function iCanNotLogInWithUserAndPassword($user, $password) { - $this->featureContext->iVisitTheHomePage(); - $this->iLogInWithUserAndPassword($user, $password); - $this->iSeeThatTheCurrentPageIsTheLoginPage(); - $this->iSeeThatAWrongPasswordMessageIsShown(); - } -} diff --git a/tests/acceptance/features/bootstrap/NotificationsContext.php b/tests/acceptance/features/bootstrap/NotificationsContext.php deleted file mode 100644 index 15ad6ee90c8..00000000000 --- a/tests/acceptance/features/bootstrap/NotificationsContext.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2019, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class NotificationsContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function notificationsButton() { - return Locator::forThe()->css("#header .notifications .notifications-button")-> - describedAs("Notifications button in the header"); - } - - /** - * @return Locator - */ - public static function notificationsContainer() { - return Locator::forThe()->css("#header .notifications .notification-container")-> - describedAs("Notifications container"); - } - - /** - * @return Locator - */ - public static function incomingShareNotificationForFile($fileName) { - return Locator::forThe()->xpath("//div[contains(concat(' ', normalize-space(@class), ' '), ' notification ') and //div[starts-with(normalize-space(), 'You received $fileName as a share by')]]")-> - descendantOf(self::notificationsContainer())-> - describedAs("Notification of incoming share for file $fileName"); - } - - /** - * @return Locator - */ - public static function actionsInIncomingShareNotificationForFile($fileName) { - return Locator::forThe()->css(".notification-actions")-> - descendantOf(self::incomingShareNotificationForFile($fileName))-> - describedAs("Actions in notification of incoming share for file $fileName"); - } - - /** - * @return Locator - */ - public static function actionInIncomingShareNotificationForFile($fileName, $action) { - return Locator::forThe()->xpath("//button[normalize-space() = '$action']")-> - descendantOf(self::actionsInIncomingShareNotificationForFile($fileName))-> - describedAs("$action button in notification of incoming share for file $fileName"); - } - - /** - * @return Locator - */ - public static function acceptButtonInIncomingShareNotificationForFile($fileName) { - return self::actionInIncomingShareNotificationForFile($fileName, 'Accept'); - } - - /** - * @Given I accept the share for :fileName in the notifications - */ - public function iAcceptTheShareForInTheNotifications($fileName) { - $this->actor->find(self::notificationsButton(), 10)->click(); - - // Notifications are refreshed every 30 seconds, so wait a bit longer. - // As the waiting is long enough already the find timeout multiplier is - // capped at 2 when finding notifications. - $findTimeoutMultiplier = $this->actor->getFindTimeoutMultiplier(); - $this->actor->setFindTimeoutMultiplier(min(2, $findTimeoutMultiplier)); - $this->actor->find(self::acceptButtonInIncomingShareNotificationForFile($fileName), 35)->click(); - $this->actor->setFindTimeoutMultiplier($findTimeoutMultiplier); - - // Hide the notifications again - $this->actor->find(self::notificationsButton(), 10)->click(); - } -} diff --git a/tests/acceptance/features/bootstrap/PublicShareContext.php b/tests/acceptance/features/bootstrap/PublicShareContext.php deleted file mode 100644 index 2213cf877f9..00000000000 --- a/tests/acceptance/features/bootstrap/PublicShareContext.php +++ /dev/null @@ -1,252 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class PublicShareContext implements Context, ActorAwareInterface { - use ActorAware; - use FileListAncestorSetter; - - /** - * @return Locator - */ - public static function passwordField() { - return Locator::forThe()->field("password")-> - describedAs("Password field in Authenticate page"); - } - - /** - * @return Locator - */ - public static function authenticateButton() { - return Locator::forThe()->id("password-submit")-> - describedAs("Authenticate button in Authenticate page"); - } - - /** - * @return Locator - */ - public static function wrongPasswordMessage() { - return Locator::forThe()->xpath("//*[@class = 'warning' and normalize-space() = 'The password is wrong. Try again.']")-> - describedAs("Wrong password message in Authenticate page"); - } - - /** - * @return Locator - */ - public static function shareMenuButton() { - return Locator::forThe()->id("header-actions-toggle")-> - describedAs("Share menu button in Shared file page"); - } - - /** - * @return Locator - */ - public static function shareMenu() { - return Locator::forThe()->id("header-actions-menu")-> - describedAs("Share menu in Shared file page"); - } - - /** - * @return Locator - */ - public static function downloadItemInShareMenu() { - return Locator::forThe()->id("download")-> - descendantOf(self::shareMenu())-> - describedAs("Download item in Share menu in Shared file page"); - } - - /** - * @return Locator - */ - public static function directLinkItemInShareMenu() { - return Locator::forThe()->id("directLink-container")-> - descendantOf(self::shareMenu())-> - describedAs("Direct link item in Share menu in Shared file page"); - } - - /** - * @return Locator - */ - public static function saveItemInShareMenu() { - return Locator::forThe()->id("save-external-share")-> - descendantOf(self::shareMenu())-> - describedAs("Save item in Share menu in Shared file page"); - } - - /** - * @return Locator - */ - public static function textPreview() { - return Locator::forThe()->css(".text-preview")-> - describedAs("Text preview in Shared file page"); - } - - /** - * @return Locator - */ - public static function downloadButton() { - return Locator::forThe()->id("downloadFile")-> - describedAs("Download button in Shared file page"); - } - - /** - * @When I visit the shared link I wrote down - */ - public function iVisitTheSharedLinkIWroteDown() { - $this->actor->getSession()->visit($this->actor->getSharedNotebook()["shared link"]); - } - - /** - * @When I visit the direct download shared link I wrote down - */ - public function iVisitTheDirectDownloadSharedLinkIWroteDown() { - $this->actor->getSession()->visit($this->actor->getSharedNotebook()["shared link"] . "/download"); - } - - /** - * @When I authenticate with password :password - */ - public function iAuthenticateWithPassword($password) { - $this->actor->find(self::passwordField(), 10)->setValue($password); - $this->actor->find(self::authenticateButton())->click(); - } - - /** - * @When I open the Share menu - */ - public function iOpenTheShareMenu() { - $this->actor->find(self::shareMenuButton(), 10)->click(); - } - - /** - * @Then I see that the current page is the Authenticate page for the shared link I wrote down - */ - public function iSeeThatTheCurrentPageIsTheAuthenticatePageForTheSharedLinkIWroteDown() { - PHPUnit_Framework_Assert::assertEquals( - $this->actor->getSharedNotebook()["shared link"] . "/authenticate/showShare", - $this->actor->getSession()->getCurrentUrl()); - } - - /** - * @Then I see that the current page is the Authenticate page for the direct download shared link I wrote down - */ - public function iSeeThatTheCurrentPageIsTheAuthenticatePageForTheDirectDownloadSharedLinkIWroteDown() { - PHPUnit_Framework_Assert::assertEquals( - $this->actor->getSharedNotebook()["shared link"] . "/authenticate/downloadShare", - $this->actor->getSession()->getCurrentUrl()); - } - - /** - * @Then I see that the current page is the shared link I wrote down - */ - public function iSeeThatTheCurrentPageIsTheSharedLinkIWroteDown() { - PHPUnit_Framework_Assert::assertEquals( - $this->actor->getSharedNotebook()["shared link"], - $this->actor->getSession()->getCurrentUrl()); - - $this->setFileListAncestorForActor(null, $this->actor); - } - - /** - * @Then I see that the current page is the direct download shared link I wrote down - */ - public function iSeeThatTheCurrentPageIsTheDirectDownloadSharedLinkIWroteDown() { - PHPUnit_Framework_Assert::assertEquals( - $this->actor->getSharedNotebook()["shared link"] . "/download", - $this->actor->getSession()->getCurrentUrl()); - } - - /** - * @Then I see that a wrong password for the shared file message is shown - */ - public function iSeeThatAWrongPasswordForTheSharedFileMessageIsShown() { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::wrongPasswordMessage(), 10)->isVisible()); - } - - /** - * @Then I see that the Share menu is shown - */ - public function iSeeThatTheShareMenuIsShown() { - // Unlike other menus, the Share menu is always present in the DOM, so - // the element could be found when it was no made visible yet due to the - // command not having been processed by the browser. - if (!WaitFor::elementToBeEventuallyShown( - $this->actor, self::shareMenu(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The Share menu is not visible yet after $timeout seconds"); - } - - // The acceptance tests are run in a window wider than the mobile breakpoint, so the - // download item should not be shown in the menu (although it will be in - // the DOM). - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::downloadItemInShareMenu())->isVisible(), - "Download item in share menu is visible"); - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::directLinkItemInShareMenu())->isVisible(), - "Direct link item in share menu is not visible"); - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::saveItemInShareMenu())->isVisible(), - "Save item in share menu is not visible"); - } - - /** - * @Then I see that the Share menu button is not shown - */ - public function iSeeThatTheShareMenuButtonIsNotShown() { - try { - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::shareMenuButton())->isVisible()); - } catch (NoSuchElementException $exception) { - } - } - - /** - * @Then I see that the shared file preview shows the text :text - */ - public function iSeeThatTheSharedFilePreviewShowsTheText($text) { - PHPUnit_Framework_Assert::assertContains($text, $this->actor->find(self::textPreview(), 10)->getText()); - } - - /** - * @Then I see that the download button is shown - */ - public function iSeeThatTheDownloadButtonIsShown() { - if (!WaitFor::elementToBeEventuallyShown( - $this->actor, self::downloadButton(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The download button is not visible yet after $timeout seconds"); - } - } - - /** - * @Then I see that the download button is not shown - */ - public function iSeeThatTheDownloadButtonIsNotShown() { - try { - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::downloadButton())->isVisible()); - } catch (NoSuchElementException $exception) { - } - } -} diff --git a/tests/acceptance/features/bootstrap/SearchContext.php b/tests/acceptance/features/bootstrap/SearchContext.php deleted file mode 100644 index bd4ba2beaef..00000000000 --- a/tests/acceptance/features/bootstrap/SearchContext.php +++ /dev/null @@ -1,113 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class SearchContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function searchBoxInput() { - return Locator::forThe()->css("#header .searchbox input")-> - describedAs("Search box input in the header"); - } - - /** - * @return Locator - */ - public static function searchResults() { - return Locator::forThe()->css("#searchresults")-> - describedAs("Search results"); - } - - /** - * @return Locator - */ - public static function searchResult($number) { - return Locator::forThe()->xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' result ')][$number]")-> - descendantOf(self::searchResults())-> - describedAs("Search result $number"); - } - - /** - * @return Locator - */ - public static function searchResultName($number) { - return Locator::forThe()->css(".name")-> - descendantOf(self::searchResult($number))-> - describedAs("Name for search result $number"); - } - - /** - * @return Locator - */ - public static function searchResultPath($number) { - // Currently search results for comments misuse the ".path" class to - // dim the user name, so "div.path" needs to be used to find the proper - // path element. - return Locator::forThe()->css("div.path")-> - descendantOf(self::searchResult($number))-> - describedAs("Path for search result $number"); - } - - /** - * @return Locator - */ - public static function searchResultLink($number) { - return Locator::forThe()->css(".link")-> - descendantOf(self::searchResult($number))-> - describedAs("Link for search result $number"); - } - - /** - * @When I search for :query - */ - public function iSearchFor($query) { - $this->actor->find(self::searchBoxInput(), 10)->setValue($query . "\r"); - } - - /** - * @When I open the search result :number - */ - public function iOpenTheSearchResult($number) { - $this->actor->find(self::searchResultLink($number), 10)->click(); - } - - /** - * @Then I see that the search result :number is :name - */ - public function iSeeThatTheSearchResultIs($number, $name) { - PHPUnit_Framework_Assert::assertEquals( - $name, $this->actor->find(self::searchResultName($number), 10)->getText()); - } - - /** - * @Then I see that the search result :number was found in :path - */ - public function iSeeThatTheSearchResultWasFoundIn($number, $path) { - PHPUnit_Framework_Assert::assertEquals( - $path, $this->actor->find(self::searchResultPath($number), 10)->getText()); - } -} diff --git a/tests/acceptance/features/bootstrap/SettingsContext.php b/tests/acceptance/features/bootstrap/SettingsContext.php deleted file mode 100644 index 2a3aeff2f2e..00000000000 --- a/tests/acceptance/features/bootstrap/SettingsContext.php +++ /dev/null @@ -1,282 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class SettingsContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function acceptSharesByDefaultCheckbox() { - // forThe()->checkbox("Accept user...") can not be used here; that would - // return the checkbox itself, but the element that the user interacts - // with is the label. - return Locator::forThe()->xpath("//label[normalize-space() = 'Accept user and group shares by default']")-> - describedAs("Accept shares by default checkbox in Sharing section in Personal Sharing Settings"); - } - - /** - * @return Locator - */ - public static function acceptSharesByDefaultCheckboxInput() { - return Locator::forThe()->checkbox("Accept user and group shares by default")-> - describedAs("Accept shares by default checkbox input in Sharing section in Personal Sharing Settings"); - } - - /** - * @return Locator - */ - public static function allowResharingCheckbox() { - // forThe()->checkbox("Allow resharing") can not be used here; that - // would return the checkbox itself, but the element that the user - // interacts with is the label. - return Locator::forThe()->xpath("//label[normalize-space() = 'Allow resharing']")-> - describedAs("Allow resharing checkbox in Sharing section in Administration Sharing Settings"); - } - - /** - * @return Locator - */ - public static function allowResharingCheckboxInput() { - return Locator::forThe()->checkbox("Allow resharing")-> - describedAs("Allow resharing checkbox input in Sharing section in Administration Sharing Settings"); - } - - /** - * @return Locator - */ - public static function restrictUsernameAutocompletionToGroupsCheckbox() { - // forThe()->checkbox("Restrict username...") can not be used here; that - // would return the checkbox itself, but the element that the user - // interacts with is the label. - return Locator::forThe()->xpath("//label[normalize-space() = 'Restrict username autocompletion to users within the same groups']")-> - describedAs("Restrict username autocompletion to groups checkbox in Sharing section in Administration Sharing Settings"); - } - - /** - * @return Locator - */ - public static function restrictUsernameAutocompletionToGroupsCheckboxInput() { - return Locator::forThe()->checkbox("Restrict username autocompletion to users within the same groups")-> - describedAs("Restrict username autocompletion to groups checkbox input in Sharing section in Administration Sharing Settings"); - } - - /** - * @return Locator - */ - public static function systemTagsSelectTagButton() { - return Locator::forThe()->id("s2id_systemtag")-> - describedAs("Select tag button in system tags section in Administration Settings"); - } - - /** - * @return Locator - */ - public static function systemTagsItemInDropdownForTag($tag) { - return Locator::forThe()->xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' select2-result-label ')]//span[normalize-space() = '$tag']/ancestor::li")-> - descendantOf(self::select2Dropdown())-> - describedAs("Item in dropdown for tag $tag in system tags section in Administration Settings"); - } - - /** - * @return Locator - */ - private static function select2Dropdown() { - return Locator::forThe()->css("#select2-drop")-> - describedAs("Select2 dropdown in Settings"); - } - - /** - * @return Locator - */ - private static function select2DropdownMask() { - return Locator::forThe()->css("#select2-drop-mask")-> - describedAs("Select2 dropdown mask in Settings"); - } - - /** - * @return Locator - */ - public static function systemTagsTagNameInput() { - return Locator::forThe()->id("systemtag_name")-> - describedAs("Tag name input in system tags section in Administration Settings"); - } - - /** - * @return Locator - */ - public static function systemTagsCreateOrUpdateButton() { - return Locator::forThe()->id("systemtag_submit")-> - describedAs("Create/Update button in system tags section in Administration Settings"); - } - - /** - * @return Locator - */ - public static function systemTagsResetButton() { - return Locator::forThe()->id("systemtag_reset")-> - describedAs("Reset button in system tags section in Administration Settings"); - } - - /** - * @When I disable accepting the shares by default - */ - public function iDisableAcceptingTheSharesByDefault() { - $this->iSeeThatSharesAreAcceptedByDefault(); - - $this->actor->find(self::acceptSharesByDefaultCheckbox(), 2)->click(); - } - - /** - * @When I disable resharing - */ - public function iDisableResharing() { - $this->iSeeThatResharingIsEnabled(); - - $this->actor->find(self::allowResharingCheckbox(), 2)->click(); - } - - /** - * @When I enable restricting username autocompletion to groups - */ - public function iEnableRestrictingUsernameAutocompletionToGroups() { - $this->iSeeThatUsernameAutocompletionIsNotRestrictedToGroups(); - - $this->actor->find(self::restrictUsernameAutocompletionToGroupsCheckbox(), 2)->click(); - } - - /** - * @When I create the tag :tag in the settings - */ - public function iCreateTheTagInTheSettings($tag) { - $this->actor->find(self::systemTagsResetButton(), 10)->click(); - $this->actor->find(self::systemTagsTagNameInput())->setValue($tag); - $this->actor->find(self::systemTagsCreateOrUpdateButton())->click(); - } - - /** - * @Then I see that shares are accepted by default - */ - public function iSeeThatSharesAreAcceptedByDefault() { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::acceptSharesByDefaultCheckboxInput(), 10)->isChecked()); - } - - /** - * @Then I see that resharing is enabled - */ - public function iSeeThatResharingIsEnabled() { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::allowResharingCheckboxInput(), 10)->isChecked()); - } - - /** - * @Then I see that resharing is disabled - */ - public function iSeeThatResharingIsDisabled() { - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::allowResharingCheckboxInput(), 10)->isChecked()); - } - - /** - * @Then I see that username autocompletion is restricted to groups - */ - public function iSeeThatUsernameAutocompletionIsRestrictedToGroups() { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::restrictUsernameAutocompletionToGroupsCheckboxInput(), 10)->isChecked()); - } - - /** - * @Then I see that username autocompletion is not restricted to groups - */ - public function iSeeThatUsernameAutocompletionIsNotRestrictedToGroups() { - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::restrictUsernameAutocompletionToGroupsCheckboxInput(), 10)->isChecked()); - } - - /** - * @Then I see that shares are not accepted by default - */ - public function iSeeThatSharesAreNotAcceptedByDefault() { - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::acceptSharesByDefaultCheckboxInput(), 10)->isChecked()); - } - - /** - * @Then I see that the button to select tags is shown - */ - public function iSeeThatTheButtonToSelectTagsIsShown() { - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::systemTagsSelectTagButton(), 10)->isVisible()); - } - - /** - * @Then I see that the dropdown for tags in the settings eventually contains the tag :tag - */ - public function iSeeThatTheDropdownForTagsInTheSettingsEventuallyContainsTheTag($tag) { - // When the dropdown is opened it is not automatically updated if new - // tags are added to the server, and when a tag is created, no explicit - // feedback is provided to the user about the completion of that - // operation (that is, when the tag is added to the server). Therefore, - // to verify that creating a tag does in fact add it to the server it is - // necessary to repeatedly open the dropdown until the tag is shown in - // the dropdown (or the limit of tries is reached). - - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::systemTagsSelectTagButton(), 10)->isVisible()); - - $actor = $this->actor; - - $tagFoundInDropdownCallback = function () use ($actor, $tag) { - // Open the dropdown to look for the tag. - $actor->find(self::systemTagsSelectTagButton())->click(); - - // When the dropdown is opened it is initially empty, and its - // contents are updated once received from the server. Therefore, a - // timeout must be used when looking for the tags. - try { - $tagFound = $this->actor->find(self::systemTagsItemInDropdownForTag($tag), 10)->isVisible(); - } catch (NoSuchElementException $exception) { - $tagFound = false; - } - - // Close again the dropdown after looking for the tag. When a - // dropdown is opened Select2 creates a special element that masks - // every other element but the dropdown to get all mouse clicks; - // this is used by Select2 to close the dropdown when the user - // clicks outside it. - $actor->find(self::select2DropdownMask())->click(); - - return $tagFound; - }; - - $numberOfTries = 5; - for ($i = 0; $i < $numberOfTries; $i++) { - if ($tagFoundInDropdownCallback()) { - return; - } - } - - PHPUnit_Framework_Assert::fail("The dropdown in system tags section in Administration Settings does not contain the tag $tag after $numberOfTries tries"); - } -} diff --git a/tests/acceptance/features/bootstrap/SettingsMenuContext.php b/tests/acceptance/features/bootstrap/SettingsMenuContext.php deleted file mode 100644 index 678d7c5eabb..00000000000 --- a/tests/acceptance/features/bootstrap/SettingsMenuContext.php +++ /dev/null @@ -1,219 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv) (skjnldsv@protonmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class SettingsMenuContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function settingsSectionInHeader() { - return Locator::forThe()->xpath("//*[@id = 'header']//*[@id = 'settings']")-> - describedAs("Settings menu section in the header"); - } - - /** - * @return Locator - */ - public static function settingsMenuButton() { - return Locator::forThe()->id("expand")-> - descendantOf(self::settingsSectionInHeader())-> - describedAs("Settings menu button"); - } - - /** - * @return Locator - */ - public static function settingsMenu() { - return Locator::forThe()->id("expanddiv")-> - descendantOf(self::settingsSectionInHeader())-> - describedAs("Settings menu"); - } - - /** - * @return Locator - */ - public static function usersMenuItem() { - return self::menuItemFor("Users"); - } - - /** - * @return Locator - */ - public static function usersAppsItem() { - return self::menuItemFor("Apps"); - } - - /** - * @return Locator - */ - public static function logOutMenuItem() { - return self::menuItemFor("Log out"); - } - - /** - * @return Locator - */ - private static function menuItemFor($itemText) { - return Locator::forThe()->xpath("//a[normalize-space() = '$itemText']")-> - descendantOf(self::settingsMenu())-> - describedAs($itemText . " item in Settings menu"); - } - - /** - * @param string $itemText - * @return Locator - */ - private static function settingsPanelFor($itemText) { - return Locator::forThe()->xpath("//div[@id = 'app-navigation' or contains(@class, 'app-navigation')]//ul//li[@class = 'app-navigation-caption' and normalize-space() = '$itemText']")-> - describedAs($itemText . " item in Settings panel"); - } - - /** - * @param string $itemText - * @return Locator - */ - private static function settingsPanelEntryFor($itemText) { - return Locator::forThe()->xpath("//div[@id = 'app-navigation' or contains(@class, 'app-navigation')]//ul//li[normalize-space() = '$itemText']")-> - describedAs($itemText . " entry in Settings panel"); - } - - /** - * @return array - */ - public function menuItems() { - return $this->actor->find(self::settingsMenu(), 10) - ->getWrappedElement()->findAll('xpath', '//a'); - } - - /** - * @When I open the Settings menu - */ - public function iOpenTheSettingsMenu() { - $this->actor->find(self::settingsMenuButton(), 10)->click(); - } - - /** - * @When I open the User settings - */ - public function iOpenTheUserSettings() { - $this->iOpenTheSettingsMenu(); - - $this->actor->find(self::usersMenuItem(), 2)->click(); - } - - /** - * @When I open the Apps management - */ - public function iOpenTheAppsManagement() { - $this->iOpenTheSettingsMenu(); - - $this->actor->find(self::usersAppsItem(), 2)->click(); - } - - /** - * @When I visit the settings page - */ - public function iVisitTheSettingsPage() { - $this->iOpenTheSettingsMenu(); - $this->actor->find(self::menuItemFor('Settings'), 2)->click(); - } - - /** - * @When I log out - */ - public function iLogOut() { - $this->iOpenTheSettingsMenu(); - - $this->actor->find(self::logOutMenuItem(), 2)->click(); - } - - /** - * @Then I see that the Settings menu is shown - */ - public function iSeeThatTheSettingsMenuIsShown() { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::settingsMenu(), 10)->isVisible()); - } - - /** - * @Then I see that the Settings menu has only :items items - */ - public function iSeeThatTheSettingsMenuHasOnlyXItems($items) { - PHPUnit_Framework_Assert::assertCount(intval($items), self::menuItems()); - } - - /** - * @Then I see that the :itemText item in the Settings menu is shown - */ - public function iSeeThatTheItemInTheSettingsMenuIsShown($itemText) { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::menuItemFor($itemText), 10)->isVisible()); - } - - /** - * @Then I see that the :itemText item in the Settings menu is not shown - */ - public function iSeeThatTheItemInTheSettingsMenuIsNotShown($itemText) { - $this->iSeeThatTheSettingsMenuIsShown(); - - try { - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::menuItemFor($itemText))->isVisible()); - } catch (NoSuchElementException $exception) { - } - } - - /** - * @Then I see that the :itemText settings panel is shown - */ - public function iSeeThatTheItemSettingsPanelIsShown($itemText) { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::settingsPanelFor($itemText), 10)->isVisible() - ); - } - - /** - * @Then I see that the :itemText entry in the settings panel is shown - */ - public function iSeeThatTheItemEntryInTheSettingsPanelIsShown($itemText) { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::settingsPanelEntryFor($itemText), 10)->isVisible() - ); - } - - /** - * @Then I see that the :itemText settings panel is not shown - */ - public function iSeeThatTheItemSettingsPanelIsNotShown($itemText) { - try { - PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::settingsPanelFor($itemText), 10)->isVisible() - ); - } catch (NoSuchElementException $exception) { - } - } -} diff --git a/tests/acceptance/features/bootstrap/ThemingAppContext.php b/tests/acceptance/features/bootstrap/ThemingAppContext.php deleted file mode 100644 index de25bafd6c3..00000000000 --- a/tests/acceptance/features/bootstrap/ThemingAppContext.php +++ /dev/null @@ -1,163 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class ThemingAppContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function inputFieldFor($parameterName) { - return Locator::forThe()->css("input")-> - descendantOf(self::parameterDivFor($parameterName))-> - describedAs("Input field for $parameterName parameter in Theming app"); - } - - /** - * @return Locator - */ - public static function resetButtonFor($parameterName) { - return Locator::forThe()->css(".theme-undo")-> - descendantOf(self::parameterDivFor($parameterName))-> - describedAs("Reset button for $parameterName parameter in Theming app"); - } - - /** - * @return Locator - */ - private static function parameterDivFor($parameterName) { - return Locator::forThe()->xpath("//*[@id='theming']//label//*[normalize-space() = '$parameterName']/ancestor::div[1]")-> - describedAs("Div for $parameterName parameter in Theming app"); - } - - /** - * @return Locator - */ - public static function statusMessage() { - return Locator::forThe()->id("theming_settings_msg")-> - describedAs("Status message in Theming app"); - } - - /** - * @When I set the :parameterName parameter in the Theming app to :parameterValue - */ - public function iSetTheParameterInTheThemingAppTo($parameterName, $parameterValue) { - $this->actor->find(self::inputFieldFor($parameterName), 10)->setValue($parameterValue . "\r"); - } - - /** - * @When I reset the :parameterName parameter in the Theming app to its default value - */ - public function iSetTheParameterInTheThemingAppToItsDefaultValue($parameterName) { - // The reset button is not shown when the cursor is outside the input - // field, so ensure that the cursor is on the input field by clicking on - // it. - $this->actor->find(self::inputFieldFor($parameterName), 10)->click(); - - $this->actor->find(self::resetButtonFor($parameterName), 10)->click(); - } - - /** - * @Then I see that the color selector in the Theming app has loaded - */ - public function iSeeThatTheColorSelectorInTheThemingAppHasLoaded() { - // Checking if the color selector has loaded by getting the background color - // of the input element. If the value present in the element matches the - // background of the input element, it means the color element has been - // initialized. - - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::inputFieldFor("Color"), 10)->isVisible()); - - $actor = $this->actor; - - $colorSelectorLoadedCallback = function () use ($actor) { - $colorSelectorValue = $this->getRGBArray($actor->getSession()->evaluateScript("return $('#theming-color')[0].value;")); - $inputBgColor = $this->getRGBArray($actor->getSession()->evaluateScript("return $('#theming-color').css('background-color');")); - if ($colorSelectorValue == $inputBgColor) { - return true; - } - - return false; - }; - - if (!Utils::waitFor($colorSelectorLoadedCallback, $timeout = 10 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) { - PHPUnit_Framework_Assert::fail("The color selector in Theming app has not been loaded after $timeout seconds"); - } - } - - private function getRGBArray($color) { - if (preg_match("/rgb\(\s*(\d+),\s*(\d+),\s*(\d+)\)/", $color, $matches)) { - // Already an RGB (R, G, B) color - // Convert from "rgb(R, G, B)" string to RGB array - $tmpColor = array_splice($matches, 1); - } elseif ($color[0] === '#') { - $color = substr($color, 1); - // HEX Color, convert to RGB array. - $tmpColor = sscanf($color, "%02X%02X%02X"); - } else { - PHPUnit_Framework_Assert::fail("The acceptance test does not know how to handle the color string : '$color'. " - . "Please provide # before HEX colors in your features."); - } - return $tmpColor; - } - - /** - * @Then I see that the header color is eventually :color - */ - public function iSeeThatTheHeaderColorIsEventually($color) { - $headerColorMatchesCallback = function () use ($color) { - $headerColor = $this->actor->getSession()->evaluateScript("return $('#header').css('background-color');"); - $headerColor = $this->getRGBArray($headerColor); - $color = $this->getRGBArray($color); - - return $headerColor == $color; - }; - - if (!Utils::waitFor($headerColorMatchesCallback, $timeout = 10 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) { - PHPUnit_Framework_Assert::fail("The header color is not $color yet after $timeout seconds"); - } - } - - /** - * @Then I see that the parameters in the Theming app are eventually saved - */ - public function iSeeThatTheParametersInTheThemingAppAreEventuallySaved() { - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::statusMessage(), 10)->isVisible()); - - $actor = $this->actor; - - $savedStatusMessageShownCallback = function () use ($actor) { - if ($actor->find(self::statusMessage())->getText() !== "Saved") { - return false; - } - - return true; - }; - - if (!Utils::waitFor($savedStatusMessageShownCallback, $timeout = 10 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) { - PHPUnit_Framework_Assert::fail("The 'Saved' status messages in Theming app has not been shown after $timeout seconds"); - } - } -} diff --git a/tests/acceptance/features/bootstrap/ToastContext.php b/tests/acceptance/features/bootstrap/ToastContext.php deleted file mode 100644 index 5a67d7f2581..00000000000 --- a/tests/acceptance/features/bootstrap/ToastContext.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class ToastContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function toastMessage($message) { - return Locator::forThe()->xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' toastify ') and normalize-space(text()) = '$message']")-> - descendantOf(self::toastContainer())-> - describedAs("$message toast"); - } - - /** - * @return Locator - */ - private static function toastContainer() { - return Locator::forThe()->xpath("//*[@id=\"content\" or contains(@class, 'content')]")-> - describedAs("Toast container"); - } - - /** - * @Then I see that the :message toast is shown - */ - public function iSeeThatTheToastIsShown($message) { - PHPUnit_Framework_Assert::assertTrue($this->actor->find( - self::toastMessage($message), 10)->isVisible()); - } -} diff --git a/tests/acceptance/features/bootstrap/UsersSettingsContext.php b/tests/acceptance/features/bootstrap/UsersSettingsContext.php deleted file mode 100644 index 020da466128..00000000000 --- a/tests/acceptance/features/bootstrap/UsersSettingsContext.php +++ /dev/null @@ -1,342 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> - * @copyright Copyright (c) 2019, Greta Doci <gretadoci@gmail.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; - -class UsersSettingsContext implements Context, ActorAwareInterface { - use ActorAware; - - /** - * @return Locator - */ - public static function newUserForm() { - return Locator::forThe()->id("new-user")-> - describedAs("New user form in Users Settings"); - } - - /** - * @return Locator - */ - public static function userNameFieldForNewUser() { - return Locator::forThe()->field("newusername")-> - describedAs("User name field for new user in Users Settings"); - } - - /** - * @return Locator - */ - public static function displayNameFieldForNewUser() { - return Locator::forThe()->field("newdisplayname")-> - describedAs("Display name field for new user in Users Settings"); - } - - /** - * @return Locator - */ - public static function passwordFieldForNewUser() { - return Locator::forThe()->field("newuserpassword")-> - describedAs("Password field for new user in Users Settings"); - } - - /** - * @return Locator - */ - public static function newUserButton() { - return Locator::forThe()->id("new-user-button")-> - describedAs("New user button in Users Settings"); - } - - /** - * @return Locator - */ - public static function createNewUserButton() { - return Locator::forThe()->xpath("//form[@id = 'new-user']//input[@type = 'submit']")-> - describedAs("Create user button in Users Settings"); - } - - /** - * @return Locator - */ - public static function rowForUser($user) { - return Locator::forThe()->css("div.user-list-grid div.row[data-id=$user]")-> - describedAs("Row for user $user in Users Settings"); - } - - /** - * Warning: you need to watch out for the proper classes order - * - * @return Locator - */ - public static function classCellForUser($class, $user) { - return Locator::forThe()->xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' $class ')]")-> - descendantOf(self::rowForUser($user))-> - describedAs("$class cell for user $user in Users Settings"); - } - - /** - * @return Locator - */ - public static function inputForUserInCell($cell, $user) { - return Locator::forThe()->css("input")-> - descendantOf(self::classCellForUser($cell, $user))-> - describedAs("$cell input for user $user in Users Settings"); - } - - /** - * @return Locator - */ - public static function displayNameCellForUser($user) { - return self::inputForUserInCell("displayName", $user); - } - - /** - * @return Locator - */ - public static function optionInInputForUser($cell, $user) { - return Locator::forThe()->css(".multiselect__option--highlight")-> - descendantOf(self::classCellForUser($cell, $user))-> - describedAs("Selected $cell option in $cell input for user $user in Users Settings"); - } - - /** - * @return Locator - */ - public static function actionsMenuOf($user) { - return Locator::forThe()->css(".icon-more")-> - descendantOf(self::rowForUser($user))-> - describedAs("Actions menu for user $user in Users Settings"); - } - - /** - * @return Locator - */ - public static function theAction($action, $user) { - return Locator::forThe()->xpath("//button[normalize-space() = '$action']")-> - descendantOf(self::rowForUser($user))-> - describedAs("$action action for the user $user row in Users Settings"); - } - - /** - * @return Locator - */ - public static function theColumn($column) { - return Locator::forThe()->xpath("//div[@class='user-list-grid']//div[normalize-space() = '$column']")-> - describedAs("The $column column in Users Settings"); - } - - /** - * @return Locator - */ - public static function selectedSelectOption($cell, $user) { - return Locator::forThe()->css(".multiselect__single")-> - descendantOf(self::classCellForUser($cell, $user))-> - describedAs("The selected option of the $cell select for the user $user in Users Settings"); - } - - /** - * @return Locator - */ - public static function editModeToggle($user) { - return Locator::forThe()->css(".toggleUserActions button.icon-rename")-> - descendantOf(self::rowForUser($user))-> - describedAs("The edit toggle button for the user $user in Users Settings"); - } - - /** - * @return Locator - */ - public static function editModeOn($user) { - return Locator::forThe()->css("div.user-list-grid div.row.row--editable[data-id=$user]")-> - describedAs("I see the edit mode is on for the user $user in Users Settings"); - } - - /** - * @When I click the New user button - */ - public function iClickTheNewUserButton() { - $this->actor->find(self::newUserButton())->click(); - } - - /** - * @When I click the :action action in the :user actions menu - */ - public function iClickTheAction($action, $user) { - $this->actor->find(self::theAction($action, $user))->click(); - } - - /** - * @When I open the actions menu for the user :user - */ - public function iOpenTheActionsMenuOf($user) { - $this->actor->find(self::actionsMenuOf($user))->click(); - } - - /** - * @When I set the user name for the new user to :user - */ - public function iSetTheUserNameForTheNewUserTo($user) { - $this->actor->find(self::userNameFieldForNewUser(), 10)->setValue($user); - } - - /** - * @When I set the display name for the new user to :displayName - */ - public function iSetTheDisplayNameForTheNewUserTo($displayName) { - $this->actor->find(self::displayNameFieldForNewUser(), 10)->setValue($displayName); - } - - /** - * @When I set the password for the new user to :password - */ - public function iSetThePasswordForTheNewUserTo($password) { - $this->actor->find(self::passwordFieldForNewUser(), 10)->setValue($password); - } - - /** - * @When I create the new user - */ - public function iCreateTheNewUser() { - $this->actor->find(self::createNewUserButton(), 10)->click(); - } - - /** - * @When I toggle the edit mode for the user :user - */ - public function iToggleTheEditModeForUser($user) { - $this->actor->find(self::editModeToggle($user), 10)->click(); - } - - /** - * @When I create user :user with password :password - */ - public function iCreateUserWithPassword($user, $password) { - $this->actor->find(self::userNameFieldForNewUser(), 10)->setValue($user); - $this->actor->find(self::passwordFieldForNewUser())->setValue($password); - $this->actor->find(self::createNewUserButton())->click(); - } - - /** - * @When I set the :field for :user to :value - */ - public function iSetTheFieldForUserTo($field, $user, $value) { - $this->actor->find(self::inputForUserInCell($field, $user), 2)->setValue($value . "\r"); - } - - /** - * Assigning/withdrawing is the same action (it toggles). - * - * @When I assign the user :user to the group :group - * @When I withdraw the user :user from the group :group - */ - public function iAssignTheUserToTheGroup($user, $group) { - $this->actor->find(self::inputForUserInCell('groups', $user))->setValue($group); - $this->actor->find(self::optionInInputForUser('groups', $user))->click(); - } - - /** - * @When I set the user :user quota to :quota - */ - public function iSetTheUserQuotaTo($user, $quota) { - $this->actor->find(self::inputForUserInCell('quota', $user))->setValue($quota); - $this->actor->find(self::optionInInputForUser('quota', $user))->click(); - } - - /** - * @Then I see that the list of users contains the user :user - */ - public function iSeeThatTheListOfUsersContainsTheUser($user) { - WaitFor::elementToBeEventuallyShown($this->actor, self::rowForUser($user)); - } - - /** - * @Then I see that the list of users does not contains the user :user - */ - public function iSeeThatTheListOfUsersDoesNotContainsTheUser($user) { - WaitFor::elementToBeEventuallyNotShown($this->actor, self::rowForUser($user)); - } - - /** - * @Then I see that the new user form is shown - */ - public function iSeeThatTheNewUserFormIsShown() { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::newUserForm(), 10)->isVisible()); - } - - /** - * @Then I see that the :action action in the :user actions menu is shown - */ - public function iSeeTheAction($action, $user) { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::theAction($action, $user), 10)->isVisible()); - } - - /** - * @Then I see that the :column column is shown - */ - public function iSeeThatTheColumnIsShown($column) { - PHPUnit_Framework_Assert::assertTrue( - $this->actor->find(self::theColumn($column), 10)->isVisible()); - } - - /** - * @Then I see that the :field of :user is :value - */ - public function iSeeThatTheFieldOfUserIs($field, $user, $value) { - PHPUnit_Framework_Assert::assertEquals( - $this->actor->find(self::inputForUserInCell($field, $user), 10)->getValue(), $value); - } - - /** - * @Then I see that the display name for the user :user is :displayName - */ - public function iSeeThatTheDisplayNameForTheUserIs($user, $displayName) { - PHPUnit_Framework_Assert::assertEquals( - $displayName, $this->actor->find(self::displayNameCellForUser($user), 10)->getValue()); - } - - /** - * @Then I see that the :cell cell for user :user is done loading - */ - public function iSeeThatTheCellForUserIsDoneLoading($cell, $user) { - WaitFor::elementToBeEventuallyShown($this->actor, self::classCellForUser($cell . ' icon-loading-small', $user)); - WaitFor::elementToBeEventuallyNotShown($this->actor, self::classCellForUser($cell . ' icon-loading-small', $user)); - } - - /** - * @Then I see that the user quota of :user is :quota - */ - public function iSeeThatTheuserQuotaIs($user, $quota) { - PHPUnit_Framework_Assert::assertEquals( - $this->actor->find(self::selectedSelectOption('quota', $user), 2)->getText(), $quota); - } - - /** - * @Then I see that the edit mode is on for user :user - */ - public function iSeeThatTheEditModeIsOn($user) { - WaitFor::elementToBeEventuallyShown($this->actor, self::editModeOn($user)); - } -} diff --git a/tests/acceptance/features/bootstrap/WaitFor.php b/tests/acceptance/features/bootstrap/WaitFor.php deleted file mode 100644 index b07586c4662..00000000000 --- a/tests/acceptance/features/bootstrap/WaitFor.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -/** - * Helper class with common "wait for" functions. - */ -class WaitFor { - - /** - * Waits for the element to be visible. - * - * @param Actor $actor the Actor used to find the element. - * @param Locator $elementLocator the locator for the element. - * @param float $timeout the number of seconds (decimals allowed) to wait at - * most for the element to be visible. - * @param float $timeoutStep the number of seconds (decimals allowed) to - * wait before checking the visibility again. - * @return boolean true if the element is visible before (or exactly when) - * the timeout expires, false otherwise. - */ - public static function elementToBeEventuallyShown(Actor $actor, Locator $elementLocator, $timeout = 10, $timeoutStep = 1) { - $elementShownCallback = function () use ($actor, $elementLocator) { - try { - return $actor->find($elementLocator)->isVisible(); - } catch (NoSuchElementException $exception) { - return false; - } - }; - - return Utils::waitFor($elementShownCallback, $timeout, $timeoutStep); - } - - /** - * Waits for the element to be hidden (either not visible or not found in - * the DOM). - * - * @param Actor $actor the Actor used to find the element. - * @param Locator $elementLocator the locator for the element. - * @param float $timeout the number of seconds (decimals allowed) to wait at - * most for the element to be hidden. - * @param float $timeoutStep the number of seconds (decimals allowed) to - * wait before checking the visibility again. - * @return boolean true if the element is hidden before (or exactly when) - * the timeout expires, false otherwise. - */ - public static function elementToBeEventuallyNotShown(Actor $actor, Locator $elementLocator, $timeout = 10, $timeoutStep = 1) { - $elementNotShownCallback = function () use ($actor, $elementLocator) { - try { - return !$actor->find($elementLocator)->isVisible(); - } catch (NoSuchElementException $exception) { - return true; - } - }; - - return Utils::waitFor($elementNotShownCallback, $timeout, $timeoutStep); - } -} diff --git a/tests/acceptance/features/core/Actor.php b/tests/acceptance/features/core/Actor.php deleted file mode 100644 index ea33e7df21e..00000000000 --- a/tests/acceptance/features/core/Actor.php +++ /dev/null @@ -1,215 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -/** - * An actor in a test scenario. - * - * Every Actor object is intended to be used only in a single test scenario. - * An Actor can control its web browser thanks to the Mink Session received when - * it was created, so in each scenario each Actor must have its own Mink - * Session; the same Mink Session can be used by different Actors in different - * scenarios, but never by different Actors in the same scenario. - * - * The test servers used in an scenario can change between different test runs, - * so an Actor stores the base URL for the current test server being used; in - * most cases the tests are specified using relative paths that can be converted - * to the appropriate absolute URL using locatePath() in the step - * implementation. - * - * An Actor can find elements in its Mink Session using its find() method; it is - * a wrapper over the find() method provided by Mink that extends it with - * several features: the element can be looked for based on a Locator object, an - * exception is thrown if the element is not found, and, optionally, it is - * possible to try again to find the element several times before giving up. - * - * The returned object is also a wrapper over the element itself that - * automatically handles common causes of failed commands, like clicking on a - * hidden element; in this case, the wrapper would wait for the element to be - * visible up to the timeout set to find the element. - * - * The amount of time to wait before giving up is specified in each call to - * find(). However, a general multiplier to be applied to every timeout can be - * set using setFindTimeoutMultiplier(); this makes possible to retry longer - * before giving up without modifying the tests themselves. Note that the - * multiplier affects the timeout, but not the timeout step; the rate at which - * find() will try again to find the element does not change. - * - * All actors share a notebook in which data can be annotated. This makes - * possible to share data between different test steps, no matter which Actor - * performs them. - */ -class Actor { - - /** - * @var string - */ - private $name; - - /** - * @var \Behat\Mink\Session - */ - private $session; - - /** - * @var string - */ - private $baseUrl; - - /** - * @var float - */ - private $findTimeoutMultiplier; - - /** - * @var array - */ - private $sharedNotebook; - - /** - * Creates a new Actor. - * - * @param string $name the name of the actor. - * @param \Behat\Mink\Session $session the Mink Session used to control its - * web browser. - * @param string $baseUrl the base URL used when solving relative URLs. - * @param array $sharedNotebook the notebook shared between all actors. - */ - public function __construct($name, \Behat\Mink\Session $session, $baseUrl, &$sharedNotebook) { - $this->name = $name; - $this->session = $session; - $this->baseUrl = $baseUrl; - $this->sharedNotebook = &$sharedNotebook; - $this->findTimeoutMultiplier = 1; - } - - /** - * Returns the name of this Actor. - * - * @return string the name of this Actor. - */ - public function getName() { - return $this->name; - } - - /** - * Sets the base URL. - * - * @param string $baseUrl the base URL used when solving relative URLs. - */ - public function setBaseUrl($baseUrl) { - $this->baseUrl = $baseUrl; - } - - /** - * Returns the multiplier for find timeouts. - * - * @return float the multiplier to apply to find timeouts. - */ - public function getFindTimeoutMultiplier() { - return $this->findTimeoutMultiplier; - } - - /** - * Sets the multiplier for find timeouts. - * - * @param float $findTimeoutMultiplier the multiplier to apply to find - * timeouts. - */ - public function setFindTimeoutMultiplier($findTimeoutMultiplier) { - $this->findTimeoutMultiplier = $findTimeoutMultiplier; - } - - /** - * Returns the Mink Session used to control its web browser. - * - * @return \Behat\Mink\Session the Mink Session used to control its web - * browser. - */ - public function getSession() { - return $this->session; - } - - /** - * Returns the full path for the given relative path based on the base URL. - * - * @param string relativePath the relative path. - * @return string the full path. - */ - public function locatePath($relativePath) { - return $this->baseUrl . $relativePath; - } - - /** - * Finds an element in the Mink Session of this Actor. - * - * The given element locator is relative to its ancestor (either another - * locator or an actual element); if it has no ancestor then the base - * document element is used. - * - * Sometimes an element may not be found simply because it has not appeared - * yet; for those cases this method supports trying again to find the - * element several times before giving up. The timeout parameter controls - * how much time to wait, at most, to find the element; the timeoutStep - * parameter controls how much time to wait before trying again to find the - * element. If ancestor locators need to be found the timeout is applied - * individually to each one, that is, if the timeout is 10 seconds the - * method will wait up to 10 seconds to find the ancestor of the ancestor - * and, then, up to 10 seconds to find the ancestor and, then, up to 10 - * seconds to find the element. By default the timeout is 0, so the element - * and its ancestor will be looked for just once; the default time to wait - * before retrying is half a second. If the timeout is not 0 it will be - * affected by the multiplier set using setFindTimeoutMultiplier(), if any. - * - * When found, the element is returned wrapped in an ElementWrapper; the - * ElementWrapper handles common causes of failures when executing commands - * in an element, like clicking on a hidden element. - * - * In any case, if the element, or its ancestors, can not be found a - * NoSuchElementException is thrown. - * - * @param Locator $elementLocator the locator for the element. - * @param float $timeout the number of seconds (decimals allowed) to wait at - * most for the element to appear. - * @param float $timeoutStep the number of seconds (decimals allowed) to - * wait before trying to find the element again. - * @return ElementWrapper an ElementWrapper object for the element. - * @throws NoSuchElementException if the element, or its ancestor, can not - * be found. - */ - public function find(Locator $elementLocator, $timeout = 0, $timeoutStep = 0.5) { - $timeout = $timeout * $this->findTimeoutMultiplier; - - $elementFinder = new ElementFinder($this->session, $elementLocator, $timeout, $timeoutStep); - - return new ElementWrapper($elementFinder); - } - - /** - * Returns the shared notebook of the Actors. - * - * @return array the shared notebook of the Actors. - */ - public function &getSharedNotebook() { - return $this->sharedNotebook; - } -} diff --git a/tests/acceptance/features/core/ActorAware.php b/tests/acceptance/features/core/ActorAware.php deleted file mode 100644 index 5a1a7542355..00000000000 --- a/tests/acceptance/features/core/ActorAware.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -trait ActorAware { - - /** - * @var Actor - */ - protected $actor; - - /** - * @param Actor $actor - */ - public function setCurrentActor(Actor $actor) { - $this->actor = $actor; - } -} diff --git a/tests/acceptance/features/core/ActorAwareInterface.php b/tests/acceptance/features/core/ActorAwareInterface.php deleted file mode 100644 index 37261773cbb..00000000000 --- a/tests/acceptance/features/core/ActorAwareInterface.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -interface ActorAwareInterface { - - /** - * @param Actor $actor - */ - public function setCurrentActor(Actor $actor); -} diff --git a/tests/acceptance/features/core/ActorContext.php b/tests/acceptance/features/core/ActorContext.php deleted file mode 100644 index 932af5ff277..00000000000 --- a/tests/acceptance/features/core/ActorContext.php +++ /dev/null @@ -1,187 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Hook\Scope\BeforeStepScope; -use Behat\MinkExtension\Context\RawMinkContext; - -/** - * Behat context to set the actor used in sibling contexts. - * - * This helper context provides a step definition ("I act as XXX") to change the - * current actor of the scenario, which makes possible to use different browser - * sessions in the same scenario. - * - * Sibling contexts that want to have access to the current actor of the - * scenario must implement the ActorAwareInterface; this can be done just by - * using the ActorAware trait. - * - * Besides updating the current actor in sibling contexts the ActorContext also - * propagates its inherited "base_url" Mink parameter to the Actors as needed. - * - * By default no multiplier for the find timeout is set in the Actors. However, - * it can be customized using the "actorTimeoutMultiplier" parameter of the - * ActorContext in "behat.yml". This parameter also affects the overall timeout - * to start a session for an Actor before giving up. - * - * Every actor used in the scenarios must have a corresponding Mink session - * declared in "behat.yml" with the same name as the actor. All used sessions - * are stopped after each scenario is run. - */ -class ActorContext extends RawMinkContext { - - /** - * @var array - */ - private $actors; - - /** - * @var array - */ - private $sharedNotebook; - - /** - * @var Actor - */ - private $currentActor; - - /** - * @var float - */ - private $actorTimeoutMultiplier; - - /** - * Creates a new ActorContext. - * - * @param float $actorTimeoutMultiplier the timeout multiplier for Actor - * related timeouts. - */ - public function __construct($actorTimeoutMultiplier = 1) { - $this->actorTimeoutMultiplier = $actorTimeoutMultiplier; - } - - /** - * Sets a Mink parameter. - * - * When the "base_url" parameter is set its value is propagated to all the - * Actors. - * - * @param string $name the name of the parameter. - * @param string $value the value of the parameter. - */ - public function setMinkParameter($name, $value) { - parent::setMinkParameter($name, $value); - - if ($name === "base_url") { - foreach ($this->actors as $actor) { - $actor->setBaseUrl($value); - } - } - } - - /** - * Returns the session with the given name. - * - * If the session is not started it is started before returning it; if the - * session fails to start (typically due to a timeout connecting with the - * web browser) it will be tried again up to $actorTimeoutMultiplier times - * in total (rounded up to the next integer) before giving up. - * - * @param string|null $sname the name of the session to get, or null for the - * default session. - * @return \Behat\Mink\Session the session. - */ - public function getSession($name = null) { - for ($i = 0; $i < ($this->actorTimeoutMultiplier - 1); $i++) { - try { - return parent::getSession($name); - } catch (\Behat\Mink\Exception\DriverException $exception) { - echo "Exception when getting " . ($name == null? "default session": "session '$name'") . ": " . $exception->getMessage() . "\n"; - echo "Trying again\n"; - } - } - - return parent::getSession($name); - } - - /** - * @BeforeScenario - * - * Initializes the Actors for the new Scenario with the default Actor. - * - * Other Actors are added (and their Mink Sessions started) only when they - * are used in an "I act as XXX" step. - */ - public function initializeActors() { - $this->actors = []; - $this->sharedNotebook = []; - - $this->actors["default"] = new Actor("default", $this->getSession(), $this->getMinkParameter("base_url"), $this->sharedNotebook); - $this->actors["default"]->setFindTimeoutMultiplier($this->actorTimeoutMultiplier); - - $this->currentActor = $this->actors["default"]; - } - - /** - * @BeforeStep - */ - public function setCurrentActorInSiblingActorAwareContexts(BeforeStepScope $scope) { - $environment = $scope->getEnvironment(); - - foreach ($environment->getContexts() as $context) { - if ($context instanceof ActorAwareInterface) { - $context->setCurrentActor($this->currentActor); - } - } - } - - /** - * @Given I act as :actorName - */ - public function iActAs($actorName) { - if (!array_key_exists($actorName, $this->actors)) { - $this->actors[$actorName] = new Actor($actorName, $this->getSession($actorName), $this->getMinkParameter("base_url"), $this->sharedNotebook); - $this->actors[$actorName]->setFindTimeoutMultiplier($this->actorTimeoutMultiplier); - } - - $this->currentActor = $this->actors[$actorName]; - - // Ensure that the browser window of the actor is the one in the - // foreground; this works around a bug in the Firefox driver of Selenium - // and/or maybe in Firefox itself when interacting with a window in the - // background, but also reflects better how the user would interact with - // the browser in real life. - $session = $this->actors[$actorName]->getSession(); - $session->switchToWindow($session->getWindowName()); - } - - /** - * @AfterScenario - * - * Stops all the Mink Sessions used in the last Scenario. - */ - public function cleanUpSessions() { - foreach ($this->actors as $actor) { - $actor->getSession()->stop(); - } - } -} diff --git a/tests/acceptance/features/core/ElementFinder.php b/tests/acceptance/features/core/ElementFinder.php deleted file mode 100644 index 9981321c90d..00000000000 --- a/tests/acceptance/features/core/ElementFinder.php +++ /dev/null @@ -1,204 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -/** - * Command object to find Mink elements. - * - * The element locator is relative to its ancestor (either another locator or an - * actual element); if it has no ancestor then the base document element is - * used. - * - * Sometimes an element may not be found simply because it has not appeared yet; - * for those cases ElementFinder supports trying again to find the element - * several times before giving up. The timeout parameter controls how much time - * to wait, at most, to find the element; the timeoutStep parameter controls how - * much time to wait before trying again to find the element. If ancestor - * locators need to be found the timeout is applied individually to each one, - * that is, if the timeout is 10 seconds the method will wait up to 10 seconds - * to find the ancestor of the ancestor and, then, up to 10 seconds to find the - * ancestor and, then, up to 10 seconds to find the element. By default the - * timeout is 0, so the element and its ancestor will be looked for just once; - * the default time to wait before retrying is half a second. - * - * In any case, if the element, or its ancestors, can not be found a - * NoSuchElementException is thrown. - */ -class ElementFinder { - - /** - * Finds an element in the given Mink Session. - * - * @see ElementFinder - */ - private static function findInternal(\Behat\Mink\Session $session, Locator $elementLocator, $timeout, $timeoutStep) { - $element = null; - $selector = $elementLocator->getSelector(); - $locator = $elementLocator->getLocator(); - $ancestorElement = self::findAncestorElement($session, $elementLocator, $timeout, $timeoutStep); - - $findCallback = function () use (&$element, $selector, $locator, $ancestorElement) { - $element = $ancestorElement->find($selector, $locator); - - return $element !== null; - }; - if (!Utils::waitFor($findCallback, $timeout, $timeoutStep)) { - $message = $elementLocator->getDescription() . " could not be found"; - if ($timeout > 0) { - $message = $message . " after $timeout seconds"; - } - throw new NoSuchElementException($message); - } - - return $element; - } - - /** - * Returns the ancestor element from which the given locator will be looked - * for. - * - * If the ancestor of the given locator is another locator the element for - * the ancestor locator is found and returned. If the ancestor of the given - * locator is already an element that element is the one returned. If the - * given locator has no ancestor then the base document element is returned. - * - * The timeout is used only when finding the element for the ancestor - * locator; if the timeout expires a NoSuchElementException is thrown. - * - * @param \Behat\Mink\Session $session the Mink Session to get the ancestor - * element from. - * @param Locator $elementLocator the locator for the element to get its - * ancestor. - * @param float $timeout the number of seconds (decimals allowed) to wait at - * most for the ancestor element to appear. - * @param float $timeoutStep the number of seconds (decimals allowed) to - * wait before trying to find the ancestor element again. - * @return \Behat\Mink\Element\Element the ancestor element found. - * @throws NoSuchElementException if the ancestor element can not be found. - */ - private static function findAncestorElement(\Behat\Mink\Session $session, Locator $elementLocator, $timeout, $timeoutStep) { - $ancestorElement = $elementLocator->getAncestor(); - if ($ancestorElement instanceof Locator) { - try { - $ancestorElement = self::findInternal($session, $ancestorElement, $timeout, $timeoutStep); - } catch (NoSuchElementException $exception) { - // Little hack to show the stack of ancestor elements that could - // not be found, as Behat only shows the message of the last - // exception in the chain. - $message = $exception->getMessage() . "\n" . - $elementLocator->getDescription() . " could not be found"; - if ($timeout > 0) { - $message = $message . " after $timeout seconds"; - } - throw new NoSuchElementException($message, $exception); - } - } - - if ($ancestorElement === null) { - $ancestorElement = $session->getPage(); - } - - return $ancestorElement; - } - - /** - * @var \Behat\Mink\Session - */ - private $session; - - /** - * @param Locator - */ - private $elementLocator; - - /** - * @var float - */ - private $timeout; - - /** - * @var float - */ - private $timeoutStep; - - /** - * Creates a new ElementFinder. - * - * @param \Behat\Mink\Session $session the Mink Session to get the element - * from. - * @param Locator $elementLocator the locator for the element. - * @param float $timeout the number of seconds (decimals allowed) to wait at - * most for the element to appear. - * @param float $timeoutStep the number of seconds (decimals allowed) to - * wait before trying to find the element again. - */ - public function __construct(\Behat\Mink\Session $session, Locator $elementLocator, $timeout, $timeoutStep) { - $this->session = $session; - $this->elementLocator = $elementLocator; - $this->timeout = $timeout; - $this->timeoutStep = $timeoutStep; - } - - /** - * Returns the description of the element to find. - * - * @return string the description of the element to find. - */ - public function getDescription() { - return $this->elementLocator->getDescription(); - } - - /** - * Returns the timeout. - * - * @return float the number of seconds (decimals allowed) to wait at most - * for the element to appear. - */ - public function getTimeout() { - return $this->timeout; - } - - /** - * Returns the timeout step. - * - * @return float the number of seconds (decimals allowed) to wait before - * trying to find the element again. - */ - public function getTimeoutStep() { - return $this->timeoutStep; - } - - /** - * Finds an element using the parameters set in the constructor of this - * ElementFinder. - * - * If the element, or its ancestors, can not be found a - * NoSuchElementException is thrown. - * - * @return \Behat\Mink\Element\Element the element found. - * @throws NoSuchElementException if the element, or its ancestor, can not - * be found. - */ - public function find() { - return self::findInternal($this->session, $this->elementLocator, $this->timeout, $this->timeoutStep); - } -} diff --git a/tests/acceptance/features/core/ElementWrapper.php b/tests/acceptance/features/core/ElementWrapper.php deleted file mode 100644 index d5f7ef495c1..00000000000 --- a/tests/acceptance/features/core/ElementWrapper.php +++ /dev/null @@ -1,336 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -/** - * Wrapper to automatically handle failed commands on Mink elements. - * - * Commands executed on Mink elements may fail for several reasons. The - * ElementWrapper frees the caller of the commands from handling the most common - * reasons of failure. - * - * StaleElementReference exceptions are thrown when the command is executed on - * an element that is no longer attached to the DOM. This can happen even in - * a chained call like "$actor->find($locator)->click()"; in the milliseconds - * between finding the element and clicking it the element could have been - * removed from the page (for example, if a previous interaction with the page - * started an asynchronous update of the DOM). Every command executed through - * the ElementWrapper is guarded against StaleElementReference exceptions; if - * the element is stale it is found again using the same parameters to find it - * in the first place. - * - * NoSuchElement exceptions are sometimes thrown instead of - * StaleElementReference exceptions. This can happen when the Selenium2 driver - * for Mink performs an action on an element through the WebDriver session - * instead of directly through the WebDriver element. In that case, if the - * element with the given ID does not exist, a NoSuchElement exception would be - * thrown instead of a StaleElementReference exception, so those cases are - * handled like StaleElementReference exceptions. - * - * ElementNotVisible exceptions are thrown when the command requires the element - * to be visible but the element is not. Finding an element only guarantees that - * (at that time) the element is attached to the DOM, but it does not provide - * any guarantee regarding its visibility. Due to that, a call like - * "$actor->find($locator)->click()" can fail if the element was hidden and - * meant to be made visible by a previous interaction with the page, but that - * interaction triggered an asynchronous update that was not finished when the - * click command is executed. All commands executed through the ElementWrapper - * that require the element to be visible are guarded against ElementNotVisible - * exceptions; if the element is not visible it is waited for it to be visible - * up to the timeout set to find it. - * - * MoveTargetOutOfBounds exceptions are sometimes thrown instead of - * ElementNotVisible exceptions. This can happen when the Selenium2 driver for - * Mink moves the cursor on an element using the "moveto" method of the - * WebDriver session, for example, before clicking on an element. In that case, - * if the element is not visible, "moveto" would throw a MoveTargetOutOfBounds - * exception instead of an ElementNotVisible exception, so those cases are - * handled like ElementNotVisible exceptions. - * - * Despite the automatic handling it is possible for the commands to throw those - * exceptions when they are executed again; this class does not handle cases - * like an element becoming stale several times in a row (uncommon) or an - * element not becoming visible before the timeout expires (which would mean - * that the timeout is too short or that the test has to, indeed, fail). In a - * similar way, MoveTargetOutOfBounds exceptions would be thrown again if - * originally they were thrown because the element was visible but "out of - * reach". - * - * If needed, automatically handling failed commands can be disabled calling - * "doNotHandleFailedCommands()"; as it returns the ElementWrapper it can be - * chained with the command to execute (but note that automatically handling - * failed commands will still be disabled if further commands are executed on - * the ElementWrapper). - */ -class ElementWrapper { - - /** - * @var ElementFinder - */ - private $elementFinder; - - /** - * @var \Behat\Mink\Element\Element - */ - private $element; - - /** - * @param boolean - */ - private $handleFailedCommands; - - /** - * Creates a new ElementWrapper. - * - * The wrapped element is found in the constructor itself using the - * ElementFinder. - * - * @param ElementFinder $elementFinder the command object to find the - * wrapped element. - * @throws NoSuchElementException if the element, or its ancestor, can not - * be found. - */ - public function __construct(ElementFinder $elementFinder) { - $this->elementFinder = $elementFinder; - $this->element = $elementFinder->find(); - $this->handleFailedCommands = true; - } - - /** - * Returns the raw Mink element. - * - * @return \Behat\Mink\Element\Element the wrapped element. - */ - public function getWrappedElement() { - return $this->element; - } - - /** - * Prevents the automatic handling of failed commands. - * - * @return ElementWrapper this ElementWrapper. - */ - public function doNotHandleFailedCommands() { - $this->handleFailedCommands = false; - - return $this; - } - - /** - * Returns whether the wrapped element is visible or not. - * - * @return bool true if the wrapped element is visible, false otherwise. - */ - public function isVisible() { - $commandCallback = function () { - return $this->element->isVisible(); - }; - return $this->executeCommand($commandCallback, "visibility could not be got"); - } - - /** - * Returns whether the wrapped element is checked or not. - * - * @return bool true if the wrapped element is checked, false otherwise. - */ - public function isChecked() { - $commandCallback = function () { - return $this->element->isChecked(); - }; - return $this->executeCommand($commandCallback, "check state could not be got"); - } - - /** - * Returns the text of the wrapped element. - * - * If the wrapped element is not visible the returned text is an empty - * string. - * - * @return string the text of the wrapped element, or an empty string if it - * is not visible. - */ - public function getText() { - $commandCallback = function () { - return $this->element->getText(); - }; - return $this->executeCommand($commandCallback, "text could not be got"); - } - - /** - * Returns the value of the wrapped element. - * - * The value can be got even if the wrapped element is not visible. - * - * @return string the value of the wrapped element. - */ - public function getValue() { - $commandCallback = function () { - return $this->element->getValue(); - }; - return $this->executeCommand($commandCallback, "value could not be got"); - } - - /** - * Sets the given value on the wrapped element. - * - * If automatically waits for the wrapped element to be visible (up to the - * timeout set when finding it). - * - * @param string $value the value to set. - */ - public function setValue($value) { - $commandCallback = function () use ($value) { - $this->element->setValue($value); - }; - $this->executeCommandOnVisibleElement($commandCallback, "value could not be set"); - } - - /** - * Clicks on the wrapped element. - * - * If automatically waits for the wrapped element to be visible (up to the - * timeout set when finding it). - */ - public function click() { - $commandCallback = function () { - $this->element->click(); - }; - $this->executeCommandOnVisibleElement($commandCallback, "could not be clicked"); - } - - /** - * Check the wrapped element. - * - * If automatically waits for the wrapped element to be visible (up to the - * timeout set when finding it). - */ - public function check() { - $commandCallback = function () { - $this->element->check(); - }; - $this->executeCommand($commandCallback, "could not be checked"); - } - - /** - * uncheck the wrapped element. - * - * If automatically waits for the wrapped element to be visible (up to the - * timeout set when finding it). - */ - public function uncheck() { - $commandCallback = function () { - $this->element->uncheck(); - }; - $this->executeCommand($commandCallback, "could not be unchecked"); - } - - /** - * Executes the given command. - * - * If a StaleElementReference or a NoSuchElement exception is thrown the - * wrapped element is found again and, then, the command is executed again. - * - * @param \Closure $commandCallback the command to execute. - * @param string $errorMessage an error message that describes the failed - * command (appended to the description of the element). - */ - private function executeCommand(\Closure $commandCallback, $errorMessage) { - if (!$this->handleFailedCommands) { - return $commandCallback(); - } - - try { - return $commandCallback(); - } catch (\WebDriver\Exception\StaleElementReference $exception) { - $this->printFailedCommandMessage($exception, $errorMessage); - } catch (\WebDriver\Exception\NoSuchElement $exception) { - $this->printFailedCommandMessage($exception, $errorMessage); - } - - $this->element = $this->elementFinder->find(); - - return $commandCallback(); - } - - /** - * Executes the given command on a visible element. - * - * If a StaleElementReference or a NoSuchElement exception is thrown the - * wrapped element is found again and, then, the command is executed again. - * If an ElementNotVisible or a MoveTargetOutOfBounds exception is thrown it - * is waited for the wrapped element to be visible and, then, the command is - * executed again. - * - * @param \Closure $commandCallback the command to execute. - * @param string $errorMessage an error message that describes the failed - * command (appended to the description of the element). - */ - private function executeCommandOnVisibleElement(\Closure $commandCallback, $errorMessage) { - if (!$this->handleFailedCommands) { - return $commandCallback(); - } - - try { - return $this->executeCommand($commandCallback, $errorMessage); - } catch (\WebDriver\Exception\ElementNotVisible $exception) { - $this->printFailedCommandMessage($exception, $errorMessage); - } catch (\WebDriver\Exception\MoveTargetOutOfBounds $exception) { - $this->printFailedCommandMessage($exception, $errorMessage); - } - - $this->waitForElementToBeVisible(); - - return $commandCallback(); - } - - /** - * Prints information about the failed command. - * - * @param \Exception exception the exception thrown by the command. - * @param string $errorMessage an error message that describes the failed - * command (appended to the description of the locator of the element). - */ - private function printFailedCommandMessage(\Exception $exception, $errorMessage) { - echo $this->elementFinder->getDescription() . " " . $errorMessage . "\n"; - echo "Exception message: " . $exception->getMessage() . "\n"; - echo "Trying again\n"; - } - - /** - * Waits for the wrapped element to be visible. - * - * This method waits up to the timeout used when finding the wrapped - * element; therefore, it may return when the element is still not visible. - * - * @return boolean true if the element is visible after the wait, false - * otherwise. - */ - private function waitForElementToBeVisible() { - $isVisibleCallback = function () { - return $this->isVisible(); - }; - $timeout = $this->elementFinder->getTimeout(); - $timeoutStep = $this->elementFinder->getTimeoutStep(); - - return Utils::waitFor($isVisibleCallback, $timeout, $timeoutStep); - } -} diff --git a/tests/acceptance/features/core/Locator.php b/tests/acceptance/features/core/Locator.php deleted file mode 100644 index dd971147f86..00000000000 --- a/tests/acceptance/features/core/Locator.php +++ /dev/null @@ -1,317 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -/** - * Data object for the information needed to locate an element in a web page - * using Mink. - * - * Locators can be created directly using the constructor, or through a more - * fluent interface with Locator::forThe(). - */ -class Locator { - - /** - * @var string - */ - private $description; - - /** - * @var string - */ - private $selector; - - /** - * @var string|array - */ - private $locator; - - /** - * @var null|Locator|\Behat\Mink\Element\ElementInterface - */ - private $ancestor; - - /** - * Starting point for the fluent interface to create Locators. - * - * @return LocatorBuilder - */ - public static function forThe() { - return new LocatorBuilder(); - } - - /** - * @param string $description - * @param string $selector - * @param string|array $locator - * @param null|Locator|\Behat\Mink\Element\ElementInterface $ancestor - */ - public function __construct($description, $selector, $locator, $ancestor = null) { - $this->description = $description; - $this->selector = $selector; - $this->locator = $locator; - $this->ancestor = $ancestor; - } - - /** - * @return string - */ - public function getDescription() { - return $this->description; - } - - /** - * @return string - */ - public function getSelector() { - return $this->selector; - } - - /** - * @return string|array - */ - public function getLocator() { - return $this->locator; - } - - /** - * @return null|Locator|\Behat\Mink\Element\ElementInterface - */ - public function getAncestor() { - return $this->ancestor; - } -} - -class LocatorBuilder { - - /** - * @param string $selector - * @param string|array $locator - * @return LocatorBuilderSecondStep - */ - public function customSelector($selector, $locator) { - return new LocatorBuilderSecondStep($selector, $locator); - } - - /** - * @param string $cssExpression - * @return LocatorBuilderSecondStep - */ - public function css($cssExpression) { - return $this->customSelector("css", $cssExpression); - } - - /** - * @param string $xpathExpression - * @return LocatorBuilderSecondStep - */ - public function xpath($xpathExpression) { - return $this->customSelector("xpath", $xpathExpression); - } - - /** - * @param string $value - * @return LocatorBuilderSecondStep - */ - public function id($value) { - return $this->customSelector("named_exact", ["id", $value]); - } - - /** - * @param string $value - * @return LocatorBuilderSecondStep - */ - public function idOrName($value) { - return $this->customSelector("named_exact", ["id_or_name", $value]); - } - - /** - * @param string $value - * @return LocatorBuilderSecondStep - */ - public function link($value) { - return $this->customSelector("named_exact", ["link", $value]); - } - - /** - * @param string $value - * @return LocatorBuilderSecondStep - */ - public function button($value) { - return $this->customSelector("named_exact", ["button", $value]); - } - - /** - * @param string $value - * @return LocatorBuilderSecondStep - */ - public function linkOrButton($value) { - return $this->customSelector("named_exact", ["link_or_button", $value]); - } - - /** - * @param string $value - * @return LocatorBuilderSecondStep - */ - public function field($value) { - return $this->customSelector("named_exact", ["field", $value]); - } - - /** - * @param string $value - * @return LocatorBuilderSecondStep - */ - public function selectField($value) { - return $this->customSelector("named_exact", ["select", $value]); - } - - /** - * @param string $value - * @return LocatorBuilderSecondStep - */ - public function checkbox($value) { - return $this->customSelector("named_exact", ["checkbox", $value]); - } - - /** - * @param string $value - * @return LocatorBuilderSecondStep - */ - public function radioButton($value) { - return $this->customSelector("named_exact", ["radio", $value]); - } - - /** - * @param string $value - * @return LocatorBuilderSecondStep - */ - public function fileInput($value) { - return $this->customSelector("named_exact", ["file", $value]); - } - - /** - * @param string $value - * @return LocatorBuilderSecondStep - */ - public function optionGroup($value) { - return $this->customSelector("named_exact", ["optgroup", $value]); - } - - /** - * @param string $value - * @return LocatorBuilderSecondStep - */ - public function option($value) { - return $this->customSelector("named_exact", ["option", $value]); - } - - /** - * @param string $value - * @return LocatorBuilderSecondStep - */ - public function fieldSet($value) { - return $this->customSelector("named_exact", ["fieldset", $value]); - } - - /** - * @param string $value - * @return LocatorBuilderSecondStep - */ - public function table($value) { - return $this->customSelector("named_exact", ["table", $value]); - } -} - -class LocatorBuilderSecondStep { - - /** - * @var string - */ - private $selector; - - /** - * @var string|array - */ - private $locator; - - /** - * @param string $selector - * @param string|array $locator - */ - public function __construct($selector, $locator) { - $this->selector = $selector; - $this->locator = $locator; - } - - /** - * @param Locator|\Behat\Mink\Element\ElementInterface $ancestor - * @return LocatorBuilderThirdStep - */ - public function descendantOf($ancestor) { - return new LocatorBuilderThirdStep($this->selector, $this->locator, $ancestor); - } - - /** - * @param string $description - * @return Locator - */ - public function describedAs($description) { - return new Locator($description, $this->selector, $this->locator); - } -} - -class LocatorBuilderThirdStep { - - /** - * @var string - */ - private $selector; - - /** - * @var string|array - */ - private $locator; - - /** - * @var Locator|\Behat\Mink\Element\ElementInterface - */ - private $ancestor; - - /** - * @param string $selector - * @param string|array $locator - * @param Locator|\Behat\Mink\Element\ElementInterface $ancestor - */ - public function __construct($selector, $locator, $ancestor) { - $this->selector = $selector; - $this->locator = $locator; - $this->ancestor = $ancestor; - } - - /** - * @param string $description - * @return Locator - */ - public function describedAs($description) { - return new Locator($description, $this->selector, $this->locator, $this->ancestor); - } -} diff --git a/tests/acceptance/features/core/NextcloudTestServerContext.php b/tests/acceptance/features/core/NextcloudTestServerContext.php deleted file mode 100644 index 682811248e1..00000000000 --- a/tests/acceptance/features/core/NextcloudTestServerContext.php +++ /dev/null @@ -1,127 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -use Behat\Behat\Context\Context; -use Behat\Behat\Hook\Scope\BeforeScenarioScope; - -/** - * Behat context to run each scenario against a clean Nextcloud server. - * - * Before each scenario is run, this context sets up a fresh Nextcloud server - * with predefined data and configuration. Thanks to this every scenario is - * independent from the others and they all know the initial state of the - * server. - * - * This context is expected to be used along with RawMinkContext contexts (or - * subclasses). As the server address can be different for each scenario, this - * context automatically sets the "base_url" parameter of all its sibling - * RawMinkContexts; just add NextcloudTestServerContext to the context list of a - * suite in "behat.yml". - * - * The Nextcloud server is provided by an instance of NextcloudTestServerHelper; - * its class must be specified when this context is created. By default, - * "NextcloudTestServerLocalBuiltInHelper" is used, although that can be - * customized using the "nextcloudTestServerHelper" parameter in "behat.yml". In - * the same way, the parameters to be passed to the helper when it is created - * can be customized using the "nextcloudTestServerHelperParameters" parameter, - * which is an array (without keys) with the value of the parameters in the same - * order as in the constructor of the helper class (by default, [ ]). - * - * Example of custom parameters in "behat.yml": - * default: - * suites: - * default: - * contexts: - * - NextcloudTestServerContext: - * nextcloudTestServerHelper: NextcloudTestServerCustomHelper - * nextcloudTestServerHelperParameters: - * - first-parameter-value - * - second-parameter-value - */ -class NextcloudTestServerContext implements Context { - - /** - * @var NextcloudTestServerHelper - */ - private $nextcloudTestServerHelper; - - /** - * Creates a new NextcloudTestServerContext. - * - * @param string $nextcloudTestServerHelper the name of the - * NextcloudTestServerHelper implementing class to use. - * @param array $nextcloudTestServerHelperParameters the parameters for the - * constructor of the $nextcloudTestServerHelper class. - */ - public function __construct($nextcloudTestServerHelper = "NextcloudTestServerLocalBuiltInHelper", - $nextcloudTestServerHelperParameters = [ ]) { - $nextcloudTestServerHelperClass = new ReflectionClass($nextcloudTestServerHelper); - - if ($nextcloudTestServerHelperParameters === null) { - $nextcloudTestServerHelperParameters = []; - } - - $this->nextcloudTestServerHelper = $nextcloudTestServerHelperClass->newInstanceArgs($nextcloudTestServerHelperParameters); - } - - /** - * @BeforeScenario - * - * Sets up the Nextcloud test server before each scenario. - * - * Once the Nextcloud test server is set up, the "base_url" parameter of the - * sibling RawMinkContexts is set to the base URL of the Nextcloud test - * server. - * - * @param \Behat\Behat\Hook\Scope\BeforeScenarioScope $scope the - * BeforeScenario hook scope. - * @throws \Exception if the Nextcloud test server can not be set up or its - * base URL got. - */ - public function setUpNextcloudTestServer(BeforeScenarioScope $scope) { - $this->nextcloudTestServerHelper->setUp(); - - $this->setBaseUrlInSiblingRawMinkContexts($scope, $this->nextcloudTestServerHelper->getBaseUrl()); - } - - /** - * @AfterScenario - * - * Cleans up the Nextcloud test server after each scenario. - * - * @throws \Exception if the Nextcloud test server can not be cleaned up. - */ - public function cleanUpNextcloudTestServer() { - $this->nextcloudTestServerHelper->cleanUp(); - } - - private function setBaseUrlInSiblingRawMinkContexts(BeforeScenarioScope $scope, $baseUrl) { - $environment = $scope->getEnvironment(); - - foreach ($environment->getContexts() as $context) { - if ($context instanceof Behat\MinkExtension\Context\RawMinkContext) { - $context->setMinkParameter("base_url", $baseUrl); - } - } - } -} diff --git a/tests/acceptance/features/core/NextcloudTestServerHelper.php b/tests/acceptance/features/core/NextcloudTestServerHelper.php deleted file mode 100644 index cd50616e34c..00000000000 --- a/tests/acceptance/features/core/NextcloudTestServerHelper.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -/** - * Interface for classes that manage a Nextcloud server during acceptance tests. - * - * A NextcloudTestServerHelper takes care of setting up a Nextcloud server to be - * used in acceptance tests through its "setUp" method. It does not matter - * wheter the server is a fresh new server just started or an already running - * server; in any case, the state of the server must comply with the initial - * state expected by the tests (like having performed the Nextcloud installation - * or having an admin user with certain password). - * - * As the IP address and thus its the base URL of the server is not known - * beforehand, the NextcloudTestServerHelper must provide it through its - * "getBaseUrl" method. Note that this must be the base URL from the point of - * view of the Selenium server, which may be a different value than the base URL - * from the point of view of the acceptance tests themselves. - * - * Once the Nextcloud test server is no longer needed the "cleanUp" method will - * be called; depending on how the Nextcloud test server was set up it may not - * need to do anything. - * - * All the methods throw an exception if they fail to execute; as, due to the - * current use of this interface, it is just a warning for the test runner and - * nothing to be explicitly catched a plain base Exception is used. - */ -interface NextcloudTestServerHelper { - - /** - * Sets up the Nextcloud test server. - * - * @throws \Exception if the Nextcloud test server can not be set up. - */ - public function setUp(); - - /** - * Cleans up the Nextcloud test server. - * - * @throws \Exception if the Nextcloud test server can not be cleaned up. - */ - public function cleanUp(); - - /** - * Returns the base URL of the Nextcloud test server (from the point of view - * of the Selenium server). - * - * @return string the base URL of the Nextcloud test server. - * @throws \Exception if the base URL can not be determined. - */ - public function getBaseUrl(); -} diff --git a/tests/acceptance/features/core/NextcloudTestServerLocalApacheHelper.php b/tests/acceptance/features/core/NextcloudTestServerLocalApacheHelper.php deleted file mode 100644 index 36cffc325dc..00000000000 --- a/tests/acceptance/features/core/NextcloudTestServerLocalApacheHelper.php +++ /dev/null @@ -1,129 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -/** - * Helper to manage a Nextcloud test server started directly by the acceptance - * tests themselves using the Apache web server. - * - * The Nextcloud test server is executed using the Apache web server; the - * default Apache directory is expected to have been set to the root directory - * of the Nextcloud server (for example, by linking "var/www/html" to it); in - * any case, note that the acceptance tests must be run from the acceptance - * tests directory. The "setUp" method resets the Nextcloud server to its - * initial state and starts it, while the "cleanUp" method stops it. To be able - * to reset the Nextcloud server to its initial state a Git repository must be - * provided in the root directory of the Nextcloud server; the last commit in - * that Git repository must provide the initial state for the Nextcloud server - * expected by the acceptance tests. When the Nextcloud server is reset the - * owner of "apps", "config" and "data" must be set to the user that Apache - * server is run as; it is assumed that Apache is run as "www-data". - * - * The Nextcloud server is available at "$nextcloudServerDomain", which can be - * optionally specified when the NextcloudTestServerLocalApacheHelper is - * created; if no value is given "127.0.0.1" is used by default. In any case, - * the value of "$nextcloudServerDomain" must be seen as a trusted domain by the - * Nextcloud server (which would be the case for "127.0.0.1" if it was installed - * by running "occ maintenance:install"). The base URL to access the Nextcloud - * server can be got from "getBaseUrl". - */ -class NextcloudTestServerLocalApacheHelper implements NextcloudTestServerHelper { - - /** - * @var string - */ - private $nextcloudServerDomain; - - /** - * Creates a new NextcloudTestServerLocalApacheHelper. - */ - public function __construct($nextcloudServerDomain = "127.0.0.1") { - $this->nextcloudServerDomain = $nextcloudServerDomain; - } - - /** - * Sets up the Nextcloud test server. - * - * It resets the Nextcloud test server restoring its last saved Git state - * and then waits for the Nextcloud test server to start again; if the - * server can not be reset or if it does not start again after some time an - * exception is thrown (as it is just a warning for the test runner and - * nothing to be explicitly catched a plain base Exception is used). - * - * @throws \Exception if the Nextcloud test server can not be reset or - * started again. - */ - public function setUp(): void { - // Ensure that previous Apache server is not running (as cleanUp may not - // have been called). - $this->stopApacheServer(); - - $this->execOrException("cd ../../ && git reset --hard HEAD"); - $this->execOrException("cd ../../ && git clean -d --force"); - $this->execOrException("cd ../../ && chown -R www-data:www-data apps config data"); - - $this->execOrException("service apache2 start"); - - $timeout = 60; - if (!Utils::waitForServer($this->getBaseUrl(), $timeout)) { - throw new Exception("Nextcloud test server could not be started"); - } - } - - /** - * Cleans up the Nextcloud test server. - * - * It stops the running Nextcloud test server, if any. - */ - public function cleanUp() { - $this->stopApacheServer(); - } - - /** - * Returns the base URL of the Nextcloud test server. - * - * @return string the base URL of the Nextcloud test server. - */ - public function getBaseUrl() { - return "http://" . $this->nextcloudServerDomain . "/index.php"; - } - - /** - * Executes the given command, throwing an Exception if it fails. - * - * @param string $command the command to execute. - * @throws \Exception if the command fails to execute. - */ - private function execOrException($command) { - exec($command . " 2>&1", $output, $returnValue); - if ($returnValue != 0) { - throw new Exception("'$command' could not be executed: " . implode("\n", $output)); - } - } - - /** - * Stops the Apache server started in setUp, if any. - */ - private function stopApacheServer() { - $this->execOrException("service apache2 stop"); - } -} diff --git a/tests/acceptance/features/core/NextcloudTestServerLocalBuiltInHelper.php b/tests/acceptance/features/core/NextcloudTestServerLocalBuiltInHelper.php deleted file mode 100644 index ce81881c9c4..00000000000 --- a/tests/acceptance/features/core/NextcloudTestServerLocalBuiltInHelper.php +++ /dev/null @@ -1,143 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -/** - * Helper to manage a Nextcloud test server started directly by the acceptance - * tests themselves using the PHP built-in web server. - * - * The Nextcloud test server is executed using the PHP built-in web server - * directly from the grandparent directory of the acceptance tests directory - * (that is, the root directory of the Nextcloud server); note that the - * acceptance tests must be run from the acceptance tests directory. The "setUp" - * method resets the Nextcloud server to its initial state and starts it, while - * the "cleanUp" method stops it. To be able to reset the Nextcloud server to - * its initial state a Git repository must be provided in the root directory of - * the Nextcloud server; the last commit in that Git repository must provide the - * initial state for the Nextcloud server expected by the acceptance tests. - * - * The Nextcloud server is available at "$nextcloudServerDomain", which can be - * optionally specified when the NextcloudTestServerLocalBuiltInHelper is - * created; if no value is given "127.0.0.1" is used by default. In any case, - * the value of "$nextcloudServerDomain" must be seen as a trusted domain by the - * Nextcloud server (which would be the case for "127.0.0.1" if it was installed - * by running "occ maintenance:install"). The base URL to access the Nextcloud - * server can be got from "getBaseUrl". - */ -class NextcloudTestServerLocalBuiltInHelper implements NextcloudTestServerHelper { - - /** - * @var string - */ - private $nextcloudServerDomain; - - /** - * @var string - */ - private $phpServerPid; - - /** - * Creates a new NextcloudTestServerLocalBuiltInHelper. - */ - public function __construct($nextcloudServerDomain = "127.0.0.1") { - $this->nextcloudServerDomain = $nextcloudServerDomain; - - $this->phpServerPid = ""; - } - - /** - * Sets up the Nextcloud test server. - * - * It resets the Nextcloud test server restoring its last saved Git state - * and then waits for the Nextcloud test server to start again; if the - * server can not be reset or if it does not start again after some time an - * exception is thrown (as it is just a warning for the test runner and - * nothing to be explicitly catched a plain base Exception is used). - * - * @throws \Exception if the Nextcloud test server can not be reset or - * started again. - */ - public function setUp(): void { - // Ensure that previous PHP server is not running (as cleanUp may not - // have been called). - $this->killPhpServer(); - - $this->execOrException("cd ../../ && git reset --hard HEAD"); - $this->execOrException("cd ../../ && git clean -d --force"); - - // execOrException is not used because the server is started in the - // background, so the command will always succeed even if the server - // itself fails. - $this->phpServerPid = exec("php -S " . $this->nextcloudServerDomain . ":80 -t ../../ >/dev/null 2>&1 & echo $!"); - - $timeout = 60; - if (!Utils::waitForServer($this->getBaseUrl(), $timeout)) { - throw new Exception("Nextcloud test server could not be started"); - } - } - - /** - * Cleans up the Nextcloud test server. - * - * It kills the running Nextcloud test server, if any. - */ - public function cleanUp() { - $this->killPhpServer(); - } - - /** - * Returns the base URL of the Nextcloud test server. - * - * @return string the base URL of the Nextcloud test server. - */ - public function getBaseUrl() { - return "http://" . $this->nextcloudServerDomain . "/index.php"; - } - - /** - * Executes the given command, throwing an Exception if it fails. - * - * @param string $command the command to execute. - * @throws \Exception if the command fails to execute. - */ - private function execOrException($command) { - exec($command . " 2>&1", $output, $returnValue); - if ($returnValue != 0) { - throw new Exception("'$command' could not be executed: " . implode("\n", $output)); - } - } - - /** - * Kills the PHP built-in web server started in setUp, if any. - */ - private function killPhpServer() { - if ($this->phpServerPid == "") { - return; - } - - // execOrException is not used because the PID may no longer exist when - // trying to kill it. - exec("kill " . $this->phpServerPid); - - $this->phpServerPid = ""; - } -} diff --git a/tests/acceptance/features/core/NoSuchElementException.php b/tests/acceptance/features/core/NoSuchElementException.php deleted file mode 100644 index dca884556ad..00000000000 --- a/tests/acceptance/features/core/NoSuchElementException.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -/** - * Exception to signal that the element looked for could not be found. - */ -class NoSuchElementException extends \Exception { - - /** - * @param string $message - * @param null|\Exception $previous - */ - public function __construct($message, \Exception $previous = null) { - parent::__construct($message, 0, $previous); - } -} diff --git a/tests/acceptance/features/core/Utils.php b/tests/acceptance/features/core/Utils.php deleted file mode 100644 index 1650df4f824..00000000000 --- a/tests/acceptance/features/core/Utils.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php - -/** - * - * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com) - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -class Utils { - - /** - * Waits at most $timeout seconds for the given condition to be true, - * checking it again every $timeoutStep seconds. - * - * Note that the timeout is no longer taken into account when a condition is - * met; that is, true will be returned if the condition is met before the - * timeout expires, but also if it is met exactly when the timeout expires. - * For example, even if the timeout is set to 0, the condition will be - * checked at least once, and true will be returned in that case if the - * condition was met. - * - * @param \Closure $conditionCallback the condition to wait for, as a - * function that returns a boolean. - * @param float $timeout the number of seconds (decimals allowed) to wait at - * most for the condition to be true. - * @param float $timeoutStep the number of seconds (decimals allowed) to - * wait before checking the condition again. - * @return boolean true if the condition is met before (or exactly when) the - * timeout expires, false otherwise. - */ - public static function waitFor($conditionCallback, $timeout, $timeoutStep) { - $elapsedTime = 0; - $conditionMet = false; - - while (!($conditionMet = $conditionCallback()) && $elapsedTime < $timeout) { - usleep($timeoutStep * 1000000); - - $elapsedTime += $timeoutStep; - } - - return $conditionMet; - } - - /** - * Waits at most $timeout seconds for the server at the given URL to be up, - * checking it again every $timeoutStep seconds. - * - * Note that it does not verify whether the URL returns a valid HTTP status - * or not; it simply checks that the server at the given URL is accessible. - * - * @param string $url the URL for the server to check. - * @param float $timeout the number of seconds (decimals allowed) to wait at - * most for the server. - * @param float $timeoutStep the number of seconds (decimals allowed) to - * wait before checking the server again; by default, 0.5 seconds. - * @return boolean true if the server was found, false otherwise. - */ - public static function waitForServer($url, $timeout, $timeoutStep = 0.5) { - $isServerUpCallback = function () use ($url) { - $curlHandle = curl_init($url); - - // Returning the transfer as the result of curl_exec prevents the - // transfer from being written to the output. - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); - - $transfer = curl_exec($curlHandle); - - curl_close($curlHandle); - - return $transfer !== false; - }; - return self::waitFor($isServerUpCallback, $timeout, $timeoutStep); - } -} diff --git a/tests/acceptance/features/header.feature b/tests/acceptance/features/header.feature deleted file mode 100644 index df9d8045b8b..00000000000 --- a/tests/acceptance/features/header.feature +++ /dev/null @@ -1,88 +0,0 @@ -@apache -Feature: header - - Scenario: admin users can see admin-level items in the Settings menu - Given I am logged in as the admin - When I open the Settings menu - Then I see that the Settings menu is shown - And I see that the Settings menu has only 6 items - And I see that the "Set status" item in the Settings menu is shown - And I see that the "Settings" item in the Settings menu is shown - And I see that the "Apps" item in the Settings menu is shown - And I see that the "Users" item in the Settings menu is shown - And I see that the "Help" item in the Settings menu is shown - And I see that the "Log out" item in the Settings menu is shown - - Scenario: normal users can see basic items in the Settings menu - Given I am logged in - When I open the Settings menu - Then I see that the Settings menu is shown - And I see that the Settings menu has only 4 items - And I see that the "Set status" item in the Settings menu is shown - And I see that the "Settings" item in the Settings menu is shown - And I see that the "Help" item in the Settings menu is shown - And I see that the "Log out" item in the Settings menu is shown - - Scenario: other users are seen in the contacts menu - Given I am logged in as the admin - When I open the Contacts menu - Then I see that the Contacts menu is shown - And I see that the contact "user0" in the Contacts menu is shown - And I see that the contact "admin" in the Contacts menu is not shown - - Scenario: users from other groups are not seen in the contacts menu when autocompletion is restricted within the same group - Given I am logged in as the admin - And I visit the settings page - And I open the "Sharing" section of the "Administration" group - And I enable restricting username autocompletion to groups - And I see that username autocompletion is restricted to groups - When I open the Contacts menu - Then I see that the Contacts menu is shown - And I see that the contact "user0" in the Contacts menu is not shown - And I see that the contact "admin" in the Contacts menu is not shown - - Scenario: just added users are seen in the contacts menu - Given I am logged in as the admin - And I open the User settings - And I click the New user button - And I see that the new user form is shown - And I create user user1 with password 123456acb - And I see that the list of users contains the user user1 - When I open the Contacts menu - Then I see that the Contacts menu is shown - And I see that the contact "user0" in the Contacts menu is shown - And I see that the contact "user1" in the Contacts menu is shown - And I see that the contact "admin" in the Contacts menu is not shown - - Scenario: search for other users in the contacts menu - Given I am logged in as the admin - And I open the User settings - And I click the New user button - And I see that the new user form is shown - And I create user user1 with password 123456acb - And I see that the list of users contains the user user1 - And I open the Contacts menu - And I see that the Contacts menu is shown - And I see that the contact "user0" in the Contacts menu is shown - And I see that the contact "user1" in the Contacts menu is shown - And I see that the Contacts menu search input is shown - When I search for the user "user0" - # First check that "user1" is no longer shown to ensure that the search was - # made; checking that "user0" is shown or that "admin" is not shown does not - # guarantee that (as they were already being shown and not being shown, - # respectively, before the search started). - Then I see that the contact "user1" in the Contacts menu is eventually not shown - And I see that the contact "user0" in the Contacts menu is shown - And I see that the contact "admin" in the Contacts menu is not shown - - Scenario: search for unknown users in the contacts menu - Given I am logged in as the admin - And I open the Contacts menu - And I see that the Contacts menu is shown - And I see that the contact "user0" in the Contacts menu is shown - And I see that the Contacts menu search input is shown - When I search for the user "unknownuser" - Then I see that the no results message in the Contacts menu is shown - And I see that the contact "user0" in the Contacts menu is not shown - And I see that the contact "admin" in the Contacts menu is not shown - diff --git a/tests/acceptance/features/login.feature b/tests/acceptance/features/login.feature deleted file mode 100644 index 047d7398d6c..00000000000 --- a/tests/acceptance/features/login.feature +++ /dev/null @@ -1,55 +0,0 @@ -@apache -Feature: login - - Scenario: log in with valid user and password - Given I visit the Home page - When I log in with user user0 and password 123456acb - Then I see that the current page is the Files app - - Scenario: try to log in with valid user and invalid password - Given I visit the Home page - When I log in with user user0 and password 654321 - Then I see that the current page is the Login page - And I see that a wrong password message is shown - -# Scenario: log in with valid user and invalid password once fixed by admin -# Given I act as John -# And I can not log in with user user0 and password 654231 -# When I act as Jane -# And I am logged in as the admin -# And I open the User settings -# And I set the password for user0 to 654321 -# And I act as John -# And I log in with user user0 and password 654321 -# Then I see that the current page is the Files app - - Scenario: try to log in with invalid user - Given I visit the Home page - When I log in with user unknownUser and password 123456acb - Then I see that the current page is the Login page - And I see that a wrong password message is shown - - Scenario: try to log in as disabled user - Given I visit the Home page - When I log in with user disabledUser and password 123456acb - Then I see that the current page is the Login page - And I see that the disabled user message is shown - - Scenario: log in with invalid user once fixed by admin - Given I act as John - And I can not log in with user unknownUser and password 123456acb - When I act as Jane - And I am logged in as the admin - And I open the User settings - And I click the New user button - And I see that the new user form is shown - And I create user unknownUser with password 123456acb - And I see that the list of users contains the user unknownUser - And I act as John - And I log in with user unknownUser and password 123456acb - Then I see that the current page is the Files app - - Scenario: log out - Given I am logged in - When I log out - Then I see that the current page is the Login page diff --git a/tests/acceptance/features/users.feature b/tests/acceptance/features/users.feature deleted file mode 100644 index 2b6597b7283..00000000000 --- a/tests/acceptance/features/users.feature +++ /dev/null @@ -1,172 +0,0 @@ -@apache -Feature: users - - Scenario: create a new user - Given I act as Jane - And I am logged in as the admin - And I open the User settings - And I click the New user button - And I see that the new user form is shown - When I create user unknownUser with password 123456acb - Then I see that the list of users contains the user unknownUser - - Scenario: create a new user with a custom display name - Given I am logged in as the admin - And I open the User settings - When I click the New user button - And I see that the new user form is shown - And I set the user name for the new user to "test" - And I set the display name for the new user to "Test display name" - And I set the password for the new user to "123456acb" - And I create the new user - Then I see that the list of users contains the user "test" -# And I see that the display name for the user "test" is "Test display name" - - Scenario: delete a user - Given I act as Jane - And I am logged in as the admin - And I open the User settings - And I see that the list of users contains the user user0 - And I open the actions menu for the user user0 - And I see that the "Delete user" action in the user0 actions menu is shown - When I click the "Delete user" action in the user0 actions menu - Then I see that the list of users does not contains the user user0 - - Scenario: disable a user - Given I act as Jane - And I am logged in as the admin - And I open the User settings - And I see that the list of users contains the user user0 - And I open the actions menu for the user user0 - And I see that the "Disable user" action in the user0 actions menu is shown - When I click the "Disable user" action in the user0 actions menu - Then I see that the list of users does not contains the user user0 - When I open the "Disabled users" section - Then I see that the list of users contains the user user0 - - Scenario: users navigation without disabled users - Given I act as Jane - And I am logged in as the admin - And I open the User settings - And I open the "Disabled users" section - And I see that the list of users contains the user disabledUser - And I open the actions menu for the user disabledUser - And I see that the "Enable user" action in the disabledUser actions menu is shown - When I click the "Enable user" action in the disabledUser actions menu - Then I see that the section "Disabled users" is not shown - # check again after reloading the settings - When I open the User settings - Then I see that the section "Disabled users" is not shown - - Scenario: assign user to a group - Given I act as Jane - And I am logged in as the admin - And I open the User settings - And I see that the list of users contains the user user0 - When I toggle the edit mode for the user user0 - Then I see that the edit mode is on for user user0 - # disabled because we need the TAB patch: - # https://github.com/minkphp/MinkSelenium2Driver/pull/244 - # When I assign the user user0 to the group admin - # Then I see that the section Admins is shown - # And I see that the section Admins has a count of 2 - - Scenario: create and delete a group - Given I act as Jane - And I am logged in as the admin - And I open the User settings - And I see that the list of users contains the user user0 - # disabled because we need the TAB patch: - # https://github.com/minkphp/MinkSelenium2Driver/pull/244 - # And I assign the user user0 to the group Group1 - # And I see that the section Group1 is shown - # And I click the "icon-delete" button on the Group1 section - # And I see that the confirmation dialog is shown - # When I click the "Yes" button of the confirmation dialog - # Then I see that the section Group1 is not shown - - Scenario: delete an empty group - Given I act as Jane - And I am logged in as the admin - And I open the User settings - # disabled because we need the TAB patch: - # https://github.com/minkphp/MinkSelenium2Driver/pull/244 - # And I assign the user user0 to the group Group1 - # And I see that the section Group1 is shown - # And I withdraw the user user0 from the group Group1 - # And I see that the section Group1 does not have a count - # And I click the "icon-delete" button on the Group1 section - # And I see that the confirmation dialog is shown - # When I click the "Yes" button of the confirmation dialog - # Then I see that the section Group1 is not shown - - Scenario: change columns visibility - Given I act as Jane - And I am logged in as the admin - And I open the User settings - And I open the settings - And I see that the settings are opened - When I toggle the showLanguages checkbox in the settings - Then I see that the "Language" column is shown - When I toggle the showLastLogin checkbox in the settings - Then I see that the "Last login" column is shown - When I toggle the showStoragePath checkbox in the settings - Then I see that the "Storage location" column is shown - When I toggle the showUserBackend checkbox in the settings - Then I see that the "User backend" column is shown - -# Scenario: change display name -# Given I act as Jane -# And I am logged in as the admin -# And I open the User settings -# And I see that the list of users contains the user user0 -# And I see that the displayName of user0 is user0 -# When I set the displayName for user0 to user1 -# And I see that the displayName cell for user user0 is done loading -# Then I see that the displayName of user0 is user1 - - Scenario: change password - Given I act as Jane - And I am logged in as the admin - And I open the User settings - And I see that the list of users contains the user user0 - When I toggle the edit mode for the user user0 - Then I see that the edit mode is on for user user0 - And I see that the password of user0 is "" - When I set the password for user0 to 123456 - And I see that the password cell for user user0 is done loading - # password input is emptied on change - Then I see that the password of user0 is "" - -# Scenario: change email -# Given I act as Jane -# And I am logged in as the admin -# And I open the User settings -# And I see that the list of users contains the user user0 -# And I see that the mailAddress of user0 is "" -# When I set the mailAddress for user0 to "test@nextcloud.com" -# And I see that the mailAddress cell for user user0 is done loading -# Then I see that the mailAddress of user0 is "test@nextcloud.com" - - Scenario: change user quota - Given I act as Jane - And I am logged in as the admin - And I open the User settings - And I see that the list of users contains the user user0 - When I toggle the edit mode for the user user0 - Then I see that the edit mode is on for user user0 - And I see that the user quota of user0 is Unlimited - # disabled because we need the TAB patch: - # https://github.com/minkphp/MinkSelenium2Driver/pull/244 - # When I set the user user0 quota to 1GB - # And I see that the quota cell for user user0 is done loading - # Then I see that the user quota of user0 is "1 GB" - # When I set the user user0 quota to Unlimited - # And I see that the quota cell for user user0 is done loading - # Then I see that the user quota of user0 is Unlimited - # When I set the user user0 quota to 0 - # And I see that the quota cell for user user0 is done loading - # Then I see that the user quota of user0 is "0 B" - # When I set the user user0 quota to Default - # And I see that the quota cell for user user0 is done loading - # Then I see that the user quota of user0 is "Default quota" |