Skip to content

Commit

Permalink
refactoring livesearch robot test
Browse files Browse the repository at this point in the history
  • Loading branch information
1letter committed Nov 12, 2024
1 parent 5e939df commit fa15014
Showing 1 changed file with 48 additions and 50 deletions.
98 changes: 48 additions & 50 deletions Products/CMFPlone/tests/robot/test_livesearch.robot
Original file line number Diff line number Diff line change
@@ -1,84 +1,82 @@
*** 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

Variables Products/CMFPlone/tests/robot/variables.py
Variables variables.py

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


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


Scenario: Simple Livesearch
Given a logged-in site administrator
and a document Welcome to Plone
When I search for Welcome
Then the livesearch results should contain Welcome to Plone
and expected livesearch results 1
and a document Welcome to Plone
When I search for Welcome
Then the livesearch results should contain Welcome to Plone
and expected livesearch results 1

Scenario: Livesearch with image results
Given a logged-in site administrator
and a news item My News with Image
When I search for My News
Then the livesearch results should contain My News with Image
and expected livesearch results 1
and Page should contain image css=.livesearch-results li.search-result .col.img img
and a news item My News with Image
When I search for My News
Then the livesearch results should contain My News with Image
and expected livesearch results 1
and Get Element Count //*[contains(@class,"livesearch-results")]//li[contains(@class,"search-result")]//*[contains(@class,"col") and contains(@class,"img")]//img greater than 0

When I disable images in results in search controlpanel
and I search for My News
Then Page should not contain image css=.livesearch-results li.search-result .col.img img
and Get Element Count //*[contains(@class,"livesearch-results")]//li[contains(@class,"search-result")]//*[contains(@class,"col") and contains(@class,"img")]//img should be 0


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

a document
[Arguments] ${title}
Create content type=Document id=doc title=${title}
[Arguments] ${title}
Create content
... type=Document
... id=doc
... title=${title}

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}
Choose File name=form.widgets.ILeadImageBehavior.image ${PATH_TO_TEST_FILES}/plone-logo.png
Click Button Save
Wait until page contains Item created error=Image could not be created.
[Arguments] ${title}
Go to ${PLONE_URL}/++add++News Item
Type text //input[@name="form.widgets.IDublinCore.title"] ${title}
Upload File By Selector //input[@name="form.widgets.ILeadImageBehavior.image"] ${PATH_TO_TEST_FILES}/pixel.png
Click //button[@name="form.buttons.save"]
Get Text //body contains Item created message=Image could not be created.

I search for
[Arguments] ${searchtext}
Input text css=input#searchGadget ${searchtext}
Wait For Element css=input#searchGadget
[Arguments] ${searchtext}
Type Text //input[@id="searchGadget"] ${searchtext}

I search the currentfolder only for
[Arguments] ${searchtext}
Select checkbox id=searchbox_currentfolder_only
Input text css=input#searchGadget ${searchtext}
Wait For Element css=input#searchGadget
[Arguments] ${searchtext}
Check Checkbox //*[@id="searchbox_currentfolder_only"]
Type Text //input[@id="searchGadget"] ${searchtext}

the livesearch results should contain
[Arguments] ${text}
Wait until keyword succeeds 5s 1s Element should contain css=.livesearch-results li a .heading ${text}
[Arguments] ${text}
Get Element States //ul[contains(@class,"livesearch-results")] contains visible
Get Text //ul[contains(@class,"livesearch-results")] contains ${text}

the livesearch results should not contain
[Arguments] ${text}
Wait until keyword succeeds 5s 1s Page should not contain css=.livesearch-results li a .heading ${text}
[Arguments] ${text}
Get Element States //ul[contains(@class,"livesearch-results")] contains visible
Get Text //ul[contains(@class,"livesearch-results")] not contains ${text}

expected livesearch results
[Arguments] ${num}
${count} = Get Element Count css=.livesearch-results li.search-result
Should Be Equal as Numbers ${count} ${num}
[Arguments] ${num}
Get Element Count //*[contains(@class,"livesearch-results")]//li[contains(@class,"search-result")] should be ${num}


I disable images in results in search controlpanel
Go to ${PLONE_URL}/@@search-controlpanel
Wait until page contains Search Settings
Unselect Checkbox form.widgets.search_show_images:list
Click Button Save
Wait until page contains Changes saved
Go to ${PLONE_URL}/@@search-controlpanel
Uncheck Checkbox //input[@name="form.widgets.search_show_images:list"]
Click //button[@name="form.buttons.save"]
Get Text //body contains Changes saved

0 comments on commit fa15014

Please sign in to comment.