Skip to content

Commit

Permalink
Merge pull request #704 from plone/port-robot-tests
Browse files Browse the repository at this point in the history
Port robot tests
  • Loading branch information
petschki authored Oct 18, 2024
2 parents db8a1c1 + 73fbf4d commit bc5aed4
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 207 deletions.
1 change: 1 addition & 0 deletions news/698.tests
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
port robot tests [1letter]
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ a event
a file
[Arguments] ${title}
Go to ${PLONE_URL}/++add++File
Wait until page contains Add File
Input text name=form.widgets.title ${title}
Fill text name=form.widgets.title ${title}
Choose File name=form.widgets.file ${PATH_TO_TEST_FILES}/file.pdf
Wait For Then Click Element css=#form-buttons-save
Wait until page contains Item created
Click css=#form-buttons-save
Get text body contains Item created

a folder
[Arguments] ${title}
Expand All @@ -48,11 +47,10 @@ a folder
a image
[Arguments] ${title}
Go to ${PLONE_URL}/++add++Image
Wait until page contains Add Image
Input text name=form.widgets.title ${title}
Fill text name=form.widgets.title ${title}
Choose File name=form.widgets.image ${PATH_TO_TEST_FILES}/image.png
Wait For Then Click Element css=#form-buttons-save
Wait until page contains Item created error=Image could not be created.
Click css=#form-buttons-save
Get text body contains Item created

a link
[Arguments] ${title}
Expand All @@ -63,10 +61,9 @@ a link
a news item
[Arguments] ${title}
Go to ${PLONE_URL}/++add++News Item
Wait until page contains Add News Item
Input text name=form.widgets.IDublinCore.title ${title}
Wait For Then Click Element css=#form-buttons-save
Wait until page contains Item created
Fill text css=[name="form.widgets.IDublinCore.title"] ${title}
Click css=#form-buttons-save
Get text body contains Item created


# ----------------------------------------------------------------------------
Expand All @@ -75,17 +72,15 @@ a news item

the content area should contain
[Arguments] ${text}
Element Should Contain id=content ${text}
Get text id=content contains ${text}

the content area should not contain
[Arguments] ${text}
Element Should Not Contain id=content ${text}
Get Text id=content != ${text}

the collection should contain
[Arguments] ${title}
Wait until page contains element xpath=//*[@id='content-core']
Page should contain element //*[@id='content-core']//article//a[contains(text(), '${title}')] limit=1

Get Element //*[@id='content-core']//article//a[contains(text(), '${title}')]

the collection should not contain
[Arguments] ${title}
Expand All @@ -101,34 +96,22 @@ fill date field
Click Element xpath=//div[@data-fieldname="${fieldid}"]//div[contains(@class, 'picker__day')][contains(text(), "${day}")]

I set the criteria ${type} in row ${number} to the option '${label}'
[Documentation] A couple of times we shift the focus so the input sticks, and wait a bit,
... to make the test more stable.
${criteria_row} = Convert to String .querystring-criteria-wrapper:nth-child(${number})
Wait until page contains element css=${criteria_row} .querystring-criteria-${type} .select2-choice
Click Element css=${criteria_row} .querystring-criteria-${type} .select2-choice
Sleep 1.5
Set Focus To Element css=body
Wait until element is visible css=#select2-drop input
Input Text css=#select2-drop input ${label}
Sleep 1.5
Set Focus To Element css=body
Wait until element is visible css=#select2-drop .select2-match
Click Element css=#select2-drop .select2-match
Sleep 1.5
Set Focus To Element css=body
Click css=${criteria_row} .querystring-criteria-${type} .select2-choice
Fill Text css=#select2-drop input ${label}
Click xpath=//*[@id="select2-drop"]//*[@class="select2-match"]

