Skip to content

Commit

Permalink
Move test from core
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Sep 15, 2023
1 parent efd1d2a commit 68d2a48
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion templates/trackingCodeReact.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'</a>',
'<a target="_blank" rel="noreferrer noopener" href="https://matomo.org/faq/new-to-piwik/how-do-i-start-tracking-data-with-matomo-on-websites-that-use-react/">',
'</a>'
) }}
)|raw }}
</div>
{% endif %}

Expand Down
35 changes: 35 additions & 0 deletions tests/UI/EmptySite_React_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*!
* 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_React", function () {

this.fixture = "Piwik\\Tests\\Fixtures\\EmptySite";

const generalParams = 'idSite=1&period=day&date=2010-01-03';

it('should show the tracking code if the website has no recorded data and React guide', async function () {

testEnvironment.detectedContentDetections = ['ReactJs'];
testEnvironment.connectedConsentManagers = [];
testEnvironment.save();

const urlToTest = "?" + generalParams + "&module=CoreHome&action=index#?" + generalParams + '&activeTab=ReactJs';
await page.goto(urlToTest);
await page.waitForSelector('#start-tracking-details .codeblock', {visible: true});
await page.evaluate(function () {
// since containerID will be random and keeps changing
var selector = $('#reactjs .codeblock');
selector.text(selector.text().replace(/http(.*)container_(.*).js/g, 'http://localhost/js/container_test123.js'));
});

const pageElement = await page.$('.page');
expect(await pageElement.screenshot()).to.matchImage('emptySiteDashboard');
});

});
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 68d2a48

Please sign in to comment.