diff --git a/plugins/PrivacyManager/tests/UI/PrivacyManager_ConsentManager_spec.js b/plugins/PrivacyManager/tests/UI/PrivacyManager_ConsentManager_spec.js index e916856dba92..441f261a1aeb 100644 --- a/plugins/PrivacyManager/tests/UI/PrivacyManager_ConsentManager_spec.js +++ b/plugins/PrivacyManager/tests/UI/PrivacyManager_ConsentManager_spec.js @@ -10,13 +10,21 @@ describe("PrivacyManager_ConsentManager", function () { this.timeout(0); - this.fixture = "Piwik\\Tests\\Fixtures\\EmptySiteWithSiteContentDetection"; + this.fixture = "Piwik\\Tests\\Fixtures\\EmptySite"; var generalParams = 'idSite=1&period=day&date=2017-01-02', urlBase = '?module=PrivacyManager&' + generalParams + '&action='; before(function () { testEnvironment.pluginsToLoad = ['PrivacyManager']; + testEnvironment.detectedContentDetections = ['Osano']; + testEnvironment.connectedConsentManagers = ['Osano']; + testEnvironment.save(); + }); + + after(function () { + testEnvironment.detectedContentDetections = []; + testEnvironment.connectedConsentManagers = []; testEnvironment.save(); }); diff --git a/plugins/SitesManager/SiteContentDetection/Matomo.php b/plugins/SitesManager/SiteContentDetection/Matomo.php index 4d7bad9bacd7..ddefa6987c5d 100644 --- a/plugins/SitesManager/SiteContentDetection/Matomo.php +++ b/plugins/SitesManager/SiteContentDetection/Matomo.php @@ -12,14 +12,12 @@ use Piwik\API\Request; use Piwik\Common; -use Piwik\Container\StaticContainer; use Piwik\Piwik; use Piwik\Plugin\Manager; use Piwik\Plugins\CustomVariables\CustomVariables; use Piwik\Plugins\PrivacyManager\DoNotTrackHeaderChecker; use Piwik\Site; use Piwik\SiteContentDetector; -use Piwik\Translation\Translator; use Piwik\Url; use Piwik\View; diff --git a/plugins/Tour/tests/UI/Tour_ConsentManager_spec.js b/plugins/Tour/tests/UI/Tour_ConsentManager_spec.js index 6c4aa750da5b..631b17ef00cb 100644 --- a/plugins/Tour/tests/UI/Tour_ConsentManager_spec.js +++ b/plugins/Tour/tests/UI/Tour_ConsentManager_spec.js @@ -8,16 +8,23 @@ describe("Tour_ConsentManager", function () { this.timeout(0); - this.fixture = "Piwik\\Tests\\Fixtures\\EmptySiteWithSiteContentDetection"; + this.fixture = "Piwik\\Tests\\Fixtures\\EmptySite"; var generalParams = 'idSite=1&period=day&date=2010-01-03', widgetizeParams = "module=Widgetize&action=iframe"; var widgetUrl = "?" + widgetizeParams + "&" + generalParams + "&moduleToWidgetize=Tour&actionToWidgetize=getEngagement"; - before(async function () { testEnvironment.pluginsToLoad = ['Tour']; + testEnvironment.detectedContentDetections = ['Osano']; + testEnvironment.connectedConsentManagers = ['Osano']; + testEnvironment.save(); + }); + + after(async function () { + testEnvironment.detectedContentDetections = []; + testEnvironment.connectedConsentManagers = []; testEnvironment.save(); }); diff --git a/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetection.php b/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetection.php deleted file mode 100644 index 6fc17a8866e7..000000000000 --- a/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetection.php +++ /dev/null @@ -1,51 +0,0 @@ - \Piwik\DI::autowire(FakeSiteContentDetector::class) - ->constructorParameter('detectedContentDetections', [Osano::getId()]) - ->constructorParameter('connectedConsentManagers', [Osano::getId()]) - ]; - } - - - public function setUp(): void - { - Fixture::createSuperUser(); - $this->setUpWebsites(); - } - - public function tearDown(): void - { - // empty - } - - private function setUpWebsites() - { - if (!self::siteCreated($idSite = 1)) { - self::createWebsite('2021-01-01'); - } - } - -} diff --git a/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetectionGA3.php b/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetectionGA3.php deleted file mode 100644 index 565917ba508a..000000000000 --- a/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetectionGA3.php +++ /dev/null @@ -1,49 +0,0 @@ - \Piwik\DI::autowire(FakeSiteContentDetector::class) - ->constructorParameter('detectedContentDetections', [GoogleAnalytics3::getId()]) - ]; - } - - public function setUp(): void - { - Fixture::createSuperUser(); - $this->setUpWebsites(); - } - - public function tearDown(): void - { - // empty - } - - private function setUpWebsites() - { - if (!self::siteCreated($idSite = 1)) { - self::createWebsite('2021-01-01'); - } - } - -} diff --git a/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetectionGA4.php b/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetectionGA4.php deleted file mode 100644 index 2f68e6e6d90c..000000000000 --- a/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetectionGA4.php +++ /dev/null @@ -1,49 +0,0 @@ - \Piwik\DI::autowire(FakeSiteContentDetector::class) - ->constructorParameter('detectedContentDetections', [GoogleAnalytics4::getId()]) - ]; - } - - public function setUp(): void - { - Fixture::createSuperUser(); - $this->setUpWebsites(); - } - - public function tearDown(): void - { - // empty - } - - private function setUpWebsites() - { - if (!self::siteCreated($idSite = 1)) { - self::createWebsite('2021-01-01'); - } - } - -} diff --git a/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetectionMergeNotification.php b/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetectionMergeNotification.php deleted file mode 100644 index 150ae1d61238..000000000000 --- a/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetectionMergeNotification.php +++ /dev/null @@ -1,53 +0,0 @@ - \Piwik\DI::autowire(FakeSiteContentDetector::class) - ->constructorParameter('detectedContentDetections', [GoogleAnalytics3::getId(), GoogleAnalytics4::getId(), Osano::getId()]) - ->constructorParameter('connectedConsentManagers', [Osano::getId()]) - ]; - } - - - public function setUp(): void - { - Fixture::createSuperUser(); - $this->setUpWebsites(); - } - - public function tearDown(): void - { - // empty - } - - private function setUpWebsites() - { - if (!self::siteCreated($idSite = 1)) { - self::createWebsite('2021-01-01'); - } - } - -} diff --git a/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetectionMergeNotificationOnlyGA.php b/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetectionMergeNotificationOnlyGA.php deleted file mode 100644 index 600371bdc685..000000000000 --- a/tests/PHPUnit/Fixtures/EmptySiteWithSiteContentDetectionMergeNotificationOnlyGA.php +++ /dev/null @@ -1,51 +0,0 @@ - \Piwik\DI::autowire(FakeSiteContentDetector::class) - ->constructorParameter('detectedContentDetections', [GoogleAnalytics3::getId(), GoogleAnalytics4::getId()]) - ]; - } - - - public function setUp(): void - { - Fixture::createSuperUser(); - $this->setUpWebsites(); - } - - public function tearDown(): void - { - // empty - } - - private function setUpWebsites() - { - if (!self::siteCreated($idSite = 1)) { - self::createWebsite('2021-01-01'); - } - } - -} diff --git a/tests/UI/expected-screenshots/EmptySite_ConsentManager_emptySiteDashboard.png b/tests/UI/expected-screenshots/EmptySite_ConsentManager_emptySiteDashboard.png deleted file mode 100644 index 31beb00844db..000000000000 --- a/tests/UI/expected-screenshots/EmptySite_ConsentManager_emptySiteDashboard.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:064bf542da18daddb045c057eb2ad870e064b1ed26b1f3e0961ce0bf8e082cc8 -size 152212 diff --git a/tests/UI/expected-screenshots/EmptySite_GA3_emptySiteDashboard.png b/tests/UI/expected-screenshots/EmptySite_GA3_emptySiteDashboard.png deleted file mode 100644 index 8c20230a217a..000000000000 --- a/tests/UI/expected-screenshots/EmptySite_GA3_emptySiteDashboard.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1d9d0b7f7ab05123a3f656a7ebfb61c1ad543228182e6283f11046af938b1ef0 -size 146943 diff --git a/tests/UI/expected-screenshots/EmptySite_GA4_emptySiteDashboard.png b/tests/UI/expected-screenshots/EmptySite_GA4_emptySiteDashboard.png deleted file mode 100644 index 39b1dd0ae5bb..000000000000 --- a/tests/UI/expected-screenshots/EmptySite_GA4_emptySiteDashboard.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fa618a55988bffa52a7ead9d0803c287a43dfb2c999e4ecadf44e9d6629a9632 -size 146865 diff --git a/tests/UI/expected-screenshots/EmptySite_MergedNotificationGA_emptySiteDashboard.png b/tests/UI/expected-screenshots/EmptySite_MergedNotificationGA_emptySiteDashboard.png deleted file mode 100644 index 21829e476f8d..000000000000 --- a/tests/UI/expected-screenshots/EmptySite_MergedNotificationGA_emptySiteDashboard.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b9220a45cf1865b736c8ba5327cb44ad59aa977ae4e9493d62da4839e9b2d424 -size 151297 diff --git a/tests/UI/expected-screenshots/EmptySite_MergedNotification_emptySiteDashboard.png b/tests/UI/expected-screenshots/EmptySite_MergedNotification_emptySiteDashboard.png deleted file mode 100644 index 9a11c620558a..000000000000 --- a/tests/UI/expected-screenshots/EmptySite_MergedNotification_emptySiteDashboard.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c7e73dbc02609b207be7fec776fd3ef2f8e084a410ec0402c31b24aa9c047c2b -size 160592 diff --git a/tests/UI/expected-screenshots/EmptySite_cloudflare.png b/tests/UI/expected-screenshots/EmptySite_cloudflare.png index b6692e5f2a11..b2e74248c749 100644 --- a/tests/UI/expected-screenshots/EmptySite_cloudflare.png +++ b/tests/UI/expected-screenshots/EmptySite_cloudflare.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e6ac085528a313451de56829daaa6f06362e59f4b482edb607324fee76eda8e8 -size 131224 +oid sha256:8e4ac97f6a13a994b54b6ec571729ed9a181854ced2c12764f4f28d219a65ebd +size 129392 diff --git a/tests/UI/expected-screenshots/EmptySite_detected_cloudflare.png b/tests/UI/expected-screenshots/EmptySite_detected_cloudflare.png index d4935273fe21..5319546acd52 100644 --- a/tests/UI/expected-screenshots/EmptySite_detected_cloudflare.png +++ b/tests/UI/expected-screenshots/EmptySite_detected_cloudflare.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5ae2e72368e0a657036d15c5bb251ef9fd05295cd66a1c6aabdd5176e2c3aa51 -size 103999 +oid sha256:4a8930e2a9ff74ab5edc75c51cb82183a618f3892bb1b7bb0f136dda1df21dc4 +size 104758 diff --git a/tests/UI/expected-screenshots/EmptySite_emptySiteDashboard.png b/tests/UI/expected-screenshots/EmptySite_emptySiteDashboard.png index bd4fbfbbfc2f..200e34b6242a 100644 --- a/tests/UI/expected-screenshots/EmptySite_emptySiteDashboard.png +++ b/tests/UI/expected-screenshots/EmptySite_emptySiteDashboard.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c985ff8ec004bd8e056494b18db84e693c5032125b4b1cc07bb5443b58da137e -size 83313 +oid sha256:0de2670bf558fe33c3887f1b15ded96bcc465ac336e65611a917165d1e3ea898 +size 102194 diff --git a/tests/UI/specs/EmptySite_ConsentManager_spec.js b/tests/UI/specs/EmptySite_ConsentManager_spec.js deleted file mode 100644 index 96f96914d78d..000000000000 --- a/tests/UI/specs/EmptySite_ConsentManager_spec.js +++ /dev/null @@ -1,26 +0,0 @@ -/*! - * Matomo - free/libre analytics platform - * - * Screenshot integration tests. - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ - -describe("EmptySite_ConsentManager", function () { - - this.fixture = "Piwik\\Tests\\Fixtures\\EmptySiteWithSiteContentDetection"; - - const generalParams = 'idSite=1&period=day&date=2010-01-03'; - - it('should show the tracking code if the website has no recorded data', async function () { - const urlToTest = "?" + generalParams + "&module=CoreHome&action=index"; - await page.goto(urlToTest); - - const pageElement = await page.$('.page'); - await page.waitForNetworkIdle(); - expect(await pageElement.screenshot()).to.matchImage('emptySiteDashboard'); - }); - - -}); diff --git a/tests/UI/specs/EmptySite_GA3_spec.js b/tests/UI/specs/EmptySite_GA3_spec.js deleted file mode 100644 index 1e88172c0af4..000000000000 --- a/tests/UI/specs/EmptySite_GA3_spec.js +++ /dev/null @@ -1,25 +0,0 @@ -/*! - * Matomo - free/libre analytics platform - * - * Screenshot integration tests. - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ - -describe("EmptySite_GA3", function () { - - this.fixture = "Piwik\\Tests\\Fixtures\\EmptySiteWithSiteContentDetectionGA3"; - - const generalParams = 'idSite=1&period=day&date=2010-01-03'; - - it('should show the tracking code if the website has no recorded data and GA3 guide', async function () { - const urlToTest = "?" + generalParams + "&module=CoreHome&action=index"; - await page.goto(urlToTest); - await page.waitForNetworkIdle(); - - const pageElement = await page.$('.page'); - expect(await pageElement.screenshot()).to.matchImage('emptySiteDashboard'); - }); - -}); diff --git a/tests/UI/specs/EmptySite_GA4_spec.js b/tests/UI/specs/EmptySite_GA4_spec.js deleted file mode 100644 index d9d6a92ceb75..000000000000 --- a/tests/UI/specs/EmptySite_GA4_spec.js +++ /dev/null @@ -1,25 +0,0 @@ -/*! - * Matomo - free/libre analytics platform - * - * Screenshot integration tests. - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ - -describe("EmptySite_GA4", function () { - - this.fixture = "Piwik\\Tests\\Fixtures\\EmptySiteWithSiteContentDetectionGA4"; - - const generalParams = 'idSite=1&period=day&date=2010-01-03'; - - it('should show the tracking code if the website has no recorded data and GA4 guide', async function () { - const urlToTest = "?" + generalParams + "&module=CoreHome&action=index"; - await page.goto(urlToTest); - await page.waitForNetworkIdle(); - - const pageElement = await page.$('.page'); - expect(await pageElement.screenshot()).to.matchImage('emptySiteDashboard'); - }); - -}); diff --git a/tests/UI/specs/EmptySite_MergedNotificationGA_spec.js b/tests/UI/specs/EmptySite_MergedNotificationGA_spec.js deleted file mode 100644 index a09cb4c5610b..000000000000 --- a/tests/UI/specs/EmptySite_MergedNotificationGA_spec.js +++ /dev/null @@ -1,26 +0,0 @@ -/*! - * Matomo - free/libre analytics platform - * - * Screenshot integration tests. - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ - -describe("EmptySite_MergedNotificationGA", function () { - - this.fixture = "Piwik\\Tests\\Fixtures\\EmptySiteWithSiteContentDetectionMergeNotificationOnlyGA"; - - const generalParams = 'idSite=1&period=day&date=2010-01-03'; - - it('should show the tracking code if the website has no recorded data with GA notifications merged into one', async function () { - const urlToTest = "?" + generalParams + "&module=CoreHome&action=index"; - await page.goto(urlToTest); - - const pageElement = await page.$('.page'); - await page.waitForNetworkIdle(); - expect(await pageElement.screenshot()).to.matchImage('emptySiteDashboard'); - }); - - -}); diff --git a/tests/UI/specs/EmptySite_MergedNotification_spec.js b/tests/UI/specs/EmptySite_MergedNotification_spec.js deleted file mode 100644 index e1195eeb265b..000000000000 --- a/tests/UI/specs/EmptySite_MergedNotification_spec.js +++ /dev/null @@ -1,26 +0,0 @@ -/*! - * Matomo - free/libre analytics platform - * - * Screenshot integration tests. - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ - -describe("EmptySite_MergedNotification", function () { - - this.fixture = "Piwik\\Tests\\Fixtures\\EmptySiteWithSiteContentDetectionMergeNotification"; - - const generalParams = 'idSite=1&period=day&date=2010-01-03'; - - it('should show the tracking code if the website has no recorded data with notifications merged into one', async function () { - const urlToTest = "?" + generalParams + "&module=CoreHome&action=index"; - await page.goto(urlToTest); - await page.waitForNetworkIdle(); - - const pageElement = await page.$('.page'); - expect(await pageElement.screenshot()).to.matchImage('emptySiteDashboard'); - }); - - -}); diff --git a/tests/UI/specs/EmptySite_spec.js b/tests/UI/specs/EmptySite_spec.js index 88e338d4485c..97358b1f2f81 100644 --- a/tests/UI/specs/EmptySite_spec.js +++ b/tests/UI/specs/EmptySite_spec.js @@ -36,7 +36,7 @@ describe("EmptySite", function () { }); it('should show the tracking code when selected', async function () { - await page.evaluate(() => $('#start-tracking-method-list a[href="#matomo"]')[0].click()); + await page.evaluate(() => $('#start-tracking-detection a[href="#matomo"]')[0].click()); // wait till url check field is filled with data, which means loading has finished. await page.waitForFunction(() => $('#baseUrl').val()); @@ -166,7 +166,23 @@ describe("EmptySite", function () { }); + it('should should show a notification on the tracking code screen when a consent manager is detected', async function () { + testEnvironment.detectedContentDetections = ['Osano']; + testEnvironment.connectedConsentManagers = ['Osano']; + testEnvironment.save(); + + await page.goto('about:blank'); + await page.goto(urlToTest); + await page.waitForSelector('#start-tracking-method-list'); // wait till list is shown + + await page.evaluate(() => $('#start-tracking-detection a[href="#matomo"]')[0].click()); + // wait till url check field is filled with data, which means loading has finished. + await page.waitForFunction(() => $('#baseUrl').val()); + + const pageElement = await page.$('#start-tracking-detection'); + expect(await pageElement.screenshot()).to.matchImage('detected_osano'); + }); it.skip('should have button to send tracking code to developer', async function () {