1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.test.ui.appwithinminutes

File ApplicationNameTest.java

 

Code metrics

0
40
3
1
153
82
3
0.08
13.33
3
1

Classes

Class Line # Actions
ApplicationNameTest 39 40 0% 3 0
1.0100%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.test.ui.appwithinminutes;
21   
22    import org.junit.Assert;
23    import org.junit.Rule;
24    import org.junit.Test;
25    import org.openqa.selenium.Keys;
26    import org.xwiki.appwithinminutes.test.po.ApplicationCreatePage;
27    import org.xwiki.test.ui.AbstractTest;
28    import org.xwiki.test.ui.AdminAuthenticationRule;
29    import org.xwiki.test.ui.browser.IgnoreBrowser;
30    import org.xwiki.test.ui.browser.IgnoreBrowsers;
31    import org.xwiki.test.ui.po.ViewPage;
32   
33    /**
34    * Tests the first step of the App Within Minutes wizard.
35    *
36    * @version $Id: 4bf86afc0ea595f248ef4f4160b9d187c5dbb97c $
37    * @since 3.4M1
38    */
 
39    public class ApplicationNameTest extends AbstractTest
40    {
41    @Rule
42    public AdminAuthenticationRule adminAuthenticationRule = new AdminAuthenticationRule(getUtil());
43   
44    /**
45    * The error message displayed when we try to create an application with an empty name.
46    */
47    private static final String EMPTY_APP_NAME_ERROR_MESSAGE = "Please enter the application name.";
48   
49    /**
50    * The warning message displayed when we input the name of an existing application.
51    */
52    public static final String APP_NAME_USED_WARNING_MESSAGE = "This application already exists.";
53   
54    /**
55    * Try to create an application with an empty name using the next step button.
56    */
 
57  1 toggle @Test
58    @IgnoreBrowsers({
59    @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"),
60    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177")
61    })
62    public void testEmptyAppNameWithNextStepButton()
63    {
64  1 ApplicationCreatePage appCreatePage = ApplicationCreatePage.gotoPage();
65  1 Assert.assertFalse(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
66   
67    // Try to move to the next step without typing the application name.
68  1 String urlBeforeClick = getDriver().getCurrentUrl();
69  1 appCreatePage.clickNextStepButton();
70  1 Assert.assertEquals(urlBeforeClick, getDriver().getCurrentUrl());
71   
72    // Type the application name.
73  1 appCreatePage.setApplicationName("A");
74  1 appCreatePage.waitForApplicationNamePreview();
75  1 Assert.assertFalse(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
76   
77    // Clear the application name using the Backspace key.
78  1 appCreatePage.getApplicationNameInput().sendKeys(Keys.BACK_SPACE);
79  1 appCreatePage.waitForApplicationNameError();
80  1 Assert.assertTrue(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
81   
82    // Try to create the application even if the error message is displayed.
83  1 urlBeforeClick = getDriver().getCurrentUrl();
84  1 appCreatePage.clickNextStepButton();
85  1 Assert.assertEquals(urlBeforeClick, getDriver().getCurrentUrl());
86   
87    // Fix the application name and move to the next step.
88  1 appCreatePage.setApplicationName(getTestMethodName());
89  1 appCreatePage.waitForApplicationNamePreview();
90  1 Assert.assertEquals(getTestMethodName() + " Structure", appCreatePage.clickNextStep().getDocumentTitle());
91    }
92   
93    /**
94    * Try to create an application with an empty name using the Enter key.
95    */
 
96  1 toggle @Test
97    @IgnoreBrowsers({
98    @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"),
99    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177")
100    })
101    public void testEmptyAppNameWithEnter()
102    {
103  1 ApplicationCreatePage appCreatePage = ApplicationCreatePage.gotoPage();
104  1 Assert.assertFalse(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
105   
106    // Press Enter key without typing the application name.
107  1 appCreatePage.getApplicationNameInput().sendKeys(Keys.RETURN);
108  1 appCreatePage.waitForApplicationNameError();
109  1 Assert.assertTrue(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
110   
111    // Type the application name.
112  1 appCreatePage.setApplicationName("B");
113  1 appCreatePage.waitForApplicationNamePreview();
114  1 Assert.assertFalse(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
115   
116    // Clear the application name using the Backspace key.
117  1 appCreatePage.getApplicationNameInput().sendKeys(Keys.BACK_SPACE);
118  1 appCreatePage.waitForApplicationNameError();
119  1 Assert.assertTrue(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
120   
121    // Try to create the application even if the error message is displayed.
122  1 appCreatePage.getApplicationNameInput().sendKeys(Keys.RETURN);
123  1 Assert.assertTrue(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
124   
125    // Fix the application name and move to the next step using the Enter key.
126  1 appCreatePage.setApplicationName(getTestMethodName());
127  1 appCreatePage.waitForApplicationNamePreview();
128  1 appCreatePage.getApplicationNameInput().sendKeys(Keys.RETURN);
129  1 Assert.assertEquals(getTestMethodName() + " Structure", new ViewPage().getDocumentTitle());
130    }
131   
132    /**
133    * Try to input the name of an existing application.
134    */
 
135  1 toggle @Test
136    @IgnoreBrowsers({
137    @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"),
138    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177")
139    })
140    public void testExistingAppName()
141    {
142  1 ApplicationCreatePage appCreatePage = ApplicationCreatePage.gotoPage();
143  1 Assert.assertFalse(appCreatePage.getContent().contains(APP_NAME_USED_WARNING_MESSAGE));
144   
145    // Type the name of an existing space.
146  1 appCreatePage.setApplicationName("Blog");
147  1 appCreatePage.waitForApplicationNamePreview();
148  1 Assert.assertTrue(appCreatePage.getContent().contains(APP_NAME_USED_WARNING_MESSAGE));
149   
150    // Proceed to the next step.
151  1 Assert.assertEquals("/Blog/Code/Blog Structure", appCreatePage.clickNextStep().getBreadcrumbContent());
152    }
153    }