Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge pull request #519 from zanata/assertj-versiongroup-tests
Browse files Browse the repository at this point in the history
Update version group tests to assertj, add Feature annotation
  • Loading branch information
Patrick Huang committed Jul 1, 2014
2 parents 48574eb + a5c1592 commit e97042e
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 164 deletions.
Expand Up @@ -21,6 +21,9 @@
@Slf4j
public class CreateVersionGroupPage extends BasePage {

public final static String LENGTH_ERROR =
"value must be shorter than or equal to 100 characters";

@FindBy(id = "group-form:descriptionField:description")
private WebElement groupDescriptionField;

Expand Down
Expand Up @@ -172,7 +172,7 @@
* Version Groups
* Creation and management of Version Groups
*/
VersionGroupFullTest.class,
VersionGroupTest.class,
VersionGroupIDValidationTest.class,
VersionGroupUrlTest.class
})
Expand Down

This file was deleted.

Expand Up @@ -20,9 +20,8 @@
*/
package org.zanata.feature.versionGroup;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;

import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Rule;
import org.junit.experimental.categories.Category;
Expand Down Expand Up @@ -123,7 +122,8 @@ public void inputValidationForID(String inputText) {
.inputGroupName(inputText)
.saveGroupFailure();

assertThat("Validation error is displayed for input:" + inputText,
groupPage.getFieldErrors(), Matchers.hasItem(errorMsg));
assertThat(groupPage.getFieldErrors())
.contains(errorMsg)
.as("Validation error is displayed for input:" + inputText);
}
}
@@ -0,0 +1,177 @@
/*
* Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
* @author tags. See the copyright.txt file in the distribution for a full
* listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
* site: http://www.fsf.org.
*/
package org.zanata.feature.versionGroup;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.zanata.feature.Feature;
import org.zanata.feature.testharness.ZanataTestCase;
import org.zanata.feature.testharness.TestPlan.BasicAcceptanceTest;
import org.zanata.feature.testharness.TestPlan.DetailedTest;
import org.zanata.page.dashboard.DashboardBasePage;
import org.zanata.page.groups.CreateVersionGroupPage;
import org.zanata.page.groups.VersionGroupPage;
import org.zanata.page.groups.VersionGroupsPage;
import org.zanata.util.SampleProjectRule;
import org.zanata.workflow.LoginWorkFlow;
import static org.zanata.util.FunctionalTestHelper.assumeTrue;

import static org.assertj.core.api.Assertions.assertThat;

/**
* @author Damian Jansen <a
* href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
@Category(DetailedTest.class)
public class VersionGroupTest extends ZanataTestCase {

@Rule
public SampleProjectRule sampleProjectRule = new SampleProjectRule();
private DashboardBasePage dashboardPage;

@Before
public void before() {
dashboardPage = new LoginWorkFlow().signIn("admin", "admin");
}

@Feature(summary = "The administrator can create a basic group",
tcmsTestPlanIds = 5316, tcmsTestCaseIds = 170109)
@Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION)
@Category(BasicAcceptanceTest.class)
public void createABasicGroup() throws Exception {
String groupID = "basic-group";
String groupName = "A Basic Group";
VersionGroupsPage versionGroupsPage = dashboardPage
.goToGroups()
.createNewGroup()
.inputGroupId(groupID)
.inputGroupName(groupName)
.inputGroupDescription("A basic group can be saved")
.saveGroup();
assertThat(versionGroupsPage.getGroupNames())
.contains(groupName)
.as("The version group was created");
VersionGroupPage groupView = versionGroupsPage.goToGroup(groupName);
assertThat(groupView.getTitle())
.isEqualTo("Groups - ".concat(groupName))
.as("The group is displayed");
}

@Feature(summary = "The administrator must fill in the required fields " +
"to create a group",
tcmsTestPlanIds = 5316, tcmsTestCaseIds = 170109)
@Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION)
public void requiredFields() throws Exception {
String errorMsg = "value is required";
String groupID = "verifyRequiredFieldsGroupID";
String groupName = "verifyRequiredFieldsGroupName";

CreateVersionGroupPage groupPage = dashboardPage
.goToGroups()
.createNewGroup()
.saveGroupFailure();

assertThat(groupPage.getFieldValidationErrors())
.contains(errorMsg, errorMsg)
.as("The two errors are value is required");

groupPage = groupPage.clearFields()
.inputGroupName(groupName)
.saveGroupFailure();

assertThat(groupPage.getFieldValidationErrors())
.contains(errorMsg)
.as("The value required error shown");

groupPage = groupPage.clearFields()
.inputGroupId(groupID)
.saveGroupFailure();

assertThat(groupPage.getFieldValidationErrors())
.contains(errorMsg)
.as("The value required error shown");
}

@Feature(summary = "The administrator must enter valid data into the " +
"required fields to create a group",
tcmsTestPlanIds = 5316, tcmsTestCaseIds = 170109)
@Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION)
public void groupDescriptionFieldSize() throws Exception {
String groupID = "verifyDescriptionFieldSizeID";
String groupName = "verifyDescriptionFieldSizeName";
String groupDescription ="This text is to test that the description " +
"field takes no more than exactly 100 characters - actually.";

assumeTrue("Description length is greater than 100 characters",
groupDescription.length() == 101);

CreateVersionGroupPage groupPage = dashboardPage
.goToGroups()
.createNewGroup()
.inputGroupId(groupID)
.inputGroupName(groupName)
.inputGroupDescription(groupDescription)
.saveGroupFailure();

assertThat(groupPage.getFieldValidationErrors())
.contains(CreateVersionGroupPage.LENGTH_ERROR)
.as("Invalid length error is shown");

groupDescription = groupDescription.substring(0, 100);
VersionGroupsPage verGroupsPage = groupPage
.clearFields()
.inputGroupId("verifyDescriptionFieldSizeID")
.inputGroupName(groupName)
.inputGroupDescription(groupDescription)
.saveGroup();

assertThat(verGroupsPage.getGroupNames())
.contains(groupName)
.as("A group description of 100 chars is valid");
}

@Feature(summary = "The administrator can add a project version to " +
"a newly created group",
tcmsTestPlanIds = 5316, tcmsTestCaseIds = 170109)
@Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION)
public void addANewProjectVersionToAnEmptyGroup() throws Exception {
String groupID = "add-version-to-empty-group";
String groupName = "AddVersionToEmptyGroup";
VersionGroupPage versionGroupPage = dashboardPage
.goToGroups()
.createNewGroup()
.inputGroupId(groupID)
.inputGroupName(groupName)
.saveGroup()
.goToGroup(groupName)
.clickProjectsTab()
.clickAddProjectVersionsButton()
.enterProjectVersion("about-fedora")
.selectProjectVersion("about-fedora master")
.clickProjectsTab();

assertThat(versionGroupPage.getProjectVersionsInGroup())
.contains("about fedora\nmaster")
.as("The version group shows in the list");
}
}

0 comments on commit e97042e

Please sign in to comment.