Skip to content

Commit

Permalink
Merge pull request #460 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 58ba7ad + f0172ce commit bab2212
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 136 deletions.
1 change: 1 addition & 0 deletions news/459.tests
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
port robot tests to use the browser library [@1letter]
11 changes: 8 additions & 3 deletions src/plone/app/multilingual/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from plone.dexterity.utils import iterSchemataForType
from plone.rfc822 import constructMessageFromSchemata
from plone.rfc822 import initializeObjectFromSchemata
from plone.testing import z2
from plone.testing.layer import Layer
from plone.testing.zope import WSGI_SERVER_FIXTURE
from plone.uuid.interfaces import IUUID
from Products.CMFCore.utils import getToolByName
from zope.configuration import xmlconfig
Expand Down Expand Up @@ -156,7 +157,7 @@ def setUpPloneSite(self, portal):
)


class MultipleLanguagesLayer(z2.Layer):
class MultipleLanguagesLayer(Layer):
defaultBases = (PLONE_APP_MULTILINGUAL_PRESET_FIXTURE,)


Expand Down Expand Up @@ -257,7 +258,11 @@ def create_translation(self, *args, **kwargs):
)

PLONE_APP_MULTILINGUAL_ROBOT_TESTING = FunctionalTesting(
bases=(MULTIPLE_LANGUAGES_LAYER, REMOTE_LIBRARY_BUNDLE_FIXTURE, z2.ZSERVER_FIXTURE),
bases=(
MULTIPLE_LANGUAGES_LAYER,
REMOTE_LIBRARY_BUNDLE_FIXTURE,
WSGI_SERVER_FIXTURE,
),
name="plone.app.multilingual:Robot",
)

Expand Down
86 changes: 27 additions & 59 deletions src/plone/app/multilingual/tests/robot/test_add_translation.robot
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
*** Settings ***

Resource plone/app/robotframework/keywords.robot
Resource plone/app/robotframework/saucelabs.robot
Resource plone/app/robotframework/selenium.robot
Resource Products/CMFPlone/tests/robot/keywords.robot
Resource plone/app/robotframework/browser.robot

Library Remote ${PLONE_URL}/RobotRemote
Library Remote ${PLONE_URL}/RobotRemote

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

*** Test Cases ***

Expand All @@ -24,74 +21,45 @@ Scenario: As an editor I can add new translation

*** Keywords ***

Setup test browser
Set Selenium speed 0.5s
Open test browser
Set window size 1200 900

# Given

a site owner
Enable autologin as Manager
Enable autologin as Manager

a document in English
Create content type=Document
... container=/${PLONE_SITE_ID}/en/
... id=an-english-document
... title=An English Document
Create content type=Document container=/${PLONE_SITE_ID}/en/ id=an-english-document title=An English Document

a document in Catalan
Create content type=Document
... container=/${PLONE_SITE_ID}/ca/
... id=a-catalan-document
... title=A Catalan Document
Create content type=Document container=/${PLONE_SITE_ID}/ca/ id=a-catalan-document title=A Catalan Document

# When

I view the Catalan document
Go to ${PLONE_URL}/ca/a-catalan-document
Wait until page contains A Catalan Document
Go to ${PLONE_URL}/ca/a-catalan-document
Get Element //h1[1][text()='A Catalan Document']

I link the document in English as a translation
Page should contain element css=#plone-contentmenu-multilingual a
Capture page screenshot
Element should be visible css=#plone-contentmenu-multilingual a
Click Element css=#plone-contentmenu-multilingual a
Wait until page contains element css=#_modify_translations
Wait until element is visible css=#_modify_translations

Click Element css=#_modify_translations
Given patterns are loaded
Wait until page contains element css=#translations-overview .connectTranslationAction

