Skip to content

Commit

Permalink
refactoring edit content robot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
1letter committed Sep 27, 2024
1 parent 8590381 commit 80134a3
Showing 1 changed file with 53 additions and 53 deletions.
106 changes: 53 additions & 53 deletions Products/CMFPlone/tests/robot/test_edit.robot
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
*** Settings *****************************************************************
*** 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
Resource keywords.robot

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

Resource keywords.robot
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


*** Variables ****************************************************************
*** Variables ***

${TITLE} An edited page
${LINK_TITLE} An edited link item
${PAGE_ID} an-edited-page
${LINK_ID} an-edited-link-item
${SELENIUM_RUN_ON_FAILURE} Capture Page Screenshot and log source

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

*** Test cases ***

Scenario: A page is opened to edit
Given a logged-in site administrator
Expand All @@ -31,7 +28,7 @@ Scenario: A page is opened to edit
Scenario: Switch tabs
Given a logged-in site administrator
and an edited page
When i click the Categorization tab
When i click the 'Categorization' tab
Then the Categorization tab is shown
and no other tab is shown

Expand All @@ -41,7 +38,7 @@ Scenario: Adding a related item
Given a logged-in site administrator
and at least one other item
and an edited page
When i click the Categorization tab
When i click the 'Categorization' tab
and i select a related item
and i save the page
Then the related item is shown in the page
Expand Down Expand Up @@ -79,68 +76,70 @@ Scenario: Add an internal link to linked item
Then the linked item is shown in the page
and Capture page screenshot and log source

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

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

an edited page
Create content type=Document title=${TITLE}
Go to ${PLONE_URL}/${PAGE_ID}/edit
Wait until page contains Edit Page
Create content
... type=Document
... title=${TITLE}
Go to ${PLONE_URL}/${PAGE_ID}/edit
Get Text //body contains Edit Page

an edited link item
Create content type=Link title=${LINK_TITLE}
Go to ${PLONE_URL}/${LINK_ID}/edit
Wait until page contains Edit Link
Create content
... type=Link
... title=${LINK_TITLE}
Go to ${PLONE_URL}/${LINK_ID}/edit
Get Text //body contains Edit Link


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

I have the title input field
Element Should Be Visible xpath=//fieldset[@id='fieldset-default']
Get Element States //fieldset[@id='fieldset-default'] contains visible

I can only see the default tab
Wait For Condition return window.jQuery('.autotoc-nav .active:visible').length > 0
Element Should Not Be Visible xpath=//fieldset[@id='fieldset-settings']
Element Should Not Be Visible xpath=//fieldset[@id='fieldset-dates']
Element Should Not Be Visible xpath=//fieldset[@id='fieldset-categorization']
Get Element States //fieldset[@id='fieldset-default'] contains visible
Get Element States //fieldset[@id='fieldset-dates'] not contains visible
Get Element States //fieldset[@id='fieldset-categorization'] not contains visible

I click the ${tab} tab
Given patterns are loaded
Click link ${tab}
Click //a[contains(text(),${tab})]

I select a related item
# Click the select button
Wait For Then Click Element //div[@id="formfield-form-widgets-IRelatedItems-relatedItems"]//button
Click //div[@id="formfield-form-widgets-IRelatedItems-relatedItems"]//button
# Click first element in first column
Wait For Then Click Element //div[contains(@class, "content-browser-wrapper")]//div[contains(@class, "levelColumns")]/div[1]/div[contains(@class, "levelItems")]/div[1]
Click //div[contains(@class, "content-browser-wrapper")]//div[contains(@class, "levelColumns")]/div[1]/div[contains(@class, "levelItems")]/div[1]
# Click the select Button in the Toolbar of column 2
Wait For Then Click Element //div[contains(@class, "content-browser-wrapper")]//div[contains(@class, "levelColumns")]/div[2]/div[contains(@class, "levelToolbar")]/button
Click //div[contains(@class, "content-browser-wrapper")]//div[contains(@class, "levelColumns")]/div[2]/div[contains(@class, "levelToolbar")]/button