I set the criteria ${type} in row ${number} to the options '${label}'
${criteria_row} = Convert to String .querystring-criteria-wrapper:nth-child(${number})
Wait until page contains element css=${criteria_row} .querystring-criteria-${type} .select2-choices
Click Element css=${criteria_row} .querystring-criteria-${type} .select2-choices
Wait until page contains element css=.select2-input.select2-focused
Input text css=.select2-input.select2-focused ${label}\n
# Click Element xpath=//div[@class='select2-result-label']/descendant-or-self::*[contains(text(), '${label}')]
${criteria_row} = Convert to String .querystring-criteria-wrapper:nth-child(1)
Click css=${criteria_row} .querystring-criteria-value .select2-choices
Fill text css=.select2-input.select2-focused ${label}\n
Click css=.select2-highlighted
Get text css=${criteria_row} .select2-search-choice contains ${label}
[Documentation] Chrome needs some more time
Sleep .1s

I set the criteria ${type} in row ${number} to the text '${label}'
${criteria_row} = Convert to String .querystring-criteria-wrapper:nth-child(${number})
Input text css=${criteria_row} .querystring-criteria-value input ${label}\t
[Documentation] Shift the focus so the input sticks, and wait a bit
Sleep 1.5
Set Focus To Element css=.querystring-sortreverse
Sleep 1.5
Fill text css=${criteria_row} .querystring-criteria-value input ${label}
Click css=.autotoc-level-1.active
Sleep 1s
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
# ============================================================================
# Tests for the Collection Creator Criterion
# ============================================================================
#
# $ bin/robot-server --reload-path src/plone.app.contenttypes plone.app.contenttypes.testing.PLONE_APP_CONTENTTYPES_ROBOT_TESTING
#
# $ bin/robot src/plone.app.contenttypes/plone/app/contenttypes/tests/robot/test_collection_creator_criterion.robot
#
# ============================================================================

*** Settings *****************************************************************

Resource plone/app/robotframework/keywords.robot
Resource plone/app/robotframework/saucelabs.robot
Resource plone/app/robotframework/selenium.robot
Resource keywords.txt
*** Settings ***

Resource plone/app/robotframework/browser.robot
Resource plone/app/robotframework/user.robot
Resource keywords.robot

Library Remote ${PLONE_URL}/RobotRemote

Test Setup Run Keywords Plone test setup
Test Teardown Run keywords Plone test teardown


*** Test cases ***************************************************************
*** Test cases ***

Scenario: Test Creator Criterions
Given a site owner document Site Owner Document
Expand All @@ -33,7 +21,7 @@ Scenario: Test Creator Criterions
And the collection should contain Site Owner Document


*** Keywords *****************************************************************
*** Keywords ***

a site owner document
[Arguments] ${title}
Expand All @@ -49,11 +37,10 @@ a test user document

I set the collection's creator criterion to the current logged in user
Go to ${PLONE_URL}/my-collection/edit
Wait until page contains Edit Collection
Get Text body contains Edit Collection

I set the criteria index in row 1 to the option 'Creator'
I set the criteria operator in row 1 to the option 'Current'

Sleep 1
Click Button Save
Wait until page contains Changes saved
Click "Save"
Get Text body contains Changes saved
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
# ============================================================================
# Tests for the Collection Location Criterion
# ============================================================================
#
# $ bin/robot-server --reload-path src/plone.app.contenttypes plone.app.contenttypes.testing.PLONE_APP_CONTENTTYPES_ROBOT_TESTING
#
# $ bin/robot src/plone.app.contenttypes/plone/app/contenttypes/tests/robot/test_collection_location_criterion.robot
#
# ============================================================================

*** Settings *****************************************************************

Resource plone/app/robotframework/keywords.robot
Resource plone/app/robotframework/saucelabs.robot
Resource plone/app/robotframework/selenium.robot
Resource keywords.txt
*** Settings ***

Resource plone/app/robotframework/browser.robot
Resource keywords.robot

Variables variables.py

Test Setup Run Keywords Plone test setup
Test Teardown Run keywords Plone test teardown


*** Test cases ***************************************************************
*** Test cases ***

Scenario: Test Relative Location Criterion
[Documentation] This sometimes fails with:
... Element locator 'css=#select2-drop input' did not match any elements after 30 seconds
Given I am logged in as site owner
And a document Document outside Folder
And a folder 'my-folder' with a document 'Document within Folder'
Expand All @@ -36,9 +22,6 @@ Scenario: Test Relative Location Criterion


