r3515 - trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its
Author: ymartel Date: 2012-06-18 16:16:41 +0200 (Mon, 18 Jun 2012) New Revision: 3515 Url: http://chorem.org/repositories/revision/pollen/3515 Log: refs #606 : add ITs for text poll with groups Added: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateTextPollForGroupSIT.java Modified: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateRestrictedTextPollSIT.java trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/PollenBaseWebDriverIT.java Modified: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateRestrictedTextPollSIT.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateRestrictedTextPollSIT.java 2012-06-18 12:44:50 UTC (rev 3514) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateRestrictedTextPollSIT.java 2012-06-18 14:16:41 UTC (rev 3515) @@ -52,8 +52,8 @@ } /** - * This test create a simple free text poll. - * At the end, should be on summary page. + * This test create a text poll with restriction on participant but no participant. + * At the end, should stay on create poll page, cause at least one participant is needed. * * @throws Exception */ @@ -300,21 +300,4 @@ checkWebElementValue(By.id("votingListRESTRICTED_0PersonToList_0.email"), participantOneEmail); } - /** - * Prepare the poll with general data : one title and two choices - */ - void preparePoll() { - // Go on home page - gotoUrl(fixtures.createPollURL()); - - // Set title - sendKeysByName("poll.title", "My Poll"); - - // Set first choice - sendKeysByName("textChoice_0.name", "Choix numero un"); - - // Set second choice - sendKeysByName("textChoice_1.name", "Choix numero deux"); - } - } Added: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateTextPollForGroupSIT.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateTextPollForGroupSIT.java (rev 0) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateTextPollForGroupSIT.java 2012-06-18 14:16:41 UTC (rev 3515) @@ -0,0 +1,487 @@ +/* + * #%L + * Pollen :: UI (struts2) + * $Id: CreateFreeTextPollSIT.java 3507 2012-06-18 09:45:47Z ymartel $ + * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-ui-struts2/src/test/java/org/c... $ + * %% + * Copyright (C) 2009 - 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.pollen.ui.its; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import java.util.List; + +/** + * Test the well work of a text poll creation page with the use of groups. + * <p/> + * Tested cases : + * <ul> + * <li>Creation with a nonamed group (KO)</li> + * <li>Creation with two group with same name (KO)</li> + * <li>Creation with a participant without email (KO)</li> + * <li>Creation with a participant with only an email (no name) (KO)</li> + * <li>Creation with two participants with same name in same group (KO)</li> + * <li>Creation with two participants with same email (KO)</li> + * <li>Creation with two participants with same name in different group (KO)</li> + * <li>Creation with two participants with same email in different group (KO)</li> + * </ul> + * + * @author ymartel <martel@codelutin.com> + * @since 1.4 + */ +public class CreateTextPollForGroupSIT extends PollenBaseWebDriverIT { + + public CreateTextPollForGroupSIT(Class<? extends WebDriver> driverType) { + super(driverType); + } + + /** + * This test create a text poll with group of participant but with no name on group. + * At the end, should stay on create page cause the group name is mandatory + * + * @throws Exception + */ + @Test + public void createTextPollWithNoNamedGroup() throws Exception { + + // Prepare the poll + preparePoll(); + + // Go to option panel and display group form + goToGroupForm(); + + // Check that the group form is displayed + WebElement groupNameElement = findElement(By.id("votingListGROUP_0.name")); + Assert.assertEquals("input", groupNameElement.getTagName()); + Assert.assertTrue(groupNameElement.isDisplayed()); + + // Set a participant in the group + // send name + String participantOneName = "toto"; + sendKeysById("votingListGROUP_0PersonToList_0.votingId", participantOneName); + // send email + String participantOneEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_0.email", participantOneEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(fixtures.createPollURL(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table, and group form is still displayed + groupNameElement = findElement(By.id("votingListGROUP_0.name")); + Assert.assertEquals("input", groupNameElement.getTagName()); + Assert.assertTrue(groupNameElement.isDisplayed()); + // check the participant is still here + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), participantOneName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), participantOneEmail); + } + + /** + * This test create a group text poll, with two groups with same name. + * At the end, should stay on create poll page, cause the group name should be unique. + * The group names and participants should not be lost. + * + * @throws Exception + */ + @Test + public void createGroupTextPollWithGroupsWithSameName() throws Exception { + + // Prepare the poll + preparePoll(); + + // Go to option panel and display group form + goToGroupForm(); + + // Set First group name + String groupOneName = "my group"; + sendKeysById("votingListGROUP_0.name", groupOneName); + // Set first participant in Group 1 + // send name + String participantOneName = "toto"; + sendKeysById("votingListGROUP_0PersonToList_0.votingId", participantOneName); + // send email + String participantOneEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_0.email", participantOneEmail); + + // Add a group + WebElement addGroupElement = findElement(By.name("pollen.action.addVotingList")); + Assert.assertEquals("input", addGroupElement.getTagName()); + Assert.assertTrue(addGroupElement.isDisplayed()); + addGroupElement.click(); + + // Set name of the second group: same as first one + sendKeysById("votingListGROUP_1.name", groupOneName); + // Set second participant in second group + // send name + String participantTwoName = "toto2"; + sendKeysById("votingListGROUP_1PersonToList_0.votingId", participantTwoName); + // send email + String participantTwoEmail = "toto2@codelutin.com"; + sendKeysById("votingListGROUP_1PersonToList_0.email", participantTwoEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(fixtures.createPollURL(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListGROUP_0.name"), groupOneName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), participantOneName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), participantOneEmail); + checkWebElementValue(By.id("votingListGROUP_1.name"), groupOneName); + checkWebElementValue(By.id("votingListGROUP_1PersonToList_0.votingId"), participantTwoName); + checkWebElementValue(By.id("votingListGROUP_1PersonToList_0.email"), participantTwoEmail); + } + + /** + * This test create a group text poll, with one participant without email. + * At the end, should stay on create poll page, cause the mail is mandatory. + * + * @throws Exception + */ + @Test + public void createGroupTextPollWithParticipantWithoutMail() throws Exception { + + // Prepare the poll + preparePoll(); + + // Go to option panel and display group form + goToGroupForm(); + + // Set group name + String groupName = "my group"; + sendKeysById("votingListGROUP_0.name", groupName); + + // Set first participant + // send name + String participantName = "toto"; + sendKeysById("votingListGROUP_0PersonToList_0.votingId", participantName); + // send an empty email + sendKeysById("votingListGROUP_0PersonToList_0.email", ""); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(fixtures.createPollURL(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListGROUP_0.name"), groupName); // group name still here + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), participantName); // participant name still here + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), ""); // still no email + } + + /** + * This test create a group text poll, with one participant without name. + * At the end, should stay on create poll page, cause the mail is mandatory. + * + * @throws Exception + */ + @Test + public void createGroupTextPollWithParticipantWithoutName() throws Exception { + + // Prepare the poll + preparePoll(); + // Go to option panel and display group form + goToGroupForm(); + + + // Set group name + String groupName = "my group"; + sendKeysById("votingListGROUP_0.name", groupName); + + // Set a participant + // send name + sendKeysById("votingListGROUP_0PersonToList_0.votingId", ""); + // send an empty email + String participantEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_0.email", participantEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(fixtures.createPollURL(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListGROUP_0.name"), groupName); // group name still here + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), ""); // participant name still empty + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), participantEmail); // still the mail + } + + /** + * This test create a group text poll, with two participants with same email in same group. + * At the end, should stay on create poll page, cause the email should be unique. + * + * @throws Exception + */ + @Test + public void createTextPollWithSameGroupParticipantsWithSameEmail() throws Exception { + + // Prepare the poll + preparePoll(); + + // Go to option panel and display group form + goToGroupForm(); + + // Set group name + String groupName = "my group"; + sendKeysById("votingListGROUP_0.name", groupName); + // Set first participant in Group + // send name + String participantOneName = "toto"; + sendKeysById("votingListGROUP_0PersonToList_0.votingId", participantOneName); + // send email + String participantEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_0.email", participantEmail); + + // Set second participant in Group with same email + // send name + String participantTwoName = "toto2"; + sendKeysById("votingListGROUP_0PersonToList_1.votingId", participantTwoName); + // send email + sendKeysById("votingListGROUP_0PersonToList_1.email", participantEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(fixtures.createPollURL(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListGROUP_0.name"), groupName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), participantOneName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), participantEmail); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_1.votingId"), participantTwoName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_1.email"), participantEmail); + } + + /** + * This test create a group text poll, with two participants on different group with same email. + * At the end, should stay on create poll page, cause the participant names should be unique. + * The group names and participants should not be lost. + * + * @throws Exception + */ + @Test + public void createGroupTextPollWithParticipantsWithSameEmail() throws Exception { + + // Prepare the poll + preparePoll(); + + // Go to option panel and display group form + goToGroupForm(); + + // Set First group name + String groupOneName = "my group"; + sendKeysById("votingListGROUP_0.name", groupOneName); + // Set first participant in Group 1 + // send name + String participantOneName = "toto"; + sendKeysById("votingListGROUP_0PersonToList_0.votingId", participantOneName); + // send email + String participantEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_0.email", participantEmail); + + // Add a group + WebElement addGroupElement = findElement(By.name("pollen.action.addVotingList")); + Assert.assertEquals("input", addGroupElement.getTagName()); + Assert.assertTrue(addGroupElement.isDisplayed()); + addGroupElement.click(); + + // Set name of the second group + String groupTwoName = "my other group"; + sendKeysById("votingListGROUP_1.name", groupTwoName); + // Set second participant in second group + // send name + String participantTwoName = "toto2"; + sendKeysById("votingListGROUP_1PersonToList_0.votingId", participantTwoName); + // send email + sendKeysById("votingListGROUP_1PersonToList_0.email", participantEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(fixtures.createPollURL(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListGROUP_0.name"), groupOneName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), participantOneName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), participantEmail); + checkWebElementValue(By.id("votingListGROUP_1.name"), groupTwoName); + checkWebElementValue(By.id("votingListGROUP_1PersonToList_0.votingId"), participantTwoName); + checkWebElementValue(By.id("votingListGROUP_1PersonToList_0.email"), participantEmail); + } + + /** + * This test create a group text poll, with two participant with same name in a group. + * At the end, should stay on create poll page, cause the email should be unique. + * The group name and participant info must be not lost + * + * @throws Exception + */ + @Test + public void createTextPollWithSameGroupParticipantsWithSameName() throws Exception { + + // Prepare the poll + preparePoll(); + + // Go to option panel and display option panel + goToGroupForm(); + + // Set group name + String groupName = "my group"; + sendKeysById("votingListGROUP_0.name", groupName); + // Set first participant in Group + // send name + String participantName = "toto"; + sendKeysById("votingListGROUP_0PersonToList_0.votingId", participantName); + // send email + String participantOneEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_0.email", participantOneEmail); + + // Set second participant in Group with same email + // send name + sendKeysById("votingListGROUP_0PersonToList_1.votingId", participantName); + // send email + String participantTwoEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_1.email", participantTwoEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(fixtures.createPollURL(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListGROUP_0.name"), groupName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), participantName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), participantOneEmail); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_1.votingId"), participantName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_1.email"), participantTwoEmail); + } + + /** + * This test create a group text poll, with two participants of different group with same name. + * At the end, should stay on create poll page, cause the participant name should be unique. + * The group names and participants should not be lost. + * + * @throws Exception + */ + @Test + public void createGroupTextPollWithParticipantsWithSameName() throws Exception { + + // Prepare the poll + preparePoll(); + + // Go to option panel and group form + goToGroupForm(); + + // Set First group name + String groupOneName = "my group"; + sendKeysById("votingListGROUP_0.name", groupOneName); + // Set first participant in Group 1 + // send name + String participantName = "toto"; + sendKeysById("votingListGROUP_0PersonToList_0.votingId", participantName); + // send email + String participantOneEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_0.email", participantOneEmail); + + // Add a group + WebElement addGroupElement = findElement(By.name("pollen.action.addVotingList")); + Assert.assertEquals("input", addGroupElement.getTagName()); + Assert.assertTrue(addGroupElement.isDisplayed()); + addGroupElement.click(); + + // Set name of the second group + String groupTwoName = "my other group"; + sendKeysById("votingListGROUP_1.name", groupTwoName); + // Set second participant in second group + // send name + sendKeysById("votingListGROUP_1PersonToList_0.votingId", participantName); + // send email + String participantTwoEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_1PersonToList_0.email", participantTwoEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(fixtures.createPollURL(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListGROUP_0.name"), groupOneName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), participantName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), participantOneEmail); + checkWebElementValue(By.id("votingListGROUP_1.name"), groupTwoName); + checkWebElementValue(By.id("votingListGROUP_1PersonToList_0.votingId"), participantName); + checkWebElementValue(By.id("votingListGROUP_1PersonToList_0.email"), participantTwoEmail); + } + + /** + * Click on option panel, and select Group type to restrict the poll participation + */ + void goToGroupForm() { + // Go to option panel : click on it + WebElement optionsClick = findElement(By.xpath("//a[@href=\"#toptions\"]")); + optionsClick.click(); + + // Switch to group type + List<WebElement> pollTypesElement = findElements(By.name("poll.pollType")); + Assert.assertEquals(3, pollTypesElement.size()); + WebElement restrictedTypeElement = pollTypesElement.get(2); + Assert.assertEquals("input", restrictedTypeElement.getTagName()); + Assert.assertEquals("GROUP", restrictedTypeElement.getAttribute("value")); + Assert.assertTrue(restrictedTypeElement.isDisplayed()); + restrictedTypeElement.click(); + } + +} Modified: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/PollenBaseWebDriverIT.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/PollenBaseWebDriverIT.java 2012-06-18 12:44:50 UTC (rev 3514) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/PollenBaseWebDriverIT.java 2012-06-18 14:16:41 UTC (rev 3515) @@ -161,6 +161,23 @@ } /** + * Prepare the poll with general data : one title and two choices + */ + void preparePoll() { + // Go on home page + gotoUrl(fixtures.createPollURL()); + + // Set title + sendKeysByName("poll.title", "My Poll"); + + // Set first choice + sendKeysByName("textChoice_0.name", "Choix numero un"); + + // Set second choice + sendKeysByName("textChoice_1.name", "Choix numero deux"); + } + + /** * Set a value for a WebElement. * This operations does 3 steps : * <ul> @@ -240,7 +257,7 @@ if (safeDrivers == null) { List<Class<? extends WebDriver>> allDrivers = Lists.newArrayList(); -// allDrivers.add(HtmlUnitDriver.class); + allDrivers.add(HtmlUnitDriver.class); allDrivers.add(FirefoxDriver.class); // allDrivers.add(ChromeDriver.class); // allDrivers.add(InternetExplorerDriver.class);
participants (1)
-
ymartel@users.chorem.org