diff --git a/functional-test/src/main/java/org/zanata/page/groups/CreateVersionGroupPage.java b/functional-test/src/main/java/org/zanata/page/groups/CreateVersionGroupPage.java index e766c18727..4e4b9bd504 100644 --- a/functional-test/src/main/java/org/zanata/page/groups/CreateVersionGroupPage.java +++ b/functional-test/src/main/java/org/zanata/page/groups/CreateVersionGroupPage.java @@ -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; diff --git a/functional-test/src/test/java/org/zanata/feature/testharness/TestPlan.java b/functional-test/src/test/java/org/zanata/feature/testharness/TestPlan.java index 31d6f12f3d..c1901282ee 100644 --- a/functional-test/src/test/java/org/zanata/feature/testharness/TestPlan.java +++ b/functional-test/src/test/java/org/zanata/feature/testharness/TestPlan.java @@ -172,7 +172,7 @@ * Version Groups * Creation and management of Version Groups */ - VersionGroupFullTest.class, + VersionGroupTest.class, VersionGroupIDValidationTest.class, VersionGroupUrlTest.class }) diff --git a/functional-test/src/test/java/org/zanata/feature/versionGroup/VersionGroupFullTest.java b/functional-test/src/test/java/org/zanata/feature/versionGroup/VersionGroupFullTest.java deleted file mode 100644 index 1ce32aecb6..0000000000 --- a/functional-test/src/test/java/org/zanata/feature/versionGroup/VersionGroupFullTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -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.hamcrest.MatcherAssert.assertThat; - -/** - * @author Damian Jansen djansen@redhat.com - */ -@Category(DetailedTest.class) -public class VersionGroupFullTest extends ZanataTestCase { - - @Rule - public SampleProjectRule sampleProjectRule = new SampleProjectRule(); - private DashboardBasePage dashboardPage; - - @Before - public void before() { - dashboardPage = new LoginWorkFlow().signIn("admin", "admin"); - } - - @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) - @Category(BasicAcceptanceTest.class) - public void createABasicGroup() { - String groupID = "basic-group"; - String groupName = "A Basic Group"; - - CreateVersionGroupPage createVersionGroupPage = - dashboardPage.goToGroups().createNewGroup(); - createVersionGroupPage.inputGroupId(groupID); - createVersionGroupPage.inputGroupName(groupName); - createVersionGroupPage - .inputGroupDescription("A basic group can be saved"); - VersionGroupsPage versionGroupsPage = - createVersionGroupPage.saveGroup(); - assertThat("Group was created", versionGroupsPage.getGroupNames() - .contains(groupName)); - VersionGroupPage groupView = versionGroupsPage.goToGroup(groupName); - assertThat("The group is displayed", groupView.getTitle(), - Matchers.equalTo("Groups - ".concat(groupName))); - } - - @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) - public void requiredFields() { - String errorMsg = "value is required"; - String groupID = "verifyRequiredFieldsGroupID"; - String groupName = "verifyRequiredFieldsGroupName"; - - CreateVersionGroupPage groupPage = - dashboardPage.goToGroups().createNewGroup().saveGroupFailure(); - assertThat("The two errors are value is required", - groupPage.getFieldValidationErrors(), Matchers.contains(errorMsg, errorMsg)); - - groupPage = - groupPage.clearFields().inputGroupName(groupName) - .saveGroupFailure(); - assertThat("The value required error shown", groupPage.getFieldValidationErrors(), - Matchers.contains(errorMsg)); - - groupPage = - groupPage.clearFields().inputGroupId(groupID) - .saveGroupFailure(); - assertThat("The value required error shown", groupPage.getFieldValidationErrors(), - Matchers.contains(errorMsg)); - } - - @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) - public void groupDescriptionFieldSize() { - String errorMsg = "value must be shorter than or equal to 100 characters"; - 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."; - - assertThat("Description length is greater than 100 characters", - groupDescription.length(), Matchers.equalTo(101)); - CreateVersionGroupPage groupPage = - dashboardPage.goToGroups().createNewGroup(); - groupPage.inputGroupId(groupID).inputGroupName(groupName) - .inputGroupDescription(groupDescription); - groupPage.saveGroupFailure(); - assertThat("Invalid length error is shown", - groupPage.getFieldValidationErrors(), - Matchers.contains(errorMsg)); - - groupPage.clearFields(); - groupDescription = groupDescription.substring(0, 100); - assertThat("Description length is now 100 characters", - groupDescription.length(), Matchers.equalTo(100)); - groupPage.inputGroupId("verifyDescriptionFieldSizeID").inputGroupName( - groupName); - VersionGroupsPage verGroupsPage = - groupPage.inputGroupDescription(groupDescription).saveGroup(); - assertThat("A group description of 100 chars is valid", - verGroupsPage.getGroupNames(), Matchers.hasItem(groupName)); - - } - - @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) - public void addANewProjectVersionToAnEmptyGroup() - throws InterruptedException { - String groupID = "add-version-to-empty-group"; - String groupName = "AddVersionToEmptyGroup"; - VersionGroupPage versionGroupPage = dashboardPage - .goToGroups() - .createNewGroup() - .inputGroupId(groupID) - .inputGroupName(groupName) - .saveGroup() - .goToGroup(groupName) - .clickProjectsTab() - .clickAddProjectVersionsButton(); - - versionGroupPage = versionGroupPage - .enterProjectVersion("about-fedora") - .selectProjectVersion("about-fedora master") - .clickProjectsTab(); - - assertThat("The version group shows in the list", - versionGroupPage.getProjectVersionsInGroup(), - Matchers.hasItem("about fedora\nmaster")); - - } - -} diff --git a/functional-test/src/test/java/org/zanata/feature/versionGroup/VersionGroupIDValidationTest.java b/functional-test/src/test/java/org/zanata/feature/versionGroup/VersionGroupIDValidationTest.java index b3c4433979..12af8fdc59 100644 --- a/functional-test/src/test/java/org/zanata/feature/versionGroup/VersionGroupIDValidationTest.java +++ b/functional-test/src/test/java/org/zanata/feature/versionGroup/VersionGroupIDValidationTest.java @@ -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; @@ -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); } } diff --git a/functional-test/src/test/java/org/zanata/feature/versionGroup/VersionGroupTest.java b/functional-test/src/test/java/org/zanata/feature/versionGroup/VersionGroupTest.java new file mode 100644 index 0000000000..1c0f1d6021 --- /dev/null +++ b/functional-test/src/test/java/org/zanata/feature/versionGroup/VersionGroupTest.java @@ -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 djansen@redhat.com + */ +@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"); + } +}