Skip to content

Commit

Permalink
Merge pull request #146 from matomo-org/cherrypick-145
Browse files Browse the repository at this point in the history
Cherry picked Fixed alert condition not reloading on site change
  • Loading branch information
AltamashShaikh authored Aug 25, 2023
2 parents 7f20a9e + 25be09d commit d080848
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Changelog

* 4.1.1 Fixed alert conditions not reloading on site change
* 4.1.0 Migrate AngularJS to Vue
* 4.0.4 Fixed autocomplete for country to trigger alerts
* 4.0.3 Grouped alert condition select in UI
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "CustomAlerts",
"description": "Create custom Alerts to be notified of important changes on your website or app! ",
"version": "4.1.0",
"version": "4.1.1",
"require": {
"matomo": ">=4.10.0-b1,<5.0.0-b1"
},
Expand Down
8 changes: 8 additions & 0 deletions tests/Fixtures/CustomAlerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Piwik\Piwik;
use Piwik\Plugins\CustomAlerts\Model;
use Piwik\Tests\Framework\Fixture;
use Piwik\Plugins\Goals\API;

/**
* Tracks custom events
Expand All @@ -32,6 +33,13 @@ private function setUpWebsites()
if (!self::siteCreated($idSite = 1)) {
self::createWebsite($this->dateTime);
}

// tests run in UTC, the Tracker in UTC
if (!self::siteCreated($idSite = 2)) {
self::createWebsite($this->dateTime);
}

API::getInstance()->addGoal($idSite, 'Goal for idSite 2', 'title', 'normal title', 'exact', true, 50, true);
}

private function addAlerts()
Expand Down
29 changes: 29 additions & 0 deletions tests/UI/CustomAlerts_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,37 @@ describe("CustomAlerts", function () {
expect(await elem.screenshot()).to.matchImage('edit');
});

it('should reload alert conditions when site is changed', async function () {
await page.evaluate(function() {
$('.siteSelector .dropdown li:contains("Piwik test"):last').click();
});
await page.waitForNetworkIdle();
await page.evaluate(function() {
$('.expandableSelector .select-wrapper').click();
$('.expandableSelector li:contains("Goals"):first:parent .secondLevel').show();
});
await page.waitForNetworkIdle();
const elem = await page.$('.pageWrap');
await page.waitForTimeout(350); // wait for animation
expect(await elem.screenshot()).to.matchImage('alert_condition_reloaded_site2');
});

it('should reload alert conditions when site is changed back', async function () {
await page.evaluate(function() {
$('.siteSelector .dropdown li:contains("Piwik test"):first').click();
});
await page.waitForNetworkIdle();
await page.waitForNetworkIdle();
const elem = await page.$('.pageWrap');
await page.waitForTimeout(350); // wait for animation
expect(await elem.screenshot()).to.matchImage('alert_condition_reloaded_site1');
});

it('should save changed alert', async function () {
// only check if name was changed in list, no need to make a screenshot
await page.evaluate(function() {
$('.expandableSelector .select-wrapper').click();
});
await page.type('#alertName', ' changed');
await page.click('.matomo-save-button');
await page.waitForNetworkIdle();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/UI/expected-ui-screenshots/CustomAlerts_edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 34 additions & 33 deletions vue/dist/CustomAlerts.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vue/dist/CustomAlerts.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vue/src/EditAlert/EditAlert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ export default defineComponent({
method: 'API.getReportMetadata',
date: Matomo.currentDateString,
period: this.actualAlert.period,
idSites: this.actualAlert.id_sites,
idSite: this.actualAlert.id_sites?.[0],
filter_limit: '-1',
}).then((data) => {
this.renderForm(data);
Expand Down

0 comments on commit d080848

Please sign in to comment.