Skip to content

Commit

Permalink
Merge pull request #255 from plone/draftjs-testing
Browse files Browse the repository at this point in the history
Draftjs testing
  • Loading branch information
tisto committed Sep 21, 2018
2 parents 6fba582 + 472cfad commit 5b2bc6f
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions tests/test_content.robot
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ 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 Page' in the navigation

# Scenario: As a site administrator I can add a text tile to a page
# Given a logged in site administrator
# and a page
# When I add a text tile with the content 'My text tile' to the page
Scenario: As a site administrator I can add a text tile to a page
Given a logged in site-administrator
and a page
When I add a text tile with the content 'My text tile' to the page
# # Then I should see a notification that 'My Page' has been created
# and I should see 'My Page' in the navigation
and I should see 'My text tile' on the page view

*** Keywords ***

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

# a page
# Wait until page contains element css=#toolbar-add
# Click element css=#toolbar-add
# Wait until page contains element css=#toolbar-add-document
# Click element css=#toolbar-add-document
# Wait until page contains element css=.public-DraftStyleDefault-block
# Execute JavaScript var textarea = document.getElementsByClassName('title')[0].getElementsByClassName('public-DraftEditor-content')[0]; var textEvent = document.createEvent('TextEvent'); textEvent.initTextEvent('textInput', true, true, null, 'My Page'); textarea.dispatchEvent(textEvent);
a page
Wait until page contains element css=#toolbar-add
Click element css=#toolbar-add
Wait until page contains element css=#toolbar-add-document
Click element css=#toolbar-add-document
Wait until page contains element css=.public-DraftStyleDefault-block
Input tile title My page


# --- When -------------------------------------------------------------------
Expand All @@ -43,16 +43,29 @@ I add a Page with the title '${title}'
Wait until page contains element css=#toolbar-add-document
Click element css=#toolbar-add-document
Wait until page contains element css=.public-DraftEditor-content
Execute JavaScript var textarea = document.getElementsByClassName('title')[0].getElementsByClassName('public-DraftEditor-content')[0]; var textEvent = document.createEvent('TextEvent'); textEvent.initTextEvent('textInput', true, true, null, 'My Page'); textarea.dispatchEvent(textEvent);
Input tile title ${title}
Click element css=*[title=Save]

I add a text tile with the content '${text}' to the page
Input tile text ${text}
Click element css=*[title=Save]

# I add a text tile with the content '${text}' to the page
# Execute JavaScript var textarea = document.getElementsByClassName('title')[0].getElementsByClassName('public-DraftEditor-content')[0]; var textEvent = document.createEvent('TextEvent'); textEvent.initTextEvent('textInput', true, true, null, 'My Page'); textarea.dispatchEvent(textEvent);
# Click element css=*[title=Save]

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

I should see '${title}' in the navigation
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']

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

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

Input tile
[Arguments] ${selector} ${text}
Execute JavaScript var textarea = document.getElementsByClassName('${selector}')[0].getElementsByClassName('public-DraftEditor-content')[0];
... var textEvent = document.createEvent('TextEvent');
... textEvent.initTextEvent('textInput', true, true, null, '${text}');
... textarea.dispatchEvent(textEvent);

0 comments on commit 5b2bc6f

Please sign in to comment.