]> source.dussan.org Git - archiva.git/commitdiff
add selenium test for roles
authorOlivier Lamy <olamy@apache.org>
Wed, 25 Jan 2012 23:22:16 +0000 (23:22 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 25 Jan 2012 23:22:16 +0000 (23:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1235987 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html
archiva-modules/archiva-web/archiva-webapp-test-js/pom.xml
archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/LoginTest.java
archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/RolesManagementTest.java [new file with mode: 0644]

index ef18d0bf4f96b422d602b5de02afdc93308e543b..4585adf6e8fc5120a39a93ffa3cbada6d31f6b5a 100644 (file)
@@ -654,6 +654,7 @@ $(function() {
   }
 
   activateRemoteRepositoryFormValidation=function(){
+    // FIXME find a way to activate cronExpression validation only if downloadRemote is activated !
     $("#main-content #remote-repository-edit-form").validate({
       /*rules: {
         daysOlder : {
index 6f03d6351fffa214fb15f0539332de6a1e364a53..ee7a674ec34a89256c5f9a1abd5f75af354c2726 100644 (file)
@@ -23,7 +23,7 @@
 
   <ul id="roles-view-tabs" class="tabs">
     <li class="active" id="roles-view-tabs-li-roles-grid">
-      <a href="#roles-view">${$.i18n.prop('roles.grid.tab.title')}</a>
+      <a href="#roles-view" id="roles-view-tabs-a-roles-grid">${$.i18n.prop('roles.grid.tab.title')}</a>
     </li>
     <li id="roles-view-tabs-li-roles-edit">
       <a href="#role-edit">${$.i18n.prop('edit')}</a>
@@ -58,7 +58,7 @@
       <tr>
         <td colspan="2">
           <div class="pull-left">
-            <button class="btn" data-bind="click: saveRoleDescription">${$.i18n.prop('save')}</button>
+            <button class="btn" id="role-edit-description-save" data-bind="click: saveRoleDescription">${$.i18n.prop('save')}</button>
           </div>
         </td>
       </tr>
           <tr>
               {{each(j, columnDefinition) columns}}
               {{var val = (typeof columnDefinition.rowText == 'function' ? columnDefinition.rowText(row) : row[columnDefinition.rowText])}}
-              <td id="role-description-${val}">
+              <td id="role-${columnDefinition.rowText}-${row.name()}">
                 ${val}
               </td>
               {{/each}}
-              <td><a href="#" data-bind="click: function(){ window.redbackModel.rolesViewModel.editRole(row) }">Edit</a></td>
+              <td>
+                <a id="edit-role-${row.name()}" href="#" data-bind="click: function(){ window.redbackModel.rolesViewModel.editRole(row) }">${$.i18n.prop('edit')}</a>
+              </td>
           </tr>
       {{/each}}
   </tbody>
index a606a527a7be4543134f5d9c89c8565c453b5486..b8fd5f3b39c2424b92e37a42f52bad1f92d3885c 100644 (file)
   <packaging>pom</packaging>
   <name>Archiva Web :: Javascript Application Tests</name>
 
+  <properties>
+    <webappDirectory>${project.build.directory}/tomcat6x/webapps/archiva</webappDirectory>
+  </properties>
+
   <dependencies>
     <dependency>
       <groupId>org.testng</groupId>
       <groupId>javax.activation</groupId>
       <artifactId>activation</artifactId>
     </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+    </dependency>
   </dependencies>
 
   <build>
                       <type>war</type>
                     </artifactItem>
                   </artifactItems>
-                  <outputDirectory>${project.build.directory}/tomcat6x/webapps/archiva</outputDirectory>
+                  <outputDirectory>${webappDirectory}</outputDirectory>
                   <overWriteSnapshots>true</overWriteSnapshots>
                 </configuration>
               </execution>
                   <path>/archiva</path>
                   <port>${container.test.port}</port>
                   <uriEncoding>UTF-8</uriEncoding>
-                  <warDirectory>${project.build.directory}/tomcat6x/webapps/archiva</warDirectory>
+                  <warDirectory>${webappDirectory}</warDirectory>
                   <fork>true</fork>
                   <ignorePackaging>true</ignorePackaging>
                   <systemProperties>
index b967a70fcc829dd5ebf0451c9e9b1c9cc56de00d..e0df61b07bf8f3313ed77592bdc988ac88f041af 100644 (file)
@@ -24,12 +24,6 @@ import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
-/*
- * Bug in TestNG. TESTNG-285: @Test(sequential=true) works incorrectly for classes with inheritance
- * http://code.google.com/p/testng/source/browse/trunk/CHANGES.txt
- * Waiting 5.9 release. It's comming soon.
- */
-
 /**
  * Based on LoginTest of Emmanuel Venisse test.
  *
diff --git a/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/RolesManagementTest.java b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/RolesManagementTest.java
new file mode 100644 (file)
index 0000000..e4b948f
--- /dev/null
@@ -0,0 +1,46 @@
+package org.apache.archiva.web.test;
+/*
+ * 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.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractArchivaTest;
+import org.apache.commons.lang.StringUtils;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * @author Olivier Lamy
+ */
+@Test( groups = { "usermanagement" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+public class RolesManagementTest
+    extends AbstractArchivaTest
+{
+    public void testReadRolesAndUpdateDescription()
+        throws Exception
+    {
+        clickLinkWithLocator( "menu-roles-list-a", true );
+        assertTextPresent( "Archiva System Administrator " );
+        Assert.assertTrue( StringUtils.isEmpty( getText( "role-description-Guest" ) ) );
+        clickLinkWithLocator( "edit-role-Guest" );
+        String desc = "The guest description";
+        setFieldValue( "role-edit-description", desc );
+        clickButtonWithLocator( "role-edit-description-save" );
+        clickLinkWithLocator( "roles-view-tabs-a-roles-grid" );
+        Assert.assertTrue( StringUtils.equals( desc, getText( "role-description-Guest" ) ) );
+    }
+}