You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by ja...@apache.org on 2012/05/30 23:06:15 UTC

svn commit: r1344463 - in /rave/trunk/rave-integration-tests: rave-core-tests/src/main/java/org/apache/rave/integrationtests/pages/ rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/ rave-default-account-tests/src/main/sto...

Author: jasha
Date: Wed May 30 21:06:14 2012
New Revision: 1344463

URL: http://svn.apache.org/viewvc?rev=1344463&view=rev
Log:
RAVE-581 Add tests for adding and deleting a new page

Added:
    rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/PageOperationsSteps.java
    rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/ProfileSteps.java
Modified:
    rave/trunk/rave-integration-tests/rave-core-tests/src/main/java/org/apache/rave/integrationtests/pages/Portal.java
    rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/DefaultAccountSteps.java
    rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/stories/johnDoe.story

Modified: rave/trunk/rave-integration-tests/rave-core-tests/src/main/java/org/apache/rave/integrationtests/pages/Portal.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-integration-tests/rave-core-tests/src/main/java/org/apache/rave/integrationtests/pages/Portal.java?rev=1344463&r1=1344462&r2=1344463&view=diff
==============================================================================
--- rave/trunk/rave-integration-tests/rave-core-tests/src/main/java/org/apache/rave/integrationtests/pages/Portal.java (original)
+++ rave/trunk/rave-integration-tests/rave-core-tests/src/main/java/org/apache/rave/integrationtests/pages/Portal.java Wed May 30 21:06:14 2012
@@ -32,7 +32,7 @@ import org.springframework.stereotype.Co
  */
 @Component
 public class Portal extends WebDriverPage {
-    private final static int SLEEP_TIME = 1666; //ms
+    private final static int SLEEP_TIME = 3333; //ms
     private final static int MAX_ATTEMPTS = 3;
 
     @Autowired

Modified: rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/DefaultAccountSteps.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/DefaultAccountSteps.java?rev=1344463&r1=1344462&r2=1344463&view=diff
==============================================================================
--- rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/DefaultAccountSteps.java (original)
+++ rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/DefaultAccountSteps.java Wed May 30 21:06:14 2012
@@ -90,59 +90,4 @@ public class DefaultAccountSteps {
         assertThat(title.getText().trim(), equalTo("Login - Rave"));
 	 }
 
-    @Then("I see the email address \"$email\" on the profile page")
-    public void getEmailOnProfilePage(String email) {
-        final WebElement emailField = portal.findElement(By.id("email"));
-        assertThat(emailField.getText().trim(), equalTo(email));
-    }
-
-    @Then("I see the about me \"$aboutMe\" on the profile page")
-    public void getAboutMeOnProfilePage(String aboutMe) {
-        final WebElement aboutMeField = portal.findElement(By.id("aboutMe"));
-        assertThat(aboutMeField.getText().trim(), equalTo(aboutMe));
-    }
-
-    @Then("I see the status \"$status\" on the profile page")
-    public void getStatusOnProfilePage(String status) {
-        final WebElement statusField = portal.findElement(By.id("status"));
-        assertThat(statusField.getText().trim(), equalTo(status));
-    }
-
-    @When("I click on the \"$buttonId\" button")
-    public void clickButton(String buttonId) {
-        final WebElement button = portal.findElement(By.id(buttonId));
-        button.click();
-    }
-
-    @Then("I can edit the email address")
-    public void editEmailFieldIsVisible() {
-        final WebElement editEmailField = portal.findElement(By.id("emailField"));
-        editEmailField.isDisplayed();
-    }
-
-    @When("I change the email address to \"$email\"")
-    public void changeEmailAddress(String email) {
-        changeFieldValue("emailField", email);
-    }
-
-    @When("I change the about me to \"$aboutMe\"")
-    public void changeAboutMe(String aboutMe) {
-        changeFieldValue("aboutMeField", aboutMe);
-    }
-
-    @When("I change the status to \"$status\"")
-    public void changeStatus(String status) {
-        changeFieldValue("statusField", status);
-    }
-    private void changeFieldValue(String fieldId, String value) {
-        final WebElement field = portal.findElement(By.id(fieldId));
-        field.clear();
-        field.sendKeys(value);
-    }
-
-    @When("I submit the edit profile form")
-    public void submitProfileForm() {
-        final WebElement editAccountForm = portal.findElement(By.id("editAccountForm"));
-        editAccountForm.submit();
-    }
 }

