Skip to content

Commit

Permalink
Refactor UI tests into one suite and update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Sep 19, 2023
1 parent 0c88562 commit 2b3c57d
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 128 deletions.
50 changes: 0 additions & 50 deletions tests/Fixtures/EmptySiteWithSiteContentDetectionGA.php

This file was deleted.

50 changes: 0 additions & 50 deletions tests/Fixtures/EmptySiteWithSiteContentDetectionGA4.php

This file was deleted.

25 changes: 0 additions & 25 deletions tests/UI/EmptySite_GA4_spec.js

This file was deleted.

48 changes: 45 additions & 3 deletions tests/UI/EmptySite_GA_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
Binary file not shown.
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 not shown.
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 2b3c57d

Please sign in to comment.