Skip to content

Commit

Permalink
refactoring controlpanel_site robot test
Browse files Browse the repository at this point in the history
  • Loading branch information
1letter committed Nov 12, 2024
1 parent 478e841 commit ff14636
Showing 1 changed file with 71 additions and 81 deletions.
152 changes: 71 additions & 81 deletions Products/CMFPlone/tests/robot/test_controlpanel_site.robot
Original file line number Diff line number Diff line change
@@ -1,125 +1,115 @@
Documentation
... $ bin/robot-server Products.CMFPlone.testing.PRODUCTS_CMFPLONE_ROBOT_TESTING
... $ bin/robot test_controlpanel_site.robot
*** Settings ***

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

Resource plone/app/robotframework/keywords.robot
Resource plone/app/robotframework/saucelabs.robot
Resource plone/app/robotframework/selenium.robot
Variables Products/CMFPlone/tests/robot/variables.py
Library Remote ${PLONE_URL}/RobotRemote

Library Remote ${PLONE_URL}/RobotRemote
Test Setup Run Keywords Plone test setup
Test Teardown Run keywords Plone test teardown

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: Set Site Title in the Site Control Panel
Given a logged-in site administrator
and the site control panel
When I set the site title to 'My Site'
Then the site title should be set to 'My Site'
Given a logged-in site administrator
and the site control panel
When I set the site title to 'My Site'
Then the site title should be set to 'My Site'

Scenario: Set Site Logo in the Site Control Panel
Given a logged-in site administrator
and the site control panel
When I set a custom logo
Then the site logo should be set to the custom logo
Given a logged-in site administrator
and the site control panel
When I set a custom logo
Then the site logo should be set to the custom logo

Scenario: Enable Dublin Core Metadata in the Site Control Panel
Given a logged-in site administrator
and the site control panel
When I enable dublin core metadata
Then the dublin core metadata shows up on the site
Given a logged-in site administrator
and the site control panel
When I enable dublin core metadata
Then the dublin core metadata shows up on the site

Scenario: Enable Sitemap in the Site Control Panel
Given a logged-in site administrator
and the site control panel
When I enable the sitemap
Then then I can see a sitemap
Given a logged-in site administrator
and the site control panel
When I enable the sitemap
Then then I can see a sitemap

Scenario: Add Webstats Javascript in the Site Control Panel
Given a logged-in site administrator
and the site control panel
When I add a Javascript snippet to the webstats javascript
Then the Javascript snippet shows up on the site
Given a logged-in site administrator
and the site control panel
When I add a Javascript snippet to the webstats javascript
Then the Javascript snippet shows up on the site


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

# --- GIVEN ------------------------------------------------------------------
# GIVEN

the site control panel
Go to ${PLONE_URL}/@@site-controlpanel
Wait until page contains Site Settings
Go to ${PLONE_URL}/@@site-controlpanel
Get Text //body contains Site Settings


# --- WHEN -------------------------------------------------------------------
# WHEN

I enable the sitemap
Given patterns are loaded
Wait For Element css=#formfield-form-widgets-enable_sitemap
Select Checkbox form.widgets.enable_sitemap:list
Wait For Then Click Element css=#form-buttons-save
Wait until page contains Changes saved
Check Checkbox //input[@name="form.widgets.enable_sitemap:list"]
Click //button[@name="form.buttons.save"]
Get Text //body contains Changes saved

I set the site title to '${site_title}'
Given patterns are loaded
Input Text name=form.widgets.site_title ${site_title}
Wait For Then Click Element css=#form-buttons-save
Wait until page contains Changes saved
Type Text //input[@name="form.widgets.site_title"] ${site_title}
Click //button[@name="form.buttons.save"]
Get Text //body contains Changes saved

I set a custom logo
Given patterns are loaded
Choose File name=form.widgets.site_logo ${PATH_TO_TEST_FILES}/pixel.png
Wait For Then Click Element css=#form-buttons-save
Wait until page contains Changes saved
Upload File By Selector //input[@name="form.widgets.site_logo"] ${PATH_TO_TEST_FILES}/pixel.png
Click //button[@name="form.buttons.save"]
Get Text //body contains Changes saved

I enable dublin core metadata
Given patterns are loaded
Select Checkbox form.widgets.exposeDCMetaTags:list
Wait For Then Click Element css=#form-buttons-save
Wait until page contains Changes saved
Check Checkbox //input[@name="form.widgets.exposeDCMetaTags:list"]
Click //button[@name="form.buttons.save"]
Get Text //body contains Changes saved

I add a Javascript snippet to the webstats javascript
Given patterns are loaded
Input Text name=form.widgets.webstats_js <script id="webstats_snippet"></script>
Wait For Then Click Element css=#form-buttons-save
Wait until page contains Changes saved
Type Text //textarea[@name="form.widgets.webstats_js"] <script id="webstats_snippet"></script>
Click //button[@name="form.buttons.save"]
Get Text //body contains Changes saved


# --- THEN -------------------------------------------------------------------
# THEN

the site title should be set to '${expected_site_title}'
Go To ${PLONE_URL}
${actual_site_title}= Get title
Should be equal ${actual_site_title} ${expected_site_title}
Go To ${PLONE_URL}
Get Text //head/title should be ${expected_site_title}

the site logo should be set to the custom logo
Go To ${PLONE_URL}
Wait Until Element Is Visible css=#portal-logo
Page should contain element //*[@id="portal-logo"]/img[contains(@src,'@@site-logo/pixel.png')]
Go To ${PLONE_URL}
Get Element Count //*[@id="portal-logo"]/img[contains(@src,'@@site-logo/pixel.png')] should be 1

then I can see a sitemap
Go to ${PLONE_URL}/sitemap.xml.gz
# We need a 'Download file' selenium2library keyword to test this:
# https://github.com/rtomac/robotframework-selenium2library/issues/24

Import library OperatingSystem

# this is for robotframework browser > 17
Download ${PLONE_URL}/sitemap.xml.gz saveAs=/tmp/sitemap.xml.gz
File Should Exist /tmp/sitemap.xml.gz

# this is for robotframework browser < 18.0
# ${file_object}= Download ${PLONE_URL}/sitemap.xml.gz
# File Should Exist ${file_object.saveAs}

the dublin core metadata shows up on the site
Go to ${PLONE_URL}
Wait until page contains Powered by Plone
Page should contain element xpath=//html/head/meta[@name='DC.date.modified']
Page should contain element xpath=//html/head/meta[@name='DC.format']
Page should contain element xpath=//html/head/meta[@name='DC.type']
Page should contain element xpath=//html/head/meta[@name='DC.date.created']
Page should contain element xpath=//html/head/meta[@name='DC.language']
Go to ${PLONE_URL}
Get Element Count //html/head/meta[@name="DC.date.modified"] should be 1
Get Element Count //html/head/meta[@name="DC.format"] should be 1
Get Element Count //html/head/meta[@name="DC.type"] should be 1
Get Element Count //html/head/meta[@name="DC.date.created"] should be 1
Get Element Count //html/head/meta[@name="DC.language"] should be 1

the Javascript snippet shows up on the site
Go to ${PLONE_URL}
Wait until page contains Powered by Plone
Page should contain element id=webstats_snippet
Go to ${PLONE_URL}
Get Element Count //*[@id="webstats_snippet"] should be 1

0 comments on commit ff14636

Please sign in to comment.