Skip to content

Commit

Permalink
Fix row evolution for reports where visits metric is not available (#…
Browse files Browse the repository at this point in the history
…22239)

* Fix row evolution for reborts where visits metric is not available

* Add UI test
  • Loading branch information
sgiehl authored May 23, 2024
1 parent 550a14f commit d0e6442
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugins/API/RowEvolution.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
13 changes: 13 additions & 0 deletions plugins/Goals/tests/UI/Goals_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d0e6442

Please sign in to comment.