MINOR: Added a first cut of some cucumber tests for the CMS

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@94529 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-12-07 05:13:02 +00:00
parent f17dd0c37e
commit 419da4d67c
12 changed files with 397 additions and 51 deletions

View File

@ -0,0 +1,115 @@
Feature: Page creation in the CMS
As a content author
I want to create a basic text page at the root level and save it
So that our website can be kept up to date
Scenario: An initial change to page name modifies key fields
Given I log into the CMS as admin
And I create a new page
When I put "Change Name" in the "Page name" field
And I click on the "Metadata" tab
Then the "URLSegment" field is "change-name"
And the "MetaTitle" field is "Change Name"
When I click on the "Main" tab
Then the "Navigation label" field is "Change Name"
Scenario: Every subsequent change does not change the key fields
Given I save the page
And I cancel pop-ups
When I put "Change Again" in the "Page name" field
And I click on the "Metadata" tab
Then the "URLSegment" field is "change-name"
And the "MetaTitle" field is "Change Name"
When I click on the "Main" tab
Then the "Navigation label" field is "Change Name"
Then I delete the current page
Scenario: I can populate all fields
And I create a new page
And I set "Page name" to "Populate name"
And I set "Navigation label" to "Populate label"
And I click on the "Metadata" tab
And I set "URLSegment" to "populate-url-segment"
And I set "MetaTitle" to "Populate MetaTitle"
And I set "Description" to "Populate Description"
And I set "Keywords" to "Populate Keywords"
And I set "Custom Meta Tags" to "Populate Custom Meta Tags"
And I click on the "Main" tab
And I save the page
When I load the "Populate label" page
Then the "Page name" field is "Populate name"
And the "Navigation label" field is "Populate label"
When I click on the "Metadata" tab
Then the "URLSegment" field is "populate-url-segment"
And the "MetaTitle" field is "Populate MetaTitle"
And the "Description" field is "Populate Description"
And the "Custom Meta Tags" field is "Populate Custom Meta Tags"
And I click on the "Main" tab
Then I delete the current page
Scenario: I can create 2 identical pages
When I create a new page
And I create a new page
Then there are 2 root pages with navigation label "New Page"
Then I delete the current page
And I load the "New Page" root-level page
Then I delete the current page
Scenario: Each change to page name changes the URL
When I create a new page
And I set "Page name" to "First Change"
And I click on the "Metadata" tab
Then the "URLSegment" field is "first-change"
When I confirm pop-ups
And I click on the "Main" tab
And I set "Page name" to "Second Change"
And I click on the "Metadata" tab
Then the "URLSegment" field is "second-change"
When I cancel pop-ups
And I click on the "Main" tab
And I set "Page name" to "Third Change"
And I click on the "Metadata" tab
Then the "URLSegment" field is "second-change"
And I click on the "Main" tab
Then I delete the current page
Scenario: Changes aren't saved if I cancel the warning
Given I create a new page
And I set "Page name" to "Change name"
When I confirm pop-ups to ignore the warning that their is unsaved content
And I load the "New Page" page
Then the "Page name" field is "New Page"
Then I delete the current page
Scenario: Page name and navigation label default to new page
Given I create a new page
Then the "Page name" field is "New Page"
And the "Navigation label" field is "New Page"
When I click on the "Metadata" tab
Then the "URLSegment" field is "new-page"
And the "MetaTitle" field is blank
And the "Description" field is blank
And the "Keywords" field is blank
And the "Custom Meta Tags" field is blank
And I click on the "Main" tab
Then I delete the current page
Scenario: The navigation label is displayed in the site tree
Given I create a new page
And I set "Navigation label" to "New Label"
And I save the page
When I load the "New Label" page
Then the "Navigation label" field is "New Label"
Scenario: If the navigation label is blanked out, it takes the value in the Page Name field
Given I set "Page name" to "Page Title"
When I set "Navigation label" to ""
And I save the page
And I load the "Page Title" page
Then the "Navigation label" field is "Page Title"

View File

@ -0,0 +1,40 @@
Feature: Page deletion in the CMS
As a content author
I want to delete pages in the CMS
So that out of date content can be removed
Scenario: User can delete a page without making any changes
Given I log into the CMS as admin
And I create a new page
And I save the page
When I delete the current page
Then there are 0 root pages with navigation label "New Page"
Scenario: A deleted page can't be viewed
Given I create a new page
And I save the page
When I delete the current page
And I log out
Then url new-page does not exist
Scenario: A deleted URL can be re-used
Given I log into the CMS as admin
And I create a new page
And I click on the "Metadata" tab
And the "URLSegment" field is "new-page"
And I save the page
And I delete the current page
When I create a new page
And I click on the "Metadata" tab
Then the "URLSegment" field is "new-page"
Then delete the current page
Scenario: A deleted page doesn't appear after re-login
Given I create a new page
And I save the page
And I delete the current page
When I log out
And I log into the CMS as admin
Then there are 0 root pages with navigation label "New Page"

