Skip to content
Extraits de code Groupes Projets
Valider 02c42e61 rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Fixing UI tests by hardcoding plugins to load and removing admin_plugins...

Fixing UI tests by hardcoding plugins to load and removing admin_plugins screenshot test. Use actual mouse/keyboard events in UI screenshot testing.
parent d3a423d1
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -72,6 +72,60 @@ class Manager extends Singleton
'LeftMenu'
);
public static $pluginsToLoadForTests = array(
"CorePluginsAdmin",
"CoreAdminHome",
"CoreHome",
"Proxy",
"API",
"Widgetize",
"Transitions",
"LanguagesManager",
"Actions",
"Dashboard",
"MultiSites",
"Referrers",
"UserSettings",
"Goals",
"SEO",
"UserCountry",
"VisitsSummary",
"VisitFrequency",
"VisitTime",
"VisitorInterest",
"ExampleAPI",
"ExamplePlugin",
"ExampleRssWidget",
"Provider",
"Feedback",
"Login",
"UsersManager",
"SitesManager",
"Installation",
"CoreUpdater",
"ScheduledReports",
"UserCountryMap",
"Live",
"CustomVariables",
"PrivacyManager",
"ImageGraph",
"Annotations",
"MobileMessaging",
"Overlay",
"SegmentEditor",
"DevicesDetection",
"DBStats",
'ExampleUI',
"TasksTimetable",
"Morpheus",
"Zeitgeist",
"CustomAlerts",
"VisitorGenerator",
"SecurityInfo",
"ExampleSettingsPlugin",
"TreemapVisualization"
);
public function getCorePluginsDisabledByDefault()
{
return $this->corePluginsDisabledByDefault;
......@@ -401,7 +455,6 @@ class Manager extends Singleton
);
$listPlugins = array_unique($listPlugins);
foreach ($listPlugins as $pluginName) {
// Hide plugins that are never going to be used
if($this->isPluginBogus($pluginName)) {
continue;
......
......@@ -238,14 +238,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
protected static function getPluginsToLoadDuringTests()
{
$manager = \Piwik\Plugin\Manager::getInstance();
$toLoad = array();
foreach($manager->readPluginsDirectory() as $plugin) {
if($manager->isPluginBundledWithCore($plugin)) {
$toLoad[] = $plugin;
}
}
return $toLoad;
return \Piwik\Plugin\Manager::$pluginsToLoadForTests;
}
public function setUp()
......
......@@ -46,15 +46,7 @@ class Piwik_TestingEnvironment
$config->setTestEnvironment();
$pluginsToLoad = array(
"CorePluginsAdmin", "CoreAdminHome", "CoreHome", "Proxy", "API", "Widgetize", "Transitions",
"LanguagesManager", "Actions", "Dashboard", "MultiSites", "Referrers", "UserSettings", "Goals",
"SEO", "UserCountry", "VisitsSummary", "VisitFrequency", "VisitTime", "VisitorInterest",
"ExampleAPI", "ExamplePlugin", "ExampleRssWidget", "Provider", "Feedback", "Login", "UsersManager",
"SitesManager", "Installation", "CoreUpdater", "ScheduledReports", "UserCountryMap", "Live",
"CustomVariables", "PrivacyManager", "ImageGraph", "Annotations", "MobileMessaging",
"Overlay", "SegmentEditor", "DevicesDetection", "DBStats", 'ExampleUI'
);
$pluginsToLoad = \Piwik\Plugin\Manager::$pluginsToLoadForTests;
$config->Plugins = array('Plugins' => $pluginsToLoad);
$trackerPluginsToLoad = array(
......
Subproject commit b5614886ec0ff654b2af40ebf35c38965b4512e1
Subproject commit 1c925966e51fa668f7a0f71c6c59b41ebe4bfc9c
......@@ -168,6 +168,7 @@ abstract class UITest extends IntegrationTestCase
$output = implode("\n", $output);
if ($result !== 0
|| strpos($output, "ERROR") !== false
|| strpos($output, "Error") !== false
) {
echo self::CAPTURE_PROGRAM . " failed: " . $output . "\n\ncommand used: $cmd\n";
}
......
......@@ -21,27 +21,7 @@ Piwik_TestingEnvironment::addHooks();
define('PIWIK_ENABLE_DISPATCH', false);
include PIWIK_INCLUDE_PATH . '/index.php';
/**
* @return bool
*/
function loadAllPluginsButOneTheme()
{
// Load all plugins that are found so UI tests are really testing real world use case
$pluginsToEnable = \Piwik\Plugin\Manager::getInstance()->getAllPluginsNames();
$themesNotToEnable = array('ExampleTheme', 'LeftMenu', 'PleineLune');
$enableZeitgeist = !empty($_REQUEST['zeitgeist']);
if (!$enableZeitgeist) {
$themesNotToEnable[] = 'Zeitgeist';
}
$pluginsToEnable = array_diff($pluginsToEnable, $themesNotToEnable);
\Piwik\Config::getInstance()->Plugins['Plugins'] = $pluginsToEnable;
return $enableZeitgeist;
}
$enableZeitgeist = loadAllPluginsButOneTheme();
$enableZeitgeist = !empty($_REQUEST['zeitgeist']);
$controller = \Piwik\FrontController::getInstance();
$controller->init();
......
......@@ -4,6 +4,50 @@ var readFileSync = fs.readFileSync || fs.read;
var VERBOSE = false;
var PageFacade = function (webpage) {
this.webpage = webpage;
};
PageFacade.prototype = {
click: function (selector) {
var elementPosition = this._getPosition(selector);
this._clickImpl(elementPosition);
},
sendKeys: function (selector, keys) {
var elementPosition = this._getPosition(selector);
this._clickImpl(elementPosition);
this.webpage.sendEvent('keypress', keys);
},
mouseMove: function (selector) {
var position = this._getPosition(selector);
this.webpage.sendEvent('mousemove', position.x, position.y);
},
_clickImpl: function (position) {
this.webpage.sendEvent('click', position.x, position.y);
},
_getPosition: function (selector) {
return this.webpage.evaluate(function (selector) {
var element = window.jQuery(selector),
offset = element.offset();
return {
x: offset.left + element.width() / 2,
y: offset.top + element.height() / 2
};
}, selector);
},
evaluate: function (impl) {
return this.webpage.evaluate(function (js) {
var $ = window.jQuery;
eval("(" + js + ")();");
}, impl.toString());
}
};
var PageRenderer = function(data) {
this.start = new Date();
};
......@@ -92,8 +136,12 @@ PageRenderer.prototype = {
app.exit(1);
}, Math.max(1000 * 15 * this.screenshotCount, 1000 * 60 * 10));
},
};
_executeScreenJs: function (js) {
var page = new PageFacade(this.webpage);
eval(js);
}
};
var IntegrationTestRenderer = function(data) {
PageRenderer.call(this, data);
......@@ -135,10 +183,7 @@ IntegrationTestRenderer.prototype._saveCurrentScreen = function () {
var self = this;
this.webpage.open(this.url, function () {
if (self.jsToTest) {
self.webpage.evaluate(function (js) {
var $ = window.jQuery;
eval(js);
}, self.jsToTest);
self._executeScreenJs(self.jsToTest);
}
self._setNoAjaxCheckTimeout();
......@@ -213,10 +258,7 @@ UnitTestRenderer.prototype._saveCurrentScreen = function () {
console.log("SAVING " + outputPath + " at " + this._getElapsedExecutionTime());
this.webpage.evaluate(function (js) {
var $ = window.jQuery;
eval(js);
}, screenJs);
this._executeScreenJs(screenJs);
var self = this;
setTimeout(function () {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter