Skip to content

Commit

Permalink
refactoring edit robot test
Browse files Browse the repository at this point in the history
  • Loading branch information
1letter committed Nov 12, 2024
1 parent fb830b0 commit 19a467e
Showing 1 changed file with 71 additions and 47 deletions.
118 changes: 71 additions & 47 deletions Products/CMFPlone/tests/robot/test_edit.robot
Original file line number Diff line number Diff line change
@@ -1,24 +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


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

Scenario: A page is opened to edit
Given a logged-in site administrator
Expand All @@ -29,17 +28,16 @@ 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

Scenario: Adding a related item
# Order of the next two lines is important
# First we're creating a new item and then editing the original page
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 All @@ -62,51 +60,78 @@ Scenario: Form dropdowns follows DateTime widget values
and i select a date using the widget
Then form dropdowns should not have the default values anymore

Scenario: A link item is opened to edit
Given a logged-in site administrator
and an edited link item
Then i have the title input field
and i can only see the default tab

Scenario: Add an internal link to linked item
Given a logged-in site administrator
and an edited link item
and i select a linked item
and i save the page
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
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
Wait For Then Click Element jquery=.pat-relateditems-container ul.select2-choices:visible
Wait For Then Click Element jquery=a.pat-relateditems-result-select:first
Click //div[@id="formfield-form-widgets-IRelatedItems-relatedItems"]//button[contains(text(), "Browse")]
Wait For Condition Element States //div[@id="select2-drop"]//ul[@class="select2-results"] contains visible
Click //a[@data-path="/test-folder" and contains(@class,"selectable")]

I select a linked item
Click //div[@id="formfield-form-widgets-remoteUrl"]//button[contains(text(), "Browse")]
Wait For Condition Element States //div[@id="select2-drop"]//ul[@class="select2-results"] contains visible
Click //a[@data-path="/test-folder" and contains(@class,"selectable")]


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 @@ -117,21 +142,20 @@ 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
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']

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
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

0 comments on commit 19a467e

Please sign in to comment.