36
tests/cuke/login.feature Normal file
View File

@ -0,0 +1,36 @@
Feature: Log in
As a CMS user
I want to security log into the CMS
So that I can make changes, knowing that other people can't.
Background:
Given I visit Security/logout
Scenario: opening admin asks user log-in
And I visit admin
Then I am sent to Security/login
Scenario: valid login
When I fill out the log in form with user "admin" and password "password"
Then I see "Your are logged in as"
Scenario: no password login
When I fill out the log in form with user "admin" and password "password"
Then I see "That doesn't seem to be the right e-mail address or password."
Scenario: no user login
When I fill out the log in form with user "" and password "password"
Then I see "That doesn't seem to be the right e-mail address or password."
Scenario: invalid login, getting right 2nd time
Given I visit admin
And I put "admin" in the "Email" field
And I put "wrongpassword" in the "Password" field
And I click the "Log in" button
Then I am sent to Security/login
And I see "That doesn't seem to be the right e-mail address or password."
Given I put "admin" in the "Email" field
And I put "password" in the "Password" field
And I click the "Log in" button
Then I am sent to admin

20
tests/cuke/logout.feature Normal file
View File

@ -0,0 +1,20 @@
Feature: Log out
As a CMS user
I want to be able to log and be locked out of the CMS
So that I can know other people can't edit my site
Scenario: Log out from CMS
Given I log into the CMS as admin
And I click the "log out" link
When I visit admin/
Then I see "Enter your username and password to access the CMS."
When I visit admin/assets/
Then I see "Enter your username and password to access the CMS."
When I visit admin/comments/
Then I see "Enter your username and password to access the CMS."
When I visit admin/reports/
Then I see "Enter your username and password to access the CMS."
When I visit admin/security/
Then I see "Enter your username and password to access the CMS."
When I visit admin/subsites/
Then I see "Enter your username and password to access the CMS."

View File

@ -0,0 +1,92 @@
## FIXTURE GENERATON
Given /^the site can be edited by the "([^\"]*)" group$/i do |arg1|
pending
end
Given /^the "([^\"]*)" page can be edited by the "([^\"]*)" group$/i do |arg1, arg2|
pending
end
Given /a "(.*)" page called "(.*)" as a child of "(.*)"/i do |type, title, parent|
Given "I click the \"#{parent}\" link"
And 'I click the "Create" button'
And "I select \"#{type}\" from \"PageType\""
And 'I click the "Go" button'
And 'I click the "Create" button'
And "I put \"#{title}\" in the \"Title\" field"
And "I click \"Save\""
end
Given /^a top\-level "(.*)" page called "(.*)"$/i do |type,title|
Given "I click the \"Site Content\" link"
And "I create a page "
And "I put \"#{title}\" in the \"Title\" field"
And "I click \"Save\""
end
## ACTIONS
Given /load the "(.*)" page/i do |title|
Given "I click the \"#{title}\" link"
end
Given /I load the "(.*)" root-level page/ do |nav|
@browser.link(:xpath, "//ul[@id='sitetree']/li/ul/li//a[.='#{nav}']").click
end
Given /I load the root node/ do
Given 'I click the "admin/0" link'
end
Given /create a new page$/i do
Given "I create a new page using template \"Page\""
end
Given /create a new page using template \"(.*)\"/i do |type|
Given 'I load the root node (ajax)'
And 'I click the "Create" button'
And "I select \"#{type}\" from \"PageType\""
And 'I click the "Go" button (ajax)'
And 'I click the "Create" button'
end
Given /save the page$/i do
Given 'I click the "Form_EditForm_action_save" button (ajax)'
end
Given /delete the current page$/i do
Given 'I click the "Delete from the draft site" button'
end
## ASSERTIONS
Given /There are ([0-9]+) root pages with navigation label "(.*)"/i do |count, nav|
@browser.elements_by_xpath("//ul[@id='sitetree']/li/ul/li//a[.='#{nav}']").count.should == count.to_i
end
Given /The "(.*)" page does not exist/i do | page|
@browser.link(:title, title).should empty?
#|''get url''|@{root_url}PAGE|
#|''title''|'''is not'''|PAGE|
end
## Current Page
Given /^The (.*) of the current page is "([^\"]*)"$/i do |arg1|
pending
end
Then /^The current page is editable$/i do
pending
end
Then /^The current page is read-only$/i do
pending
end
Then /^The current page is at the top\-level$/i do
pending
end

View File

@ -0,0 +1,21 @@
##
## Step definitions for testing the front-end site
##
Given /I go to the draft site/ do
pending
Given 'I click the "viewStageSite" link'
# |''element''|//a[@id="viewStageSite"]|''exists''|
# |''checking timeout''|@{fast_checking_timeout}|
# |''optionally''|''element''|//a[@id="viewStageSite"][@style=""]|''exists''|
# |''checking timeout''|@{checking_timeout}|
# |''click''|viewStageSite|
end
Given /I close window and go back to clean state/ do
# |''close''|
# |''select initial window''|
# |default frame|
# |''go to root node''|
end

