Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2018-11-09 09:04:27 +0300
committerGitHub <noreply@github.com>2018-11-09 09:04:27 +0300
commit6c0b49387d58768d0cbbd0a50ea1b4b4b83b15e1 (patch)
treec9c80921fca2910699395b8675aaed4a8644b2ec /plugins/CorePluginsAdmin/tests
parent3bc57d6e4df80ff1969151d75a378ab2233f8067 (diff)
Add Matomo Tag Manager to core (#13402)
Diffstat (limited to 'plugins/CorePluginsAdmin/tests')
-rw-r--r--plugins/CorePluginsAdmin/tests/Integration/TagManagerTeaserTest.php106
-rw-r--r--plugins/CorePluginsAdmin/tests/UI/.gitignore2
-rw-r--r--plugins/CorePluginsAdmin/tests/UI/TagManagerTeaser_spec.js92
-rw-r--r--plugins/CorePluginsAdmin/tests/UI/expected-screenshots/.gitkeep0
-rw-r--r--plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page.png3
-rw-r--r--plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page_disable.png3
-rw-r--r--plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_super_user_activate_plugin.png3
-rw-r--r--plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_superuser_page.png3
8 files changed, 212 insertions, 0 deletions
diff --git a/plugins/CorePluginsAdmin/tests/Integration/TagManagerTeaserTest.php b/plugins/CorePluginsAdmin/tests/Integration/TagManagerTeaserTest.php
new file mode 100644
index 0000000000..7b28bf339e
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/Integration/TagManagerTeaserTest.php
@@ -0,0 +1,106 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Plugins\CorePluginsAdmin\tests\Integration;
+
+use Piwik\Plugin;
+use Piwik\Plugins\CorePluginsAdmin\Model\TagManagerTeaser;
+use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
+
+/**
+ * @group CorePluginsAdmin
+ * @group ApiTest
+ * @group Api
+ * @group Plugins
+ */
+class TagManagerTeaserTest extends IntegrationTestCase
+{
+ /**
+ * @var TagManagerTeaser
+ */
+ private $teaser;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ Plugin\Manager::getInstance()->deactivatePlugin('TagManager');
+
+ $this->teaser = $this->makeTeaser('mylogin');
+ }
+
+ private function makeTeaser($login)
+ {
+ return new TagManagerTeaser($login);
+ }
+
+ public function test_isEnabledGloballyByDefault()
+ {
+ $this->assertTrue($this->teaser->isEnabledGlobally());
+ }
+
+ public function test_disableGlobally()
+ {
+ $this->teaser->disableGlobally();
+ $this->assertFalse($this->teaser->isEnabledGlobally());
+ }
+
+ public function test_reset()
+ {
+ $this->teaser->disableGlobally();
+ $this->assertFalse($this->teaser->isEnabledGlobally());
+ $this->teaser->reset();
+ $this->assertTrue($this->teaser->isEnabledGlobally());
+ }
+
+ public function test_disableGlobally_removesUserSettings()
+ {
+ $this->teaser->disableForUser();
+ $this->assertFalse($this->teaser->isEnabledForUser());
+
+ $this->teaser->disableGlobally();
+
+ $this->assertFalse($this->teaser->isEnabledGlobally());
+ // should reset user enable flags cause disabled globally anyway
+ $this->assertTrue($this->teaser->isEnabledForUser());
+ }
+
+ public function test_isEnabledForCurrentUserByDefault()
+ {
+ $this->assertTrue($this->teaser->isEnabledForUser());
+ }
+
+ public function test_disableForUser()
+ {
+ $this->teaser->disableForUser();
+ $this->assertFalse($this->teaser->isEnabledForUser());
+
+ // still enabled globally
+ $this->assertTrue($this->teaser->isEnabledGlobally());
+
+ // still enabled for other user
+ $otherUser = $this->makeTeaser('foobar123');
+ $this->assertTrue($otherUser->isEnabledForUser());
+ }
+
+ public function test_shouldShowTeaser()
+ {
+ $this->assertTrue($this->teaser->shouldShowTeaser());
+ $this->assertTrue($this->teaser->isEnabledGlobally());
+ }
+
+ public function test_shouldShowTeaser_shouldNotBeShownWhenTagManagerEnabled()
+ {
+ Plugin\Manager::getInstance()->activatePlugin('TagManager');
+ $this->assertFalse($this->teaser->shouldShowTeaser());
+ // should have been disabled automatically
+ $this->assertFalse($this->teaser->isEnabledGlobally());
+ }
+
+
+}
diff --git a/plugins/CorePluginsAdmin/tests/UI/.gitignore b/plugins/CorePluginsAdmin/tests/UI/.gitignore
new file mode 100644
index 0000000000..f39be478e7
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/UI/.gitignore
@@ -0,0 +1,2 @@
+/processed-ui-screenshots
+/screenshot-diffs \ No newline at end of file
diff --git a/plugins/CorePluginsAdmin/tests/UI/TagManagerTeaser_spec.js b/plugins/CorePluginsAdmin/tests/UI/TagManagerTeaser_spec.js
new file mode 100644
index 0000000000..f892f42bed
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/UI/TagManagerTeaser_spec.js
@@ -0,0 +1,92 @@
+/*!
+ * 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("TagManagerTeaser", function () {
+ this.timeout(0);
+
+ var urlBase = '?module=CorePluginsAdmin&action=tagManagerTeaser&idSite=1&period=day&date=2010-01-03',
+ pageSelector = '.activateTagManager';
+
+ function setPluginsToLoad(plugins)
+ {
+ testEnvironment.pluginsToLoad = plugins
+ testEnvironment.save();
+ }
+
+ function unloadTagManager()
+ {
+ testEnvironment.unloadTagManager = 1;
+ testEnvironment.save();
+ }
+
+ function setAdminUser()
+ {
+ delete testEnvironment.idSitesViewAccess;
+ delete testEnvironment.idSitesWriteAccess;
+ testEnvironment.idSitesAdminAccess = [1];
+ testEnvironment.save();
+ }
+
+ function reset()
+ {
+ delete testEnvironment.idSitesViewAccess;
+ delete testEnvironment.idSitesWriteAccess;
+ delete testEnvironment.idSitesAdminAccess;
+ delete testEnvironment.idSitesCapabilities;
+ delete testEnvironment.unloadTagManager;
+ testEnvironment.save();
+ }
+
+ beforeEach(function () {
+ setPluginsToLoad(['CorePluginsAdmin']);
+ });
+
+ afterEach(reset);
+
+ function capturePage(done, screenshotName, test, selector)
+ {
+ if (!selector) {
+ selector = pageSelector;
+ }
+ expect.screenshot(screenshotName).to.be.captureSelector(selector, test, done);
+ }
+
+ it('should show teaser to super user', function (done) {
+ unloadTagManager();
+ capturePage(done, 'superuser_page', function (page) {
+ unloadTagManager();
+ page.load(urlBase);
+ });
+ });
+
+ it('should be possible to activate plugin and redirect to tag manager', function (done) {
+ capturePage(done, 'super_user_activate_plugin', function (page) {
+ page.click('.activateTagManager .activateTagManagerPlugin');
+ }, '.pageWrap');
+ });
+
+ it('should show teaser to admin', function (done) {
+ unloadTagManager();
+ setAdminUser();
+ capturePage(done, 'admin_page', function (page) {
+ unloadTagManager();
+ setAdminUser();
+ page.load(urlBase);
+ });
+ });
+
+ it('should be possible to disable page and redirect to home', function (done) {
+ capturePage(done, 'admin_page_disable', function (page) {
+ unloadTagManager();
+ setAdminUser();
+ page.click('.activateTagManager .dontShowAgainBtn');
+ }, '.pageWrap');
+ });
+
+}); \ No newline at end of file
diff --git a/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/.gitkeep b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/.gitkeep
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/.gitkeep
diff --git a/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page.png b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page.png
new file mode 100644
index 0000000000..73344efb78
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cd7ff984c4a1b5d341bdbf221f33f5ba0b82c4d65280f48a93ebd329c8412ae2
+size 156916
diff --git a/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page_disable.png b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page_disable.png
new file mode 100644
index 0000000000..caaeb7edee
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page_disable.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:72823683d6dcf3c3f423ca4519cfc33c9bc9166a31acde992a737b00bd9ddd2b
+size 142530
diff --git a/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_super_user_activate_plugin.png b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_super_user_activate_plugin.png
new file mode 100644
index 0000000000..7e962c324f
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_super_user_activate_plugin.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d4fcce39e90d28b3c78d311d50a546c7c6a30c52b028e4a3dce38daa4da395a0
+size 208986
diff --git a/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_superuser_page.png b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_superuser_page.png
new file mode 100644
index 0000000000..8a483e976d
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_superuser_page.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:0351e3a807ae93574d8d303a734a16b226bde1254929f8b3d9d11857f850a93e
+size 202635