Click Element css=#translations-overview .connectTranslationAction
Wait until page contains element css=.select2-choices
Wait until element is visible css=.select2-choices
Click Element css=#formfield-form-widgets-content .pat-relateditems-container button.mode.search
Input Text css=#formfield-form-widgets-content .select2-input en
Wait until page contains element xpath=(//span[contains(., 'An English Document')])
Wait until element is visible xpath=(//span[contains(., 'An English Document')])
Click Element xpath=(//span[contains(., 'An English Document')])
Wait until page contains An English Document

# We need a complicated xpath, because for some reason a button with this id is there twice.
# The first one is hidden.
Click Element xpath=(//*[contains(@class, 'modal-footer')]//button[@id='form-buttons-connect_translation'])
Wait until page contains element xpath=(//h3[@class="translationTitle"])
Sleep 5
Wait until element is visible xpath=(//h3[@class="translationTitle"])
Set Focus To Element xpath=(//*[@id="translations-overview"]//a[contains(@href,"a-catalan-document")])
Click Element xpath=(//*[@id="translations-overview"]//a[contains(text(),'/plone/ca/a-catalan-document')])
Wait until page contains A Catalan Document
Get Element //li[@id="plone-contentmenu-multilingual"]/a
Take Screenshot
Get Element States //li[@id="plone-contentmenu-multilingual"]/a contains visible
Click //li[@id="plone-contentmenu-multilingual"]/a
Get Element States //a[@id="_modify_translations"] contains visible
Click //a[@id="_modify_translations"]
Click //table[@id="translations-overview"]/tbody/tr[1]/td[3]/a[contains(@class,"connectTranslationAction")]
Click //div[@id="formfield-form-widgets-content"]//div[contains(@class,"pat-relateditems-container")]//button[contains(@class,"mode") and contains(@class,"search")]
Type Text //div[@id="formfield-form-widgets-content"]//input[contains(@class,"select2-input")] en
Click //span[contains(., 'An English Document')]
Click //*[contains(@class, 'modal-footer')]//button[@id='form-buttons-connect_translation']
Get Text //table[@id="translations-overview"]/tbody/tr[1]/td[2]/h3[@class="translationTitle"] should be An English Document
Click //table[@id="translations-overview"]//a[contains(text(),'/plone/ca/a-catalan-document')]
Get Text //*[@id="content"]/header/h1 should be A Catalan Document

I switch to English
Click Link xpath=//a[@title='English']
Wait until page contains An English Document
Click //a[@title='English']
Get Element //h1[1][contains(text(),'An English Document')]

# Then

I can view the document in English
Wait until page contains element
... xpath=//h1[1][contains(text(),'English Document')]
Wait until page contains element
... xpath=//ul[@id='portal-languageselector']/li[contains(@class, 'currentLanguage')]/a[@title='English']
Get Element //h1[1][contains(text(),'English Document')]
Get Element //ul[@id='portal-languageselector']/li[contains(@class, 'currentLanguage')]/a[@title='English']
63 changes: 30 additions & 33 deletions src/plone/app/multilingual/tests/robot/test_schemaeditor.robot
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
*** Settings ***

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

Library Remote ${PLONE_URL}/RobotRemote
Library Remote ${PLONE_URL}/RobotRemote

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


*** Test Cases ***
*** Test cases ***

Scenario: As a site owner I can see language independent field setting
Given a site owner
Expand Down Expand Up @@ -42,54 +39,54 @@ Scenario: As a site owner I can unset field from being language independent
# Given

a site owner
Enable autologin as Manager
Enable autologin as Manager

a dexterity content type with a TTW field
Create content type Custom
Go to ${PLONE_URL}/dexterity-types/Custom/@@fields
Wait until page contains element css=body.template-fields
Create content type Custom
Go to ${PLONE_URL}/dexterity-types/Custom/@@fields
Get Element //body[contains(@class, "template-fields")]

a dexterity content type field settings form
Go to ${PLONE_URL}/dexterity-types/Custom/@@fields
Go to ${PLONE_URL}/dexterity-types/Custom/custom
Wait until page contains Language independent field
Go to ${PLONE_URL}/dexterity-types/Custom/@@fields
Go to ${PLONE_URL}/dexterity-types/Custom/custom
Get Text //div[@id="form-widgets-IFieldLanguageIndependent-languageindependent"] contains Language independent field

a dexterity content type with a language independent TTW field
Create content type Custom
Set field language independent Custom custom on
Go to ${PLONE_URL}/dexterity-types/Custom/@@fields
Wait until page contains element css=body.template-fields
Create content type Custom
Set field language independent Custom custom on
Go to ${PLONE_URL}/dexterity-types/Custom/@@fields
Get Element //body[contains(@class, "template-fields")]

# When

I open the field settings
Go to ${PLONE_URL}/dexterity-types/Custom/custom
Page should contain Language independent field
Go to ${PLONE_URL}/dexterity-types/Custom/custom
Get Text //div[@id="form-widgets-IFieldLanguageIndependent-languageindependent"] contains Language independent field

I select the language independent field setting
Select checkbox form-widgets-IFieldLanguageIndependent-languageindependent-0
Checkbox should be selected form-widgets-IFieldLanguageIndependent-languageindependent-0
Check Checkbox //input[@id="form-widgets-IFieldLanguageIndependent-languageindependent-0"]
Get Checkbox State //input[@id="form-widgets-IFieldLanguageIndependent-languageindependent-0"] == checked

I save the form
Wait until page contains element css=#form-buttons-save
Click button css=#form-buttons-save
Wait until keyword succeeds 1 10 Element should not be visible .plone-modal-wrapper
Get Element //*[@id="form-buttons-save"]
Click //*[@id="form-buttons-save"]
Get Element Count //div[contains(@class,"plone-modal-wrapper")] should be 0

I open the form again
Go to ${PLONE_URL}/dexterity-types/Custom/custom
Wait until page contains Language independent field
Go to ${PLONE_URL}/dexterity-types/Custom/custom
Get Text //div[@id="form-widgets-IFieldLanguageIndependent-languageindependent"] contains Language independent field

I unselect the language independent field setting
Unselect checkbox form-widgets-IFieldLanguageIndependent-languageindependent-0
Checkbox should not be selected form-widgets-IFieldLanguageIndependent-languageindependent-0
Uncheck Checkbox //input[@id="form-widgets-IFieldLanguageIndependent-languageindependent-0"]
Get Checkbox State //input[@id="form-widgets-IFieldLanguageIndependent-languageindependent-0"] == unchecked

# Then

I can see the language independent field setting
Wait until page contains element id=form-widgets-IFieldLanguageIndependent-languageindependent-0
Get Element //*[@id="form-widgets-IFieldLanguageIndependent-languageindependent-0"]

the language independent field setting is selected
Checkbox should be selected form-widgets-IFieldLanguageIndependent-languageindependent-0
Get Checkbox State //input[@id="form-widgets-IFieldLanguageIndependent-languageindependent-0"] == checked

the language independent field setting is not selected
Checkbox should not be selected form-widgets-IFieldLanguageIndependent-languageindependent-0
Get Checkbox State //input[@id="form-widgets-IFieldLanguageIndependent-languageindependent-0"] == unchecked
60 changes: 19 additions & 41 deletions src/plone/app/multilingual/tests/robot/test_translate_content.robot
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
*** Settings ***

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

Library Remote ${PLONE_URL}/RobotRemote
Library Remote ${PLONE_URL}/RobotRemote

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


*** Test Cases ***
*** Test cases ***

Scenario: As an editor I can translate a document
Given a site owner
Expand All @@ -24,56 +21,37 @@ Scenario: As a visitor I can view the translation
When I switch to Catalan
Then I can view the document in Catalan


*** Keywords ***

# Given

a site owner
Enable autologin as Manager

a visitor
Disable autologin

a document in English
Create content type=Document
... container=/${PLONE_SITE_ID}/en/
... id=an-english-document
... title=An English Document
Create content type=Document container=/${PLONE_SITE_ID}/en/ id=an-english-document title=An English Document

a document in English with Catalan translation
${uid} = Create content type=Document
... container=/${PLONE_SITE_ID}/en/
... id=an-english-document
... title=An English Document
Create translation ${uid} ca
... title=A Catalan Document
Go to ${PLONE_URL}/resolveuid/${uid}
Wait until page contains An English Document
${uid}= Create content type=Document container=/${PLONE_SITE_ID}/en/ id=an-english-document title=An English Document
Create translation ${uid} ca title=A Catalan Document
Go to ${PLONE_URL}/resolveuid/${uid}
Get Element //h1[1][text()='An English Document']

# When

I translate the document into Catalan
Go to ${PLONE_URL}/en/an-english-document/@@create_translation?language=ca
Capture page screenshot
Input Text form.widgets.IDublinCore.title A Catalan Document
Click Link Dates # workaround for of TinyMCE editor field problem
Capture page screenshot
Click button css=#form-buttons-save

# Wait until page contains Element creat
# (Catalan translations not currently available)

Wait until page contains A Catalan Document
Go to ${PLONE_URL}/en/an-english-document/@@create_translation?language=ca
Take screenshot
Type Text //input[@name="form.widgets.IDublinCore.title"] A Catalan Document
Take screenshot
Click //button[@id="form-buttons-save"]

I switch to Catalan
Click Link xpath=//a[@title='Català']
Wait until page contains A Catalan Document
Click //a[@title='Català']
Get Element //h1[1][text()='A Catalan Document']

# Then

I can view the document in Catalan
Page Should Contain Element
... xpath=//h1[1][text()='A Catalan Document']
Page Should Contain Element
... xpath=//ul[@id='portal-languageselector']/li[contains(@class, 'currentLanguage')]/a[@title='Català']
Get Element //h1[1][text()='A Catalan Document']
Get Element //ul[@id='portal-languageselector']/li[contains(@class, 'currentLanguage')]/a[@title='Català']

0 comments on commit bab2212

Please sign in to comment.