Skip to content

Commit

Permalink
Various test improvements (#21181)
Browse files Browse the repository at this point in the history
* Ensure to wait til screenshoted element is visible

* remove skipped tests, as they are meanwhile tested in Live plugin

* remove some useless version checks

* remove some no expected assertion checks

* cs

* increase some test timeouts on ci

* ensure mouse position doesn't randomly affect Goals UI tests

* Ensure tests including images run on github

* Remove test for ssl database connection as it would never be executed anyway

* submodule update

* update expected test files, now that system tests including images run again

* use fixed timestamp for tests, so they don't fail when time changes while running
  • Loading branch information
sgiehl authored Aug 31, 2023
1 parent 73b6f79 commit b1e29db
Show file tree
Hide file tree
Showing 24 changed files with 120 additions and 185 deletions.
9 changes: 0 additions & 9 deletions plugins/CorePluginsAdmin/tests/Integration/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Piwik\Plugins\UsersManager\API;
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
use Piwik\Version;

class ApiTest extends IntegrationTestCase
{
Expand Down Expand Up @@ -49,10 +48,6 @@ public function setUp(): void

public function test_setSystemSettings_throwsIfNoPasswordConfirmation()
{
if (version_compare(Version::VERSION, '4.4.0-b1', '<')) {
$this->markTestSkipped('Skipping test since passwordConfirmation is optional until version 4.4.');
}

$this->expectException(\Exception::class);
$this->expectExceptionMessage('UsersManager_ConfirmWithPassword');

Expand All @@ -62,10 +57,6 @@ public function test_setSystemSettings_throwsIfNoPasswordConfirmation()

public function test_setSystemSettings_throwsIfPasswordConfirmationWrong()
{
if (version_compare(Version::VERSION, '4.4.0-b1', '<')) {
$this->markTestSkipped('Skipping test since passwordConfirmation is optional until version 4.4.');
}

$this->expectException(\Exception::class);
$this->expectExceptionMessage('UsersManager_CurrentPasswordNotCorrect');

Expand Down
Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file not shown.
3 changes: 3 additions & 0 deletions plugins/Goals/tests/UI/Goals_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe("Goals", function () {
await page.waitForTimeout(100);
await page.waitForSelector('.dimensionReport .dataTableVizGoals');
await page.waitForNetworkIdle();
await page.mouse.move(-10, -10);

var report = await page.$('.dimensionReport');
expect(await report.screenshot()).to.matchImage('goals_by_page_titles');
Expand All @@ -74,6 +75,7 @@ describe("Goals", function () {
await page.waitForTimeout(100);
await page.waitForSelector('.dimensionReport .dataTableVizGoals');
await page.waitForNetworkIdle();
await page.mouse.move(-10, -10);

var report = await page.$('.dimensionReport');
expect(await report.screenshot()).to.matchImage('goals_by_entry_pages');
Expand All @@ -87,6 +89,7 @@ describe("Goals", function () {
await page.waitForTimeout(100);
await page.waitForSelector('.dimensionReport .dataTableVizGoals');
await page.waitForNetworkIdle();
await page.mouse.move(-10, -10);

var report = await page.$('.dimensionReport');
expect(await report.screenshot()).to.matchImage('goals_by_entry_page_titles');
Expand Down
4 changes: 2 additions & 2 deletions plugins/Live/tests/UI/Live_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe("Live", function () {
it('should show action tooltip', async function() {
var action = await page.jQuery('.visitor-profile-visits li:first-child .visitor-profile-actions .action:first-child');
await action.hover();
await page.waitForSelector('.ui-tooltip');
await page.waitForSelector('.ui-tooltip', {visible: true});
await page.waitForTimeout(250);

const elem = await page.$('.ui-tooltip');
Expand All @@ -135,7 +135,7 @@ describe("Live", function () {
$('.card:first-child .visitor-log-visitor-profile-link').click();
});

await page.waitForSelector('.ui-dialog');
await page.waitForSelector('.ui-dialog', {visible: true});
await page.waitForNetworkIdle();
await page.mouse.move(-10, -10);

Expand Down
2 changes: 1 addition & 1 deletion plugins/TagManager
2 changes: 1 addition & 1 deletion tests/PHPUnit/Framework/Fixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Fixture extends \PHPUnit\Framework\Assert
{
const IMAGES_GENERATED_ONLY_FOR_OS = 'linux';
const IMAGES_GENERATED_FOR_PHP = '7.2';
const IMAGES_GENERATED_FOR_GD = '2.1.0';
const IMAGES_GENERATED_FOR_GD = '2.3.3';
const DEFAULT_SITE_NAME = 'Piwik test';

const ADMIN_USER_LOGIN = 'superUserLogin';
Expand Down
2 changes: 0 additions & 2 deletions tests/PHPUnit/Integration/AccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@ public function testCheckUserHasAdminAccessWithEmptyAccessNoSiteIdsGiven()

public function testCheckUserHasAdminAccessWithSomeAccessSuccessIdSitesAsString()
{
self::expectNotToPerformAssertions();

$mock = $this->createPartialMock(
'Piwik\Access',
array('getSitesIdWithAdminAccess')
Expand Down
30 changes: 0 additions & 30 deletions tests/PHPUnit/Integration/DbSSLTest.php

This file was deleted.

4 changes: 2 additions & 2 deletions tests/PHPUnit/Integration/FrontControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FrontControllerTest extends IntegrationTestCase
public function test_fatalErrorStackTracesReturned()
{
$url = Fixture::getRootUrl() . '/tests/resources/trigger-fatal.php?format=json';
$response = Http::sendHttpRequest($url, self::isCIEnvironment() ? 2 : 20);
$response = Http::sendHttpRequest($url, self::isCIEnvironment() ? 5 : 20);

$response = json_decode($response, $isAssoc = true);
$response['message'] = $this->cleanMessage($response['message']);
Expand All @@ -40,7 +40,7 @@ public function test_fatalErrorStackTracesReturned()
public function test_thrownExceptionInFrontControllerPrintsBacktrace()
{
$url = Fixture::getRootUrl() . '/tests/resources/trigger-fatal-exception.php?format=json';
$response = Http::sendHttpRequest($url, self::isCIEnvironment() ? 2 : 20);
$response = Http::sendHttpRequest($url, self::isCIEnvironment() ? 5 : 20);

$response = json_decode($response, $isAssoc = true);
$response['message'] = $this->cleanMessage($response['message']);
Expand Down
2 changes: 0 additions & 2 deletions tests/PHPUnit/Integration/SegmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,6 @@ public function test_getSelectQuery_whenJoinLogLinkVisitActionOnActionOnVisit()

private function assertQueryDoesNotFail($query)
{
self::expectNotToPerformAssertions();

Db::fetchAll($query['sql'], $query['bind']);
}

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit b1e29db

Please sign in to comment.