Scenario: Test Absolute Location Criterion
[Documentation] This sometimes fails with:
... Element locator 'css=#select2-drop input' did not match any elements after 30 seconds
... Or with: Element 'id=content' should not contain text 'Document outside Folder' but it did.
Given I am logged in as site owner
And a document Document outside Folder
And a folder 'my-folder' with a document 'Document within Folder'
Expand All @@ -52,22 +35,22 @@ Scenario: Test Absolute Location Criterion

a folder '${folder-id}' with a document '${document-title}'
Go to ${PLONE_URL}/++add++Folder
Wait until page contains element name=form.widgets.IDublinCore.title
Input text name=form.widgets.IDublinCore.title ${folder-id}
Click Button Save
# Wait until page contains element name=form.widgets.IDublinCore.title
Fill text xpath=//*[@name="form.widgets.IDublinCore.title"] ${folder-id}
Click "Save"
Go to ${PLONE_URL}/${folder-id}/++add++Document
Wait until page contains element name=form.widgets.IDublinCore.title
Input text name=form.widgets.IDublinCore.title ${document-title}
Click Button Save
Wait until page contains Item created
# Wait until page contains element name=form.widgets.IDublinCore.title
Fill text xpath=//*[@name="form.widgets.IDublinCore.title"] ${document-title}
Click "Save"
# Wait until page contains Item created

I set the collection's location criterion to Advanced Mode
I set the criteria operator in row 1 to the option 'Advanced Mode'

I set the collection's relative location criterion to
[Arguments] ${criterion}
Go to ${PLONE_URL}/my-collection/edit
Wait until page contains Edit Collection
# Wait until page contains Edit Collection

I set the criteria index in row 1 to the option 'Location'

Expand All @@ -76,13 +59,13 @@ I set the collection's relative location criterion to
I set the criteria operator in row 1 to the option 'Relative path'
I set the criteria value in row 1 to the text '${criterion}'

Click Button Save
Wait until page contains Changes saved
Click "Save"
# Wait until page contains Changes saved

I set the collection's absolute location criterion to
[Arguments] ${criterion}
Go to ${PLONE_URL}/my-collection/edit
Wait until page contains Edit Collection
# Wait until page contains Edit Collection

I set the criteria index in row 1 to the option 'Location'

Expand All @@ -91,5 +74,5 @@ I set the collection's absolute location criterion to
I set the criteria operator in row 1 to the option 'Absolute path'
I set the criteria value in row 1 to the text '${criterion}'

Click Button Save
Wait until page contains Changes saved
Click "Save"
# Wait until page contains Changes saved
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
# ============================================================================
# Tests for the Collection Type Criterion
# ============================================================================
#
# $ bin/robot-server --reload-path src/plone.app.contenttypes plone.app.contenttypes.testing.PLONE_APP_CONTENTTYPES_ROBOT_TESTING
#
# $ bin/robot src/plone.app.contenttypes/plone/app/contenttypes/tests/robot/test_collection_review_state_criterion.robot
#
# ============================================================================

*** Settings *****************************************************************

Resource plone/app/robotframework/keywords.robot
Resource plone/app/robotframework/saucelabs.robot
Resource plone/app/robotframework/selenium.robot
Resource keywords.txt
*** Settings ***

Resource plone/app/robotframework/browser.robot
Resource keywords.robot

Variables variables.py

Test Setup Run Keywords Plone test setup
Test Teardown Run keywords Plone test teardown


*** Test cases ***************************************************************
*** Test cases ***

Scenario: Test Review state Criterion
Given I am logged in as site owner
Expand All @@ -31,7 +21,7 @@ Scenario: Test Review state Criterion
And the collection should not contain Published Document


*** Keywords *****************************************************************
*** Keywords ***

a published document
[Arguments] ${title}
Expand All @@ -45,12 +35,9 @@ a private document
I set the collection's review state criterion to
[Arguments] ${criterion}
Go to ${PLONE_URL}/my-collection/edit
Wait until page contains Edit Collection

I set the criteria index in row 1 to the option 'Review state'
I set the criteria operator in row 1 to the option 'Any'
I set the criteria value in row 1 to the options '${criterion}'

Sleep 1
Click Button Save
Wait until page contains Changes saved
Click "Save"
Loading

0 comments on commit bc5aed4

Please sign in to comment.