Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry picked Fixed alert condition not reloading on site change #146

Merged
merged 3 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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