Added: rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/PageOperationsSteps.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/PageOperationsSteps.java?rev=1344463&view=auto
==============================================================================
--- rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/PageOperationsSteps.java (added)
+++ rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/PageOperationsSteps.java Wed May 30 21:06:14 2012
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.rave.integrationtests.steps;
+
+import org.apache.rave.integrationtests.pages.Portal;
+import org.jbehave.core.annotations.Then;
+import org.jbehave.core.annotations.When;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.Select;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsNull.notNullValue;
+
+/**
+ * Steps for managing page operations (adding pages, changing layout etc)
+ */
+@Step
+public class PageOperationsSteps {
+
+    @Autowired
+    Portal portal;
+
+
+    @When("I click the add page button")
+    public void clickAddPage() {
+        final WebElement addPageLink = portal.findElement(By.xpath("//li[@id='addPageButton']/a"));
+        addPageLink.click();
+        final WebElement pageForm = portal.findElement(By.id("pageForm"));
+        assertThat(pageForm.isDisplayed(), equalTo(Boolean.TRUE));
+    }
+
+    @When("I enter the title \"$value\"")
+    public void enterTitle(String value) {
+        changeFieldValue("tab_title", value);
+    }
+
+    @When("I choose the two column layout")
+    public void selectTwoColumnLayout() {
+        final Select layouts = new Select(portal.findElement(By.id("pageLayout")));
+        layouts.selectByValue("columns_2");
+    }
+
+    @When("I add the page")
+    public void submitAddPage() {
+        final WebElement updateButton = portal.findElement(By.id("pageMenuUpdateButton"));
+        updateButton.click();
+        sleep(2000L);
+    }
+
+    @Then("the new page with title \"$pageTitle\" is selected")
+    public void checkNewPage(String pageTitle) {
+        final WebElement activePage =
+                portal.findElement(By.xpath("//div[@id='pageContent']/nav//li[contains(@class, 'active')]/a"));
+        assertThat(activePage, notNullValue());
+        assertThat(activePage.getText().trim(), equalTo(pageTitle));
+        final WebElement emptyPageBox = portal.getEmptyPageBox();
+        assertThat(emptyPageBox.isDisplayed(), equalTo(Boolean.TRUE));
+    }
+
+    @When("I delete the current page")
+    public void deleteCurrentPage() {
+        final WebElement activePage =
+                portal.findElement(By.xpath("//div[@id='pageContent']/nav//li[contains(@class, 'active')]"));
+        activePage.click();
+        sleep(2000L);
+        final WebElement deletePageLink = portal.findElement(By.xpath("//li[@id='pageMenuDelete']/a"));
+        deletePageLink.click();
+    }
+
+
+    private void changeFieldValue(String fieldId, String value) {
+        final WebElement field = portal.findElement(By.id(fieldId));
+        field.clear();
+        field.sendKeys(value);
+    }
+
+    private void sleep(long milis) {
+        try {
+            Thread.sleep(milis);
+        } catch (InterruptedException e) {
+            throw new RuntimeException("Could not sleep thread", e);
+        }
+    }
+
+}

Added: rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/ProfileSteps.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/ProfileSteps.java?rev=1344463&view=auto
==============================================================================
--- rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/ProfileSteps.java (added)
+++ rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/java/org/apache/rave/integrationtests/steps/ProfileSteps.java Wed May 30 21:06:14 2012
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.rave.integrationtests.steps;
+
+import org.apache.rave.integrationtests.pages.Portal;
+import org.jbehave.core.annotations.Then;
+import org.jbehave.core.annotations.When;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * Steps for managing a user profile
+ */
+@Step
+public class ProfileSteps {
+
+    @Autowired
+    private Portal portal;
+
+    @Then("I see the email address \"$email\" on the profile page")
+    public void getEmailOnProfilePage(String email) {
+        final WebElement emailField = portal.findElement(By.id("email"));
+        assertThat(emailField.getText().trim(), equalTo(email));
+    }
+
+    @Then("I see the about me \"$aboutMe\" on the profile page")
+    public void getAboutMeOnProfilePage(String aboutMe) {
+        final WebElement aboutMeField = portal.findElement(By.id("aboutMe"));
+        assertThat(aboutMeField.getText().trim(), equalTo(aboutMe));
+    }
+
+    @Then("I see the status \"$status\" on the profile page")
+    public void getStatusOnProfilePage(String status) {
+        final WebElement statusField = portal.findElement(By.id("status"));
+        assertThat(statusField.getText().trim(), equalTo(status));
+    }
+
+    @When("I click on the \"$buttonId\" button")
+    public void clickButton(String buttonId) {
+        final WebElement button = portal.findElement(By.id(buttonId));
+        button.click();
+    }
+
+    @Then("I can edit the email address")
+    public void editEmailFieldIsVisible() {
+        final WebElement editEmailField = portal.findElement(By.id("emailField"));
+        editEmailField.isDisplayed();
+    }
+
+    @When("I change the email address to \"$email\"")
+    public void changeEmailAddress(String email) {
+        changeFieldValue("emailField", email);
+    }
+
+    @When("I change the about me to \"$aboutMe\"")
+    public void changeAboutMe(String aboutMe) {
+        changeFieldValue("aboutMeField", aboutMe);
+    }
+
+    @When("I change the status to \"$status\"")
+    public void changeStatus(String status) {
+        changeFieldValue("statusField", status);
+    }
+
+    private void changeFieldValue(String fieldId, String value) {
+        final WebElement field = portal.findElement(By.id(fieldId));
+        field.clear();
+        field.sendKeys(value);
+    }
+
+    @When("I submit the edit profile form")
+    public void submitProfileForm() {
+        final WebElement editAccountForm = portal.findElement(By.id("editAccountForm"));
+        editAccountForm.submit();
+    }
+}

Modified: rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/stories/johnDoe.story
URL: http://svn.apache.org/viewvc/rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/stories/johnDoe.story?rev=1344463&r1=1344462&r2=1344463&view=diff
==============================================================================
--- rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/stories/johnDoe.story (original)
+++ rave/trunk/rave-integration-tests/rave-default-account-tests/src/main/stories/johnDoe.story Wed May 30 21:06:14 2012
@@ -29,7 +29,6 @@ Then I see the email address "john.doe@e
 And I see the about me "I'm a test user" on the profile page
 And I see the status "It's complicated" on the profile page
 When I log out
-Then I see the Rave login page
 
 Scenario: John Doe reverts his profile after logging out and in
 When I log in with username "john.doe" and password "john.doe"
@@ -46,4 +45,14 @@ And I submit the edit profile form
 Then I see the email address "john.doe@example.com" on the profile page
 And I see the about me "" on the profile page
 And I see the status "" on the profile page
+When I log out
 
+Scenario: John Doe adds a new page
+When I log in with username "john.doe" and password "john.doe"
+And I click the add page button
+And I enter the title "Auto test"
+And I choose the two column layout
+And I add the page
+Then the new page with title "Auto test" is selected
+When I delete the current page
+When I log out