I select a linked item
# Click the select button
Wait For Then Click Element //div[@id="formfield-form-widgets-remoteUrl"]//button
Click //div[@id="formfield-form-widgets-remoteUrl"]//button
# Click first element in first column
Wait For Then Click Element //div[contains(@class, "content-browser-wrapper")]//div[contains(@class, "levelColumns")]/div[1]/div[contains(@class, "levelItems")]/div[1]
Click //div[contains(@class, "content-browser-wrapper")]//div[contains(@class, "levelColumns")]/div[1]/div[contains(@class, "levelItems")]/div[1]
# Click the select Button in the Toolbar of column 2
# This selects the "test-folder"
Wait For Then Click Element //div[contains(@class, "content-browser-wrapper")]//div[contains(@class, "levelColumns")]/div[2]/div[contains(@class, "levelToolbar")]/button
Click //div[contains(@class, "content-browser-wrapper")]//div[contains(@class, "levelColumns")]/div[2]/div[contains(@class, "levelToolbar")]/button

I save the page
Click Button Save
Click //button[@name="form.buttons.save"]

I click the calendar icon
Click Element xpath=//span[@id='edit_form_effectiveDate_0_popup']
Element Should Be Visible xpath=//div[@class='calendar']
Click //span[@id='edit_form_effectiveDate_0_popup']
Get Element States //div[@class='calendar'] contains visible

I select a date using the widget
Click Element xpath=//div[@class='calendar']/table/thead/tr[2]/td[4]/div
Click //div[@class='calendar']/table/thead/tr[2]/td[4]/div


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

popup calendar should have the same date
Element Text Should Be xpath=//div[@class='calendar']//thead//td[@class='title'] January, 2001
Get Text //div[@class='calendar']//thead//td[@class='title'] should be January, 2001

form dropdowns should not have the default values anymore
${yearLabel} = Get Selected List Label xpath=//select[@id='edit_form_effectiveDate_0_year']
Expand All @@ -151,25 +150,26 @@ form dropdowns should not have the default values anymore
Should Not Be Equal ${dayLabel} --

the related item is shown in the page
Page should contain element css=#section-related
Get Element Count //*[@id="section-related"] should be 1

the linked item is shown in the page
# check if the selected testfolder is linked
Page should contain element xpath=//a[@href='${PLONE_URL}/test-folder']
Get Element Count //a[@href='${PLONE_URL}/test-folder'] greater than 0


an overlay pops up
Wait Until Page Contains Element xpath=//div[contains(@class, 'overlay')]//input[@class='insertreference']
Get Element Count //div[contains(@class, 'overlay')]//input[@class='insertreference'] should be 1

the categorization tab is shown
Element Should Be Visible xpath=//fieldset[@id='fieldset-categorization']
Get Element States //fieldset[@id='fieldset-categorization'] contains visible

no other tab is shown
Element Should Not Be Visible xpath=//fieldset[@id='fieldset-dates']
Element Should Not Be Visible xpath=//fieldset[@id='fieldset-default']
Element Should Not Be Visible xpath=//fieldset[@id='fieldset-settings']
Get Element States //fieldset[@id='fieldset-dates'] not contains visible
Get Element States //fieldset[@id='fieldset-default'] not contains visible
Get Element States //fieldset[@id='fieldset-settings'] not contains visible

at least one other item
Go to ${PLONE_URL}/++add++Document
Given patterns are loaded
Execute Javascript $('#form-widgets-IDublinCore-title').val('${TITLE}'); return 0;
Click Button Save
Go to ${PLONE_URL}/++add++Document
Type Text //input[@id="form-widgets-IDublinCore-title"] ${TITLE}
Click //button[@name="form.buttons.save"]
Get Text //body contains Item created

0 comments on commit 80134a3

Please sign in to comment.