Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
scayt on startup
image2 dialog
  • Loading branch information
gotcha committed Jan 22, 2016
1 parent d51958d commit 78192df
Show file tree
Hide file tree
Showing 10 changed files with 226 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/collective/ckeditor/profiles/testing_image2/metadata.xml
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<metadata>
<version>0001</version>
<dependencies>
<dependency>profile-collective.ckeditor:testing</dependency>
</dependencies>
</metadata>
12 changes: 12 additions & 0 deletions src/collective/ckeditor/profiles/testing_image2/propertiestool.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" ?>
<object name="portal_properties" meta_type="Plone Properties Tool">
<object name="ckeditor_properties" meta_type="Plone Property Sheet" purge="False">
<property name="removePlugins" type="lines">
<element value="image"/>
</property>
<property name="plugins" type="lines">
<element value="ajaxsave;/++resource++cke_ajaxsave/plugin.js"/>
<element value="image2;/++resource++ckeditor/plugins/image2/plugin.js"/>
</property>
</object>
</object>
7 changes: 7 additions & 0 deletions src/collective/ckeditor/profiles/testing_scayt/metadata.xml
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<metadata>
<version>0001</version>
<dependencies>
<dependency>profile-collective.ckeditor:testing</dependency>
</dependencies>
</metadata>
@@ -0,0 +1,6 @@
<?xml version="1.0" ?>
<object name="portal_properties" meta_type="Plone Properties Tool">
<object name="ckeditor_properties" meta_type="Plone Property Sheet" purge="False">
<property name="enableScaytOnStartup" type="boolean">True</property>
</object>
</object>
29 changes: 28 additions & 1 deletion src/collective/ckeditor/testing.py
Expand Up @@ -9,6 +9,7 @@


CKEDITOR = PloneWithPackageLayer(
bases=(REMOTE_LIBRARY_BUNDLE_FIXTURE, ),
zcml_package=collective.ckeditor,
zcml_filename='testing.zcml',
gs_profile_id='collective.ckeditor:testing',
Expand All @@ -26,6 +27,32 @@
)

CKEDITOR_ROBOT = FunctionalTesting(
bases=(CKEDITOR, REMOTE_LIBRARY_BUNDLE_FIXTURE, z2.ZSERVER_FIXTURE),
bases=(CKEDITOR, z2.ZSERVER_FIXTURE),
name='CKEDITOR_ROBOT',
)

CKEDITOR_SCAYT = PloneWithPackageLayer(
bases=(REMOTE_LIBRARY_BUNDLE_FIXTURE, ),
zcml_package=collective.ckeditor,
zcml_filename='testing.zcml',
gs_profile_id='collective.ckeditor:testing_scayt',
name='CKEDITOR_SCAYT',
)

CKEDITOR_SCAYT_ROBOT = FunctionalTesting(
bases=(CKEDITOR_SCAYT, z2.ZSERVER_FIXTURE),
name='CKEDITOR_SCAYT_ROBOT',
)

CKEDITOR_IMAGE2 = PloneWithPackageLayer(
bases=(REMOTE_LIBRARY_BUNDLE_FIXTURE, ),
zcml_package=collective.ckeditor,
zcml_filename='testing.zcml',
gs_profile_id='collective.ckeditor:testing_image2',
name='CKEDITOR_IMAGE2',
)

CKEDITOR_IMAGE2_ROBOT = FunctionalTesting(
bases=(CKEDITOR_IMAGE2, z2.ZSERVER_FIXTURE),
name='CKEDITOR_IMAGE2_ROBOT',
)
16 changes: 16 additions & 0 deletions src/collective/ckeditor/testing.zcml
Expand Up @@ -13,4 +13,20 @@
provides="Products.GenericSetup.interfaces.EXTENSION"
/>

<genericsetup:registerProfile
name="testing_scayt"
title="Testing profile for CKeditor for Plone"
directory="profiles/testing_scayt"
description=""
provides="Products.GenericSetup.interfaces.EXTENSION"
/>

<genericsetup:registerProfile
name="testing_image2"
title="Testing profile for CKeditor for Plone"
directory="profiles/testing_image2"
description=""
provides="Products.GenericSetup.interfaces.EXTENSION"
/>

</configure>
34 changes: 31 additions & 3 deletions src/collective/ckeditor/tests/robot/base.robot
Expand Up @@ -20,6 +20,18 @@ Scenario: As an editor, I am using CKEditor
When I edit the document
Then CKEditor is used for the text field

Scenario: Does not display uncorrect spelling
Given a logged-in editor
and a document
When I edit the document
Then CKEditor does not show uncorrect spelling

Scenario: Uses default image editor
Given a logged-in editor
and a document
When I edit the document
Then CKEditor uses default image editor

Scenario: Use bold button
Given a logged-in editor
and a document
Expand Down Expand Up @@ -65,15 +77,17 @@ select some text
Unselect Frame

click the bold button
Page Should contain Element css=span.cke_button__bold_icon
Click Element css=span.cke_button__bold_icon

click the italic button
Page Should contain Element css=span.cke_button__italic_icon
Click Element css=span.cke_button__italic_icon

save the document
Unselect Frame
Sleep 1 Wait for the modification of the content
Click Button Save
Unselect Frame
Sleep 1 Wait for the modification of the content
Click Button Save

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

