From 2e3e6c68fe4dc50640a70d326b93083e5e83b9aa Mon Sep 17 00:00:00 2001 From: Oleksii Kurinnyi Date: Wed, 29 Jan 2020 11:45:22 +0200 Subject: [PATCH] Fix resolving the User Dashboard route (#15833) * Fix resolving the User Dashboard route Signed-off-by: Oleksii Kurinnyi * Switch on e2e java selenium tests in test suite * Fix resolving the route for the workspace details page Signed-off-by: Oleksii Kurinnyi Co-authored-by: Aleksandr Shmaraiev --- dashboard/src/app/dashboard/dashboard-config.ts | 11 ++++------- dashboard/src/app/navbar/navbar.controller.ts | 2 +- .../workspace-details/workspace-details-config.ts | 6 +++--- .../components/api/workspace/che-workspace.factory.ts | 5 ++--- .../organization/AddWorkspaceToOrganizationTest.java | 3 +-- .../organization/ShareWorkspaceMemberTest.java | 3 +-- 6 files changed, 12 insertions(+), 18 deletions(-) diff --git a/dashboard/src/app/dashboard/dashboard-config.ts b/dashboard/src/app/dashboard/dashboard-config.ts index 501d2e159b..9e803eeb7e 100644 --- a/dashboard/src/app/dashboard/dashboard-config.ts +++ b/dashboard/src/app/dashboard/dashboard-config.ts @@ -35,16 +35,13 @@ export class DashboardConfig { templateUrl: 'app/dashboard/dashboard.html', resolve: { check: ['$q', '$window', 'cheWorkspace', ($q: ng.IQService, $window: ng.IWindowService, cheWorkspace: CheWorkspace) => { - const defer = $q.defer(); - cheWorkspace.fetchWorkspaces().then(() => { + return cheWorkspace.fetchWorkspaces().then(() => { if (cheWorkspace.getWorkspaces().length === 0) { - $window.open(MENU_ITEM.getstarted, '_self'); - defer.reject(); - } else { - defer.resolve(); + return $q.reject(); } + }).catch(() => { + $window.open(MENU_ITEM.getstarted, '_self'); }); - return defer.promise; }] } }); diff --git a/dashboard/src/app/navbar/navbar.controller.ts b/dashboard/src/app/navbar/navbar.controller.ts index 095a7ca521..e162724b38 100644 --- a/dashboard/src/app/navbar/navbar.controller.ts +++ b/dashboard/src/app/navbar/navbar.controller.ts @@ -77,7 +77,7 @@ export class CheNavBarController { private isKeycloackPresent: boolean; private workspacesNumber: number; - private pageFactories: Array; + private pageFactories: Array = []; /** * Default constructor diff --git a/dashboard/src/app/workspaces/workspace-details/workspace-details-config.ts b/dashboard/src/app/workspaces/workspace-details/workspace-details-config.ts index ac652d6179..e60046ca2c 100644 --- a/dashboard/src/app/workspaces/workspace-details/workspace-details-config.ts +++ b/dashboard/src/app/workspaces/workspace-details/workspace-details-config.ts @@ -87,9 +87,9 @@ export class WorkspaceDetailsConfig { } return workspace.devfile.metadata.name; }; - return cheWorkspace.fetchWorkspacesByNamespace(namespace).then(() => { - const workspaceDetails = cheWorkspace.getWorkspacesByNamespace(namespace).find( workspace => getName(workspace) === workspaceName); - return {namespaceId: namespace, workspaceName: workspaceName, workspaceDetails: workspaceDetails}; + return cheWorkspace.fetchWorkspaceDetails(`${namespace}/${workspaceName}`).then(() => { + const workspaceDetails = cheWorkspace.getWorkspaceByName(namespace, workspaceName); + return { namespaceId: namespace, workspaceName: workspaceName, workspaceDetails: workspaceDetails }; }); }] } diff --git a/dashboard/src/components/api/workspace/che-workspace.factory.ts b/dashboard/src/components/api/workspace/che-workspace.factory.ts index a80ea008a1..7c0843f277 100644 --- a/dashboard/src/components/api/workspace/che-workspace.factory.ts +++ b/dashboard/src/components/api/workspace/che-workspace.factory.ts @@ -285,9 +285,9 @@ export class CheWorkspace { * If there are no changes, it's not updated */ fetchWorkspaces(): ng.IPromise> { - let promise = this.remoteWorkspaceAPI.query({'maxItems': 256}).$promise; + const promise = this.remoteWorkspaceAPI.query({'maxItems': 256}).$promise; - promise.then((workspaces: Array) => { + return promise.then((workspaces: Array) => { this.workspaceIds.length = 0; workspaces.forEach((workspace: che.IWorkspace) => { if (!workspace.temporary) { @@ -310,7 +310,6 @@ export class CheWorkspace { return this.$q.reject(error); }); - return promise; } /** diff --git a/tests/legacy-e2e/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/AddWorkspaceToOrganizationTest.java b/tests/legacy-e2e/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/AddWorkspaceToOrganizationTest.java index 8d4fdaa4f1..677f4d57bb 100644 --- a/tests/legacy-e2e/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/AddWorkspaceToOrganizationTest.java +++ b/tests/legacy-e2e/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/AddWorkspaceToOrganizationTest.java @@ -33,8 +33,7 @@ import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -// Known permanent failure https://github.com/eclipse/che/issues/15822 -@Test(groups = {TestGroup.UNDER_REPAIR, TestGroup.MULTIUSER, TestGroup.OPENSHIFT, TestGroup.K8S}) +@Test(groups = {TestGroup.MULTIUSER, TestGroup.OPENSHIFT, TestGroup.K8S}) public class AddWorkspaceToOrganizationTest { private static final String WORKSPACE_FOR_ADMIN_1 = generate("workspace", 4); diff --git a/tests/legacy-e2e/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/ShareWorkspaceMemberTest.java b/tests/legacy-e2e/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/ShareWorkspaceMemberTest.java index 7f09370315..37714bb1e6 100644 --- a/tests/legacy-e2e/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/ShareWorkspaceMemberTest.java +++ b/tests/legacy-e2e/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/ShareWorkspaceMemberTest.java @@ -43,8 +43,7 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -// Known permanent failure https://github.com/eclipse/che/issues/15822 -@Test(groups = {TestGroup.UNDER_REPAIR, TestGroup.MULTIUSER, TestGroup.OPENSHIFT, TestGroup.K8S}) +@Test(groups = {TestGroup.MULTIUSER, TestGroup.OPENSHIFT, TestGroup.K8S}) public class ShareWorkspaceMemberTest { private static final String WORKSPACE_NAME = generate("workspace", 4);