Skip to content

Commit

Permalink
Merge 2739db0 into 7c3c15c
Browse files Browse the repository at this point in the history
  • Loading branch information
tisto committed Oct 3, 2018
2 parents 7c3c15c + 2739db0 commit 637083b
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 21 deletions.
1 change: 1 addition & 0 deletions tests/__init__.robot
Expand Up @@ -7,6 +7,7 @@ Library OperatingSystem
Library Process
Library WebpackLibrary


Suite Setup Suite Setup
Suite Teardown Suite Teardown

Expand Down
47 changes: 29 additions & 18 deletions tests/keywords.robot
Expand Up @@ -5,6 +5,8 @@ Library DebugLibrary
Library RequestsLibrary
Library SeleniumLibrary timeout=30 implicit_wait=0

Variables variables.py

*** Variables ***

${FIXTURE} plone.app.robotframework.testing.PLONE_ROBOT_TESTING
Expand All @@ -15,10 +17,11 @@ ${BROWSER} chrome

*** Keywords ***

### Test Setup and Test Teardown are only called when robot tests are run for
### the whole directory (see: ./__init__.robot). These keyword import
### Zope2Server library to make it possible to run individual test case
### files without Zope2Server in PYTHONPATH of pybot test runner.
# --- Test Setup / Teardown --------------------------------------------------
# Test Setup and Test Teardown are only called when robot tests are run for
# the whole directory (see: ./__init__.robot). These keyword import
# Zope2Server library to make it possible to run individual test case
# files without Zope2Server in PYTHONPATH of pybot test runner.

Test Setup
Run Keyword If '${API}' == 'Plone' Import library plone.app.robotframework.Zope2Server
Expand All @@ -33,7 +36,8 @@ Test Teardown
Run Keyword If '${API}' == 'Plone' ZODB TearDown
Close all browsers

###

# --- Browser ----------------------------------------------------------------

Create default browser
[Documentation] Opens a new browser window based on configured ${BROWSER}
Expand All @@ -48,6 +52,7 @@ Open default browser
${status}= Run Keyword And Ignore Error Switch browser default
Run Keyword If '${status[0]}' == 'FAIL' Create default browser


# --- Given ------------------------------------------------------------------
# Given keywords are pre-conditions of the test.
# Given keywords should not contain any Selenium code or actions.
Expand All @@ -57,19 +62,7 @@ Open default browser
# action is carried out (e.g. 'the front page')

A logged in site-administrator
${headers} Create Dictionary Accept application/json Content-Type application/json
${data}= Create dictionary login admin password secret
Run Keyword If '${API}' == 'Guillotina' Create Session plone http://localhost:8081/db/container
Run Keyword If '${API}' == 'Plone' Create Session plone http://localhost:55001/plone
${resp}= Post Request plone /@login headers=${headers} data=${data}
Should Be Equal As Strings ${resp.status_code} 200
# Log ${resp.json().get('token')} WARN
the front page
Add Cookie auth_token ${resp.json().get('token')}
Reload page
Wait until keyword succeeds 120s 1s
... Page fully loaded
Page should contain Log out
Autologin as admin secret

the front page
Go to ${FRONTEND_URL}
Expand Down Expand Up @@ -119,3 +112,21 @@ I should be logged out

I should be logged in
Wait until element is visible css=.left.fixed.menu


# --- Autologin --------------------------------------------------------------

Autologin as
[Arguments] ${username}=admin ${password}=secret
${headers} Create Dictionary Accept application/json Content-Type application/json
${data}= Create dictionary login ${username} password ${password}
Create Session plone http://localhost:55001/plone
${resp}= Post Request plone /@login headers=${headers} data=${data}
Should Be Equal As Strings ${resp.status_code} 200
# Log ${resp.json().get('token')} WARN
the front page
Add Cookie auth_token ${resp.json().get('token')}
Reload page
Wait until keyword succeeds 120s 1s
... Page fully loaded
Page should contain Log out
Binary file added tests/pixel.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 123 additions & 3 deletions tests/test_content.robot
Expand Up @@ -21,8 +21,61 @@ Scenario: As a site administrator I can add a page
# # # Then I should see a notification that 'My Page' has been created
# and I should see 'My text tile' on the page view

Scenario: As a site administrator I can add a News Item
Given a logged in site-administrator
and the Plone site root
When I add a News Item with the title 'My News Item'
# Then I should see a notification that 'My Page' has been created
and I should see 'My News Item' in the navigation

# XXX: Event is broken in Plone-React
# Scenario: As a site administrator I can add an Event
# Given a logged in site-administrator
# and the Plone site root
# When I add an Event with the title 'My Event'
# # Then I should see a notification that 'My Page' has been created
# and I should see 'My Event' in the navigation