Expand All @@ -85,3 +99,17 @@ the selected text is bold

the selected text is italic
Page Should Contain Element css=#p1 em

CKEditor does not show uncorrect spelling
Select Frame css=iframe.cke_wysiwyg_frame
Sleep 1s # to give time to scayt
Page Should Not Contain Element css=#p1 .scayt-misspell-word

CKEditor uses default image editor
Page Should Not Contain Element css=.cke_editor_text_dialog .cke_dialog_title
Page Should Contain Element css=span.cke_button__image_icon
Click Element css=span.cke_button__image_icon
Wait Until Element Is Visible css=.cke_editor_text_dialog .cke_dialog_title
Page Should Contain Element css=.cke_editor_text_dialog .cke_dialog_title
Element should contain css=.cke_editor_text_dialog .cke_dialog_title Image Properties
Element should contain css=.cke_editor_text_dialog Preview
52 changes: 52 additions & 0 deletions src/collective/ckeditor/tests/robot/image2.robot
@@ -0,0 +1,52 @@
*** Settings ***

Library collective.ckeditor.tests.keyword.TestKeywords

Resource plone/app/robotframework/keywords.robot
Resource plone/app/robotframework/selenium.robot
Resource plone/app/robotframework/saucelabs.robot

Library Remote ${PLONE_URL}/RobotRemote
Library plone.app.robotframework.keywords.Debugging

Test Setup Open SauceLabs test browser
Test Teardown Run keywords Report test status Close all browsers

*** Test cases ***

Scenario: Uses image2 editor
Given a logged-in editor
and a document
When I edit the document
Then CKEditor uses image2 editor

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

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

a logged-in editor
Enable autologin as Editor Contributor

a document
Create content type=Document id=document-to-edit title=Document to edit text=<p id="p1">paragraph1</p><p id="p2">paragraph2</p><p>paragraph3</p><p>paragraph4</p>
Go to ${PLONE_URL}/document-to-edit
Page Should Contain paragraph1
Page Should Contain paragraph4
Page Should Contain Element css=#p1
Page Should Not Contain Element css=#p1 strong

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

I edit the document
Go to ${PLONE_URL}/document-to-edit/edit

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

CKEditor uses image2 editor
Page Should Not Contain Element css=.cke_editor_text_dialog .cke_dialog_title
Page Should Contain Element css=span.cke_button__image_icon
Click Element css=span.cke_button__image_icon
Wait Until Element Is Visible css=.cke_editor_text_dialog .cke_dialog_title
Page Should Contain Element css=.cke_editor_text_dialog .cke_dialog_title
Element should contain css=.cke_editor_text_dialog .cke_dialog_title Image Properties
Element should contain css=.cke_editor_text_dialog Captioned image
49 changes: 49 additions & 0 deletions src/collective/ckeditor/tests/robot/scayt.robot
@@ -0,0 +1,49 @@
*** Settings ***

Library collective.ckeditor.tests.keyword.TestKeywords

Resource plone/app/robotframework/keywords.robot
Resource plone/app/robotframework/selenium.robot
Resource plone/app/robotframework/saucelabs.robot

Library Remote ${PLONE_URL}/RobotRemote
Library plone.app.robotframework.keywords.Debugging

Test Setup Open SauceLabs test browser
Test Teardown Run keywords Report test status Close all browsers

*** Test cases ***

Scenario: As an editor, CKEditor displays uncorrect spelling
Given a logged-in editor
and a document
When I edit the document
Then CKEditor shows uncorrect spelling

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

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

a logged-in editor
Enable autologin as Editor Contributor

a document
Create content type=Document id=document-to-edit title=Document to edit text=<p id="p1">paragraph1</p><p id="p2">paragraph2</p><p>paragraph3</p><p>paragraph4</p>
Go to ${PLONE_URL}/document-to-edit
Page Should Contain paragraph1
Page Should Contain paragraph4
Page Should Contain Element css=#p1
Page Should Not Contain Element css=#p1 strong

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

I edit the document
Go to ${PLONE_URL}/document-to-edit/edit

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

CKEditor shows uncorrect spelling
Select Frame css=iframe.cke_wysiwyg_frame
Sleep 1s # to give time to scayt
Page Should Contain Element css=#p1 .scayt-misspell-word

21 changes: 18 additions & 3 deletions src/collective/ckeditor/tests/test_robot.py
@@ -1,12 +1,27 @@
from plone.testing import layered

import robotsuite
import unittest

from ..testing import CKEDITOR_ROBOT
from ..testing import CKEDITOR_SCAYT_ROBOT
from ..testing import CKEDITOR_IMAGE2_ROBOT


def test_suite():
return layered(
robotsuite.RobotTestSuite('robot/base.robot'),
layer=CKEDITOR_ROBOT
return unittest.TestSuite(
[
layered(
robotsuite.RobotTestSuite('robot/base.robot'),
layer=CKEDITOR_ROBOT
),
layered(
robotsuite.RobotTestSuite('robot/scayt.robot'),
layer=CKEDITOR_SCAYT_ROBOT
),
layered(
robotsuite.RobotTestSuite('robot/image2.robot'),
layer=CKEDITOR_IMAGE2_ROBOT
),
]
)

0 comments on commit 78192df

Please sign in to comment.