From 525fb0b69d986aeef0e7ad1594f71f3c019c026e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Wed, 9 Aug 2017 16:40:51 +0200 Subject: [PATCH] Add redirection of old routes to the new format --- .../main/js/apps/component-measures/routes.js | 36 +++++++++++++++++++ .../measure/ProjectMeasuresPageTest.java | 19 +++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/server/sonar-web/src/main/js/apps/component-measures/routes.js b/server/sonar-web/src/main/js/apps/component-measures/routes.js index 02a7323043e..ae5557a77ef 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/routes.js +++ b/server/sonar-web/src/main/js/apps/component-measures/routes.js @@ -22,6 +22,42 @@ const routes = [ getIndexRoute(_, callback) { import('./components/AppContainer').then(i => callback(null, { component: i.default })); } + }, + { + path: 'domain/:domainName', + onEnter(nextState, replace) { + replace({ + pathname: '/component_measures', + query: { + ...nextState.location.query, + metric: nextState.params.domainName + } + }); + } + }, + { + path: 'metric/:metricKey/:view', + onEnter(nextState, replace) { + if (nextState.params.view === 'history') { + replace({ + pathname: '/project/activity', + query: { + id: nextState.location.query.id, + graph: 'custom', + custom_metrics: nextState.params.metricKey + } + }); + } else { + replace({ + pathname: '/component_measures', + query: { + ...nextState.location.query, + metric: nextState.params.metricKey, + view: nextState.params.view + } + }); + } + } } ]; diff --git a/tests/src/test/java/org/sonarqube/tests/measure/ProjectMeasuresPageTest.java b/tests/src/test/java/org/sonarqube/tests/measure/ProjectMeasuresPageTest.java index 5ecedb276db..c92cb765471 100644 --- a/tests/src/test/java/org/sonarqube/tests/measure/ProjectMeasuresPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/measure/ProjectMeasuresPageTest.java @@ -116,7 +116,6 @@ public class ProjectMeasuresPageTest { } @Test - @Ignore public void should_redirect_history_to_project_activity() { Navigation nav = tester.openBrowser(); nav.open("/component_measures/metric/reliability_rating/history?id=project-measures-page-test-project"); @@ -127,6 +126,24 @@ public class ProjectMeasuresPageTest { .contains("custom_metrics=reliability_rating"); } + @Test + public void should_redirect_old_routes_to_new_measures_page() { + Navigation nav = tester.openBrowser(); + nav.open("/component_measures/metric/reliability_rating/tree?id=project-measures-page-test-project"); + assertThat(url()) + .contains("/component_measures") + .contains("id=project-measures-page-test-project") + .contains("metric=reliability_rating") + .contains("view=tree") + .doesNotContain("/metric/reliability_rating/tree"); + nav.open("/component_measures/domain/Security?id=project-measures-page-test-project"); + assertThat(url()) + .contains("/component_measures") + .contains("id=project-measures-page-test-project") + .contains("metric=Security") + .doesNotContain("/domain/Security"); + } + @Test public void should_show_link_to_history() { Navigation nav = tester.openBrowser(); -- 2.39.5