diff --git a/plugins/API/RowEvolution.php b/plugins/API/RowEvolution.php index 2218cf050ae..ada804c8c22 100644 --- a/plugins/API/RowEvolution.php +++ b/plugins/API/RowEvolution.php @@ -63,9 +63,14 @@ public function getRowEvolution($idSite, $period, $date, $apiModule, $apiAction, // if goal metrics should be shown, we replace the metrics if ($showGoalMetricsForGoal !== false) { - $metadata['metrics'] = [ - 'nb_visits' => $metadata['metrics']['nb_visits'], - ]; + if (array_key_exists('nb_visits', $metadata['metrics'])) { + $metadata['metrics'] = [ + 'nb_visits' => $metadata['metrics']['nb_visits'], + ]; + } else { + // if no visits are available, simply use the first available metric + $metadata['metrics'] = array_slice($metadata['metrics'], 0, 1); + } // Use ecommerce specific metrics / column names when only showing ecommerce metrics if ($showGoalMetricsForGoal === Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) { diff --git a/plugins/Goals/tests/UI/Goals_spec.js b/plugins/Goals/tests/UI/Goals_spec.js index 9eeca2e70bc..651347aab5d 100644 --- a/plugins/Goals/tests/UI/Goals_spec.js +++ b/plugins/Goals/tests/UI/Goals_spec.js @@ -95,6 +95,19 @@ describe("Goals", function () { expect(await report.screenshot()).to.matchImage('goals_by_entry_page_titles'); }); + it('should load row evolution with goal metrics', async function() { + const row = await page.waitForSelector('.reportsByDimensionView tbody tr:first-child'); + await row.hover(); + + const icon = await page.waitForSelector('.reportsByDimensionView tbody tr:first-child a.actionRowEvolution'); + await icon.click(); + + await page.waitForSelector('.ui-dialog'); + await page.waitForNetworkIdle(); + + const dialog = await page.$('.ui-dialog'); + expect(await dialog.screenshot()).to.matchImage('goals_by_entry_page_titles_row_evolution'); + }); it('should show action goals visualization for page urls', async function() { diff --git a/plugins/Goals/tests/UI/expected-screenshots/Goals_goals_by_entry_page_titles_row_evolution.png b/plugins/Goals/tests/UI/expected-screenshots/Goals_goals_by_entry_page_titles_row_evolution.png new file mode 100644 index 00000000000..a932c9172c9 --- /dev/null +++ b/plugins/Goals/tests/UI/expected-screenshots/Goals_goals_by_entry_page_titles_row_evolution.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d601aca6b4ab2a7bae8bcdd5c6e17143258846c31f1c2c88002c7060e503267b +size 98330