View File

@ -0,0 +1,25 @@
##
## General rules for the SilverStripe CMS as a whole. They mostly have to do with the LeftAndMain
## interface
Given /I click on the "([^\"]*)" tab/ do |tab|
Given "I click the \"tab-Root_Content_set_#{tab}\" link"
end
Given /I wait for a status message/ do
Watir::Waiter::wait_until {
@browser.p(:id, 'statusMessage').exists? && @browser.p(:id, 'statusMessage').visible?
}
end
Given /I wait for a success message/ do
# We have to wait until after messages of the form 'Saving...', to get either a good message or
# a bad message
Watir::Waiter::wait_until {
@browser.p(:id, 'statusMessage').exists? && @browser.p(:id, 'statusMessage').visible? && @browser.p(:id, 'statusMessage').class_name != ""
}
@browser.p(:id, 'statusMessage').class_name.should == 'good'
end

View File

@ -0,0 +1,25 @@
# Log in
Given /log in as (.*)$/ do |user|
Given "I fill out the log in form with user \"#{user}\" and password \"password\""
And 'I see "Your are logged in as"'
end
Given /log into the CMS as (.*)/ do |user|
Given "I log in as #{user}"
And "I visit admin/"
And "I load the root node"
end
Given /log out$/ do
Given "I visit Security/logout"
end
Given /fill out the log in form with user "(.*)" and password "(.*)"/ do |user, password|
Given 'I visit Security/logout'
And 'I visit Security/login?BackURL=Security/login'
And "I put \"#{user}\" in the \"Email\" field"
And "I put \"#{password}\" in the \"Password\" field"
And "I click the \"Log in\" button"
end

View File

@ -0,0 +1,23 @@
# Steps definitions for security
# Fixture instantiation
Given /a "(.*)" group/ do |group|
Given 'I visit admin/security'
And 'I click the "Security Groups" link'
And 'I click the "Create" button'
And "I put \"#{group}\" in the \"Title\" field"
And 'I click the "Save" button'
end
Given /a user called "(.*)" in the "(.*)" group/ do |user, group|
Given 'I visit admin/security'
And "I click the \"#{group} (global group)\" link"
And "I put \"#{user}\" in the \"FirstName\" field"
And "I put \"#{user}\" in the \"Email\" field"
And "I put \"password\" in the \"SetPassword\" field"
And "I click the \"Add\" button"
end
Given /^I get a permission denied error$/ do
pending
end

View File

@ -1 +0,0 @@
from windmill.authoring import setup_module, teardown_module, enable_collector

View File

@ -1,24 +0,0 @@
from windmill.authoring import setup_module, teardown_module, enable_collector, WindmillTestClient
import windmill
def setup_module(module):
client = WindmillTestClient(__name__)
client.type(text=u'cms/tests/CMSMainTest.yml', id=u'fixture-file')
client.click(id=u'start-session')
client.waits.forPageLoad(timeout=u'20000')
client.click(id=u'admin-link')
client.waits.forPageLoad(timeout=u'20000')
client.type(text=u'admin@example.com', id=u'MemberLoginForm_LoginForm_Email')
client.type(text=u'ZXXlkwecxz2390232233', id=u'MemberLoginForm_LoginForm_Password')
client.click(id=u'MemberLoginForm_LoginForm_action_dologin')
client.waits.forPageLoad(timeout=u'300000')
def teardown_module(module):
client = WindmillTestClient(__name__)
client.open(url=windmill.settings['TEST_URL'], id=u'fixture-file')
client.click(id=u'end-session')

View File

@ -1,26 +0,0 @@
# Generated by the windmill services transformer
from windmill.authoring import WindmillTestClient
def test():
client = WindmillTestClient(__name__)
client.click(link=u'Security')
client.waits.forPageLoad(timeout=u'20000')
client.click(xpath=u"/html/body/div[@id='left']/div[@id='treepanes']/ul[@id='TreeActions']/li[@id='addgroup']/button")
client.waits.sleep(milliseconds=u'5000')
client.asserts.assertText(validator=u'New Group', id=u'record-2')
client.asserts.assertValue(validator=u'New Group', id=u'Form_EditForm_Title')
client.click(id=u'Form_EditForm_Title')
client.type(text=u'Test Group', id=u'Form_EditForm_Title')
client.click(id=u'Form_EditForm_action_save')
client.waits.sleep(milliseconds=u'5000')
client.asserts.assertText(validator=u'Test Group', id=u'record-2')
client.click(id=u'Form_AddRecordForm_FirstName')
client.type(text=u'Test', id=u'Form_AddRecordForm_FirstName')
client.type(text=u'Person', id=u'Form_AddRecordForm_Surname')
client.type(text=u'test@example.com', id=u'Form_AddRecordForm_Email')
client.click(id=u'Form_AddRecordForm_action_addtogroup')