Scenario: As a site administrator I can add a Folder
Given a logged in site-administrator
and the Plone site root
When I add a Folder with the title 'My Folder'
# Then I should see a notification that 'My Page' has been created
and I should see 'My Folder' in the navigation

Scenario: As a site administrator I can add a File
Given a logged in site-administrator
and the Plone site root
When I add a File with the title 'My File'
# Then I should see a notification that 'My Page' has been created
and I should see 'My File' in the navigation

Scenario: As a site administrator I can add an Image
Given a logged in site-administrator
and the Plone site root
When I add an Image with the title 'My Image'
# Then I should see a notification that 'My Page' has been created
and I should see 'My Image' in the navigation

# XXX: Links are not implemented in Plone-React yet
# Scenario: As a site administrator I can add a Link
# Given a logged in site-administrator
# and the Plone site root
# When I add a Link with the title 'My Link'
# # Then I should see a notification that 'My Page' has been created
# and I should see 'My Link' in the navigation

# XXX: Collections are not implemented in Plone-React yet
# Scenario: As a site administrator I can add a Collection
# Given a logged in site-administrator
# and the Plone site root
# When I add a Collection with the title 'My Collection'
# # Then I should see a notification that 'My Page' has been created
# and I should see 'My Collection' in the navigation

*** Keywords ***


# --- Given ------------------------------------------------------------------

a page
Expand All @@ -37,7 +90,6 @@ a page
# --- When -------------------------------------------------------------------

I add a Page with the title '${title}'
Log I add a Page with the title '${title}' WARN
Wait until page contains element css=#toolbar-add
Click element css=#toolbar-add
Wait until page contains element css=#toolbar-add-document
Expand All @@ -50,19 +102,87 @@ I add a text tile with the content '${text}' to the page
Input tile text ${text}
Click element css=*[title=Save]

I add a News Item with the title '${title}'
Wait until page contains element css=#toolbar-add
Click element css=#toolbar-add
Wait until page contains element css=#toolbar-add-news-item
Click element css=#toolbar-add-news-item
Wait until page contains element name=title
Input text name=title ${title}
Click element css=*[title=Save]

I add an Event with the title '${title}'
Wait until page contains element css=#toolbar-add
Click element css=#toolbar-add
Wait until page contains element css=#toolbar-add-event
Click element css=#toolbar-add-event
Wait until page contains element name=title
Input text name=title ${title}
Click element css=*[title=Save]

I add a Folder with the title '${title}'
Wait until page contains element css=#toolbar-add
Click element css=#toolbar-add
Wait until element is visible css=#toolbar-add-folder
Click element css=#toolbar-add-folder
Wait until page contains element name=title
Input text name=title ${title}
Click element css=*[title=Save]

I add a File with the title '${title}'
Wait until page contains element css=#toolbar-add
Click element css=#toolbar-add
Wait until element is visible css=#toolbar-add-file
Click element css=#toolbar-add-file
Wait until page contains element name=title
Input text name=title ${title}
Choose File name=file ${PATH_TO_TEST_FILES}/pixel.png
Click element css=*[title=Save]

I add an Image with the title '${title}'
Wait until page contains element css=#toolbar-add
Click element css=#toolbar-add
Wait until element is visible css=#toolbar-add-image
Click element css=#toolbar-add-image
Wait until page contains element name=title
Input text name=title ${title}
Choose File name=image ${PATH_TO_TEST_FILES}/pixel.png
Click element css=*[title=Save]

I add a Link with the title '${title}'
Wait until page contains element css=#toolbar-add
Click element css=#toolbar-add
Wait until element is visible css=#toolbar-add-link
Click element css=#toolbar-add-link
Debug
Wait until page contains element name=title
Input text name=title ${title}
Click element css=*[title=Save]

I add a Collection with the title '${title}'
Wait until page contains element css=#toolbar-add
Click element css=#toolbar-add
Wait until element is visible css=#toolbar-add-collection
Click element css=#toolbar-add-collection
Wait until page contains element name=title
Input text name=title ${title}
Click element css=*[title=Save]


# --- Then -------------------------------------------------------------------

I should see '${title}' in the navigation
Go to ${FRONTEND_URL}/my-page
Reload Page
Wait until page contains element css=.navigation a
Wait until page contains element css=.navigation a[href='/my-page']
Page should contain element css=.navigation a[href='/my-page']
Wait until page contains element xpath=//*[contains(@class, 'navigation')]//*[contains(text(), '${title}')]
Page should contain element xpath=//*[contains(@class, 'navigation')]//*[contains(text(), '${title}')]


I should see '${text}' on the page view
Page should contain ${text}


# --- Helper -----------------------------------------------------------------

Input tile
Expand Down
4 changes: 4 additions & 0 deletions tests/variables.py
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
import os

PATH_TO_TEST_FILES = os.path.join(os.path.dirname(__file__)) # noqa

0 comments on commit 637083b

Please sign in to comment.