Fix welcome screen close timeout 47/98847/2
authorandre.schmid <andre.schmid@est.tech>
Mon, 25 Nov 2019 11:51:14 +0000 (11:51 +0000)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Sun, 1 Dec 2019 15:41:05 +0000 (15:41 +0000)
The welcome screen close timeout is triggering even if you close the
welcome window. After 4 seconds it forces the user to go to the home
screen even if it is already in another screen. The timeout was also
the cause for one known problem in the sanity ui test
"onapOnboardVNFflow".
Adds also a print screen to the ui tests, to check if the resource
was really clicked.
Removes invalids "throws Exception" declarations that were being
handled in the main test method "Vf.changeInstanceNameInVfTest", that
was catching also assertions errors.

Change-Id: Idff26b1ba5b199482e68cc50532fa20f4f834e34
Issue-ID: SDC-2648
Signed-off-by: andre.schmid <andre.schmid@est.tech>
catalog-ui/src/app/view-models/welcome/welcome-view.ts
ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CanvasManager.java
ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java
ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/HomePage.java
ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/GeneralUIUtils.java
ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java

index 9e88cb6..5ed7159 100644 (file)
@@ -49,12 +49,13 @@ export class WelcomeViewModel {
     }
 
     private initScope = ():void => {
-        this.$scope.onCloseButtonClick = ():void => {
+        let timeout = window.setTimeout(():void => {
             this.$state.go("dashboard", {});
-        };
-        window.setTimeout(():void => {
+        }, 4000);
+        this.$scope.onCloseButtonClick = ():void => {
+            window.clearTimeout(timeout);
             this.$state.go("dashboard", {});
-        },4000);
+        }
     };
 
     private init = ():void => {
index 0541ab9..012895f 100644 (file)
@@ -271,7 +271,7 @@ public final class CanvasManager {
         return null;
     }
 
-    public CanvasElement createElementOnCanvas(String elementName) throws Exception {
+    public CanvasElement createElementOnCanvas(String elementName) {
         String actionDuration = GeneralUIUtils.getActionDuration(() -> {
             try {
                 canvasElement = createElementOnCanvasWithoutDuration(elementName);
@@ -310,7 +310,7 @@ public final class CanvasManager {
         return null;
     }
 
-    public CanvasElement createElementOnCanvas(LeftPanelCanvasItems canvasItem) throws Exception {
+    public CanvasElement createElementOnCanvas(LeftPanelCanvasItems canvasItem) {
         return createElementOnCanvas(canvasItem.getValue());
     }
 
index 1a5cace..6a1ec57 100644 (file)
@@ -428,19 +428,12 @@ public class Vf extends SetupCDTest {
     @Test
     public void changeInstanceNameInVfTest() {
         final ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
+        ResourceUIUtils.createVF(vfMetaData, getUser());
+        ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
+        final CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
+        final CanvasElement computeElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE);
         final String updatedInstanceName = "updatedName";
-        try {
-            ResourceUIUtils.createVF(vfMetaData, getUser());
-            ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
-            final CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
-            final CanvasElement computeElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE);
-            vfCanvasManager.updateElementNameInCanvas(computeElement, updatedInstanceName);
-        } catch (final Exception e) {
-            final String errorMsg = "An unexpected error has occurred during the changeInstanceNameInVfTest";
-            takeScreenshot("ChangeInstanceNameInVf" + vfMetaData.getToscaResourceName(), errorMsg);
-            LOGGER.error(errorMsg, e);
-            fail(errorMsg);
-        }
+        vfCanvasManager.updateElementNameInCanvas(computeElement, updatedInstanceName);
         assertEquals(CompositionPage.getSelectedInstanceName(), updatedInstanceName);
     }
 
index c5cd347..3454c20 100644 (file)
@@ -25,10 +25,14 @@ import static org.openecomp.sdc.ci.tests.pages.HomePage.PageElement.REPOSITORY_I
 
 import com.aventstack.extentreports.Status;
 import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
 import java.util.List;
 import java.util.UUID;
 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
 import org.openecomp.sdc.ci.tests.exception.HomePageRuntimeException;
+import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions;
 import org.openecomp.sdc.ci.tests.utilities.DownloadManager;
 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
@@ -174,6 +178,17 @@ public class HomePage {
             getExtendTest().log(Status.ERROR, e.getMessage());
             throw new HomePageRuntimeException(errorMsg, e);
         }
+        final String datetimeString =
+            new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss.SSS").format(Calendar.getInstance().getTime());
+        try {
+            ExtentTestActions
+                .addScreenshot(Status.INFO,
+                    String.format("after-click-resource-%s-%s", resourceName, datetimeString),
+                    String.format("Clicked on resource '%s'", resourceName)
+                );
+        } catch (final IOException e) {
+            LOGGER.warn("Could take screenshot after resource {} click", resourceName, e);
+        }
         try {
             GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
         } catch (final Exception e) {
index a416324..ef91c1c 100644 (file)
@@ -414,7 +414,7 @@ public final class GeneralUIUtils {
         return true;
     }
 
-    public static String getActionDuration(Runnable func) throws Exception {
+    public static String getActionDuration(Runnable func) {
         long startTime = System.nanoTime();
         func.run();
         long estimateTime = System.nanoTime();
index 1937785..76c1a4c 100644 (file)
@@ -153,7 +153,7 @@ public final class ResourceUIUtils {
         createVF(resource, user);
     }
 
-    public static void createVF(ResourceReqDetails resource, User user) throws Exception {
+    public static void createVF(ResourceReqDetails resource, User user) {
         ExtentTestActions.log(Status.INFO, "Going to create a new VF.");
         createResource(resource, user, DataTestIdEnum.Dashboard.BUTTON_ADD_VF);
     }