diff --git a/tests/Fixtures/EmptySiteWithSiteContentDetectionGA.php b/tests/Fixtures/EmptySiteWithSiteContentDetectionGA.php deleted file mode 100644 index 5cff48388..000000000 --- a/tests/Fixtures/EmptySiteWithSiteContentDetectionGA.php +++ /dev/null @@ -1,50 +0,0 @@ - \Piwik\DI::autowire(FakeSiteContentDetector::class) - ->constructorParameter('detectedContentDetections', [Cloudflare::getId(), 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'); - } - } - -} \ No newline at end of file diff --git a/tests/Fixtures/EmptySiteWithSiteContentDetectionGA4.php b/tests/Fixtures/EmptySiteWithSiteContentDetectionGA4.php deleted file mode 100644 index 00733c12b..000000000 --- a/tests/Fixtures/EmptySiteWithSiteContentDetectionGA4.php +++ /dev/null @@ -1,50 +0,0 @@ - \Piwik\DI::autowire(FakeSiteContentDetector::class) - ->constructorParameter('detectedContentDetections', [Cloudflare::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'); - } - } - -} \ No newline at end of file diff --git a/tests/UI/EmptySite_GA4_spec.js b/tests/UI/EmptySite_GA4_spec.js deleted file mode 100644 index e490f717c..000000000 --- a/tests/UI/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.timeout(0); - - this.fixture = "Piwik\\Plugins\\GoogleAnalyticsImporter\\tests\\Fixtures\\EmptySiteWithSiteContentDetectionGA4"; - - const generalParams = 'idSite=1&period=day&date=2010-01-03'; - - it('should show no data screen with GA import and without ga3 offset banner', async function () { - const urlToTest = "?" + generalParams + "&module=CoreHome&action=index"; - await page.goto(urlToTest); - - const pageElement = await page.$('.page'); - expect(await pageElement.screenshot()).to.matchImage('emptySiteDashboard'); - }); - -}); diff --git a/tests/UI/EmptySite_GA_spec.js b/tests/UI/EmptySite_GA_spec.js index 049c7523c..b35e9ce0a 100644 --- a/tests/UI/EmptySite_GA_spec.js +++ b/tests/UI/EmptySite_GA_spec.js @@ -10,16 +10,58 @@ describe("EmptySite_GA", function () { this.timeout(0); - this.fixture = "Piwik\\Plugins\\GoogleAnalyticsImporter\\tests\\Fixtures\\EmptySiteWithSiteContentDetectionGA"; + this.fixture = "Piwik\\Tests\\Fixtures\\EmptySite"; const generalParams = 'idSite=1&period=day&date=2010-01-03'; - it('should show no data screen with GA import and with ga3 offset banner', async function () { + before(function () { + testEnvironment.detectedContentDetections = []; + testEnvironment.connectedConsentManagers = []; + testEnvironment.save(); + }); + + after(function () { + // unset all detections so fake class is no longer used + delete testEnvironment.detectedContentDetections; + delete testEnvironment.connectedConsentManagers; + testEnvironment.save(); + }); + + it('should show no data screen with GA import recommended', async function () { + testEnvironment.detectedContentDetections = ['GoogleAnalytics3', 'Cloudflare']; + testEnvironment.connectedConsentManagers = []; + testEnvironment.save(); + const urlToTest = "?" + generalParams + "&module=CoreHome&action=index"; await page.goto(urlToTest); const pageElement = await page.$('.page'); - expect(await pageElement.screenshot()).to.matchImage('emptySiteDashboard'); + expect(await pageElement.screenshot()).to.matchImage('list'); }); + it('should show import details with ga3 offset banner', async function () { + await page.evaluate(() => $('#start-tracking-detection a[href="#googleanalyticsimporter"]')[0].click()); + + const pageElement = await page.$('.page'); + expect(await pageElement.screenshot()).to.matchImage('details_ga3'); + }); + + it('should show no data screen with GA import recommended', async function () { + testEnvironment.detectedContentDetections = ['GoogleAnalytics4', 'Cloudflare']; + testEnvironment.connectedConsentManagers = []; + testEnvironment.save(); + + const urlToTest = "?" + generalParams + "&module=CoreHome&action=index"; + await page.goto(urlToTest); + + const pageElement = await page.$('.page'); + expect(await pageElement.screenshot()).to.matchImage('list'); + }); + + it('should show import details', async function () { + await page.evaluate(() => $('#start-tracking-detection a[href="#googleanalyticsimporter"]')[0].click()); + + const pageElement = await page.$('.page'); + expect(await pageElement.screenshot()).to.matchImage('details_ga4'); + }); }); diff --git a/tests/UI/expected-ui-screenshots/EmptySite_GA4_emptySiteDashboard.png b/tests/UI/expected-ui-screenshots/EmptySite_GA4_emptySiteDashboard.png deleted file mode 100644 index 4e14d9425..000000000 Binary files a/tests/UI/expected-ui-screenshots/EmptySite_GA4_emptySiteDashboard.png and /dev/null differ diff --git a/tests/UI/expected-ui-screenshots/EmptySite_GA_details_ga3.png b/tests/UI/expected-ui-screenshots/EmptySite_GA_details_ga3.png new file mode 100644 index 000000000..08ab86e57 Binary files /dev/null and b/tests/UI/expected-ui-screenshots/EmptySite_GA_details_ga3.png differ diff --git a/tests/UI/expected-ui-screenshots/EmptySite_GA_details_ga4.png b/tests/UI/expected-ui-screenshots/EmptySite_GA_details_ga4.png new file mode 100644 index 000000000..1af170a8c Binary files /dev/null and b/tests/UI/expected-ui-screenshots/EmptySite_GA_details_ga4.png differ diff --git a/tests/UI/expected-ui-screenshots/EmptySite_GA_emptySiteDashboard.png b/tests/UI/expected-ui-screenshots/EmptySite_GA_emptySiteDashboard.png deleted file mode 100644 index 1fa63c9ff..000000000 Binary files a/tests/UI/expected-ui-screenshots/EmptySite_GA_emptySiteDashboard.png and /dev/null differ diff --git a/tests/UI/expected-ui-screenshots/EmptySite_GA_list.png b/tests/UI/expected-ui-screenshots/EmptySite_GA_list.png new file mode 100644 index 000000000..4e36c4b72 Binary files /dev/null and b/tests/UI/expected-ui-screenshots/EmptySite_GA_list.png differ