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>2016-11-15 04:03:59 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2016-11-15 04:03:59 +0300
commit587cc39e0362719332d410b7a4d5ddcc68788eeb (patch)
treec982c369cdda542c3a4de08be11c893e5364838c /tests/UI/specs
parent64314b26dbc6619d535002bdb79b9e55d1fc87db (diff)
Update Marketplace to work with new API (#10799)
* starting to port marketplace to piwik 3 * updating tests * fix translation key * fix various issues * use material select * fix plugin upload * deprecate license_homepage plugin metadata and link to a LICENSE[.md|.txt] file if found (#10756) * deprecate license_homepage plugin metadata, and link to a LICENSE[.md|.txt] file if found * Make license view HTML only without menu * fix tests and update * fix some links did not work * we need to show warnings even when plugin is installed, not only when activated. otherwise it is not clear why something is not downloadable * fix install was not working * improved responsiveness of marketplace * fix more tests * fix search was shown when only a few plugins are there * fix ui tests * fix some translations * fix tests and remove duplicated test
Diffstat (limited to 'tests/UI/specs')
-rw-r--r--tests/UI/specs/Marketplace_spec.js265
1 files changed, 265 insertions, 0 deletions
diff --git a/tests/UI/specs/Marketplace_spec.js b/tests/UI/specs/Marketplace_spec.js
new file mode 100644
index 0000000000..dab2e3a5e6
--- /dev/null
+++ b/tests/UI/specs/Marketplace_spec.js
@@ -0,0 +1,265 @@
+/*!
+ * Piwik - free/libre analytics platform
+ *
+ * Screenshot tests for main, top and admin menus.
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+describe("Marketplace", function () {
+ this.timeout(0);
+
+ this.fixture = "Piwik\\Plugins\\Marketplace\\tests\\Fixtures\\SimpleFixtureTrackFewVisits";
+
+ var urlBase = '?module=Marketplace&action=overview&';
+ var paidPluginsUrl = urlBase + 'show=premium';
+ var themesUrl = urlBase + 'show=themes';
+ var pluginsUrl = urlBase;
+
+ var noLicense = 'noLicense';
+ var expiredLicense = 'expiredLicense';
+ var exceededLicense = 'exceededLicense';
+ var validLicense = 'validLicense';
+
+ function loadPluginDetailPage(page, pluginName, isFreePlugin)
+ {
+ page.load(isFreePlugin ? pluginsUrl : paidPluginsUrl);
+ page.click('.card-title [piwik-plugin-name="' + pluginName + '"]');
+ }
+
+ function captureSelector(done, screenshotName, test, selector)
+ {
+ expect.screenshot(screenshotName).to.be.captureSelector(selector, test, done);
+ }
+
+ function captureMarketplace(done, screenshotName, test, selector)
+ {
+ if (!selector) {
+ selector = '';
+ }
+
+ captureSelector(done, screenshotName, test, '.marketplace' + selector);
+ }
+
+ function captureWithNotification(done, screenshotName, test)
+ {
+ captureMarketplace(done, screenshotName, test, ',#notificationContainer');
+ }
+
+ function captureWithDialog(done, screenshotName, test)
+ {
+ captureSelector(done, screenshotName, test, '.ui-dialog:visible');
+ }
+
+ function assumePaidPluginsActivated()
+ {
+ testEnvironment.mockMarketplaceAssumePluginNamesActivated = ['CustomPlugin1','CustomPlugin2','PaidPlugin1','PaidPlugin2'];
+ testEnvironment.save();
+ }
+
+ function setEnvironment(mode, consumer)
+ {
+ if (mode === 'user') {
+ testEnvironment.idSitesViewAccess = [1];
+ } else {
+ // superuser
+ testEnvironment.idSitesViewAccess = [];
+ }
+
+ if (mode === 'multiUserEnvironment') {
+ testEnvironment.overrideConfig('General', 'multi_server_environment', '1');
+ } else {
+ testEnvironment.overrideConfig('General', 'multi_server_environment', '0');
+ }
+
+ testEnvironment.overrideConfig('General', 'enable_plugins_admin', '1');
+
+ delete testEnvironment.mockMarketplaceAssumePluginNamesActivated;
+
+ testEnvironment.consumer = consumer;
+ testEnvironment.mockMarketplaceApiService = 1;
+ testEnvironment.save();
+ }
+
+ ['superuser', 'user', 'multiUserEnvironment'].forEach(function (mode) {
+
+ if (mode !== 'user') {
+ it('should show available updates in plugins page', function (done) {
+ setEnvironment(mode, noLicense);
+
+ captureSelector(done, 'updates_' + mode, function (page) {
+ page.load('?module=CorePluginsAdmin&action=plugins&idSite=1&period=day&date=yesterday&activated=');
+ }, '#content .card:first');
+ });
+ }
+
+ it(mode + ' for a user without license key should be able to open paid plugins', function (done) {
+ setEnvironment(mode, noLicense);
+
+ captureMarketplace(done, 'paid_plugins_no_license_' + mode, function (page) {
+ page.load(paidPluginsUrl);
+ });
+ });
+
+ it(mode + ' for a user with license key should be able to open paid plugins', function (done) {
+ setEnvironment(mode, validLicense);
+
+ captureMarketplace(done, 'paid_plugins_with_license_' + mode, function (page) {
+ page.load(paidPluginsUrl);
+ });
+ });
+
+ it(mode + ' for a user with exceeded license key should be able to open paid plugins', function (done) {
+ setEnvironment(mode, exceededLicense);
+ assumePaidPluginsActivated();
+
+ captureMarketplace(done, 'paid_plugins_with_exceeded_license_' + mode, function (page) {
+ page.load(paidPluginsUrl);
+ });
+ });
+
+ it('should show themes page', function (done) {
+ setEnvironment(mode, validLicense);
+
+ captureMarketplace(done, 'themes_with_valid_license_' + mode, function (page) {
+ page.load(themesUrl);
+ });
+ });
+
+ it('should show free plugin details', function (done) {
+ setEnvironment(mode, noLicense);
+
+ captureWithDialog(done, 'free_plugin_details_' + mode, function (page) {
+ var isFree = true;
+ loadPluginDetailPage(page, 'TreemapVisualization', isFree);
+ });
+ });
+
+ it('should show paid plugin details when having no license', function (done) {
+ setEnvironment(mode, noLicense);
+
+ captureWithDialog(done, 'paid_plugin_details_no_license_' + mode, function (page) {
+ assumePaidPluginsActivated();
+ var isFree = false;
+ loadPluginDetailPage(page, 'PaidPlugin1', isFree);
+ });
+ });
+
+ it('should show paid plugin details when having valid license', function (done) {
+ setEnvironment(mode, validLicense);
+
+ captureWithDialog(done, 'paid_plugin_details_valid_license_' + mode + '_installed', function (page) {
+ assumePaidPluginsActivated();
+ var isFree = false;
+ loadPluginDetailPage(page, 'PaidPlugin1', isFree);
+ });
+ });
+
+ it('should show paid plugin details when having valid license', function (done) {
+ setEnvironment(mode, exceededLicense);
+
+ captureWithDialog(done, 'paid_plugin_details_exceeded_license_' + mode, function (page) {
+ assumePaidPluginsActivated();
+ var isFree = false;
+ loadPluginDetailPage(page, 'PaidPlugin1', isFree);
+ });
+ });
+ });
+
+ var mode = 'superuser';
+
+ it('should show a dialog showing a list of all possible plugins to install', function (done) {
+ setEnvironment(mode, validLicense);
+
+ captureSelector(done, mode + '_install_all_paid_plugins_at_once', function (page) {
+ page.load(pluginsUrl);
+ page.click('.installAllPaidPlugins');
+ }, '.modal.open');
+ });
+
+ it('should show an error message when invalid license key entered', function (done) {
+ setEnvironment(mode, noLicense);
+
+ captureWithNotification(done, mode + '_invalid_license_key_entered', function (page) {
+ page.load(pluginsUrl);
+ page.sendKeys('#license_key', 'invalid');
+ page.click('.marketplace-paid-intro'); // click outside so change event is triggered
+ page.click('#submit_license_key input');
+ });
+ });
+
+ it('should show a confirmation before removing a license key', function (done) {
+ setEnvironment(mode, validLicense);
+
+ captureSelector(done, mode + '_remove_license_key_confirmation', function (page) {
+ page.load(pluginsUrl);
+ page.click('#remove_license_key input');
+ }, '.modal.open');
+ });
+
+ it('should show a confirmation before removing a license key', function (done) {
+ setEnvironment(mode, noLicense);
+
+ captureMarketplace(done, mode + '_remove_license_key_confirmed', function (page) {
+ page.click('.modal.open .modal-footer a:contains(Yes)')
+ });
+ });
+
+ it('should show a success message when valid license key entered', function (done) {
+ setEnvironment(mode, noLicense);
+
+ captureMarketplace(done, mode + '_valid_license_key_entered', function (page) {
+ page.load(pluginsUrl);
+ page.sendKeys('#license_key', 'valid');
+ page.execCallback(function () {
+ setEnvironment(mode, validLicense);
+ });
+ page.click('#submit_license_key input');
+ });
+ });
+
+ it('should hide activate / deactivate buttons if plugins admin is disabled', function (done) {
+ setEnvironment(mode, noLicense);
+ testEnvironment.overrideConfig('General', 'enable_plugins_admin', '0');
+ testEnvironment.save();
+
+ captureMarketplace(done, mode + '_enable_plugins_admin', function (page) {
+ page.load(pluginsUrl);
+ });
+ });
+
+ it('should hide activate / deactivate buttons if plugins admin is disabled when also multi server environment is enabled', function (done) {
+ setEnvironment('multiUserEnvironment', noLicense);
+ testEnvironment.overrideConfig('General', 'enable_plugins_admin', '0');
+ testEnvironment.save();
+
+ captureMarketplace(done, mode + '_enable_plugins_admin_with_multiserver_enabled', function (page) {
+ page.load(pluginsUrl);
+ });
+ });
+
+ [expiredLicense, exceededLicense, validLicense, noLicense].forEach(function (consumer) {
+ it('should show a subscription overview for ' + consumer, function (done) {
+ setEnvironment('superuser', consumer);
+
+ captureSelector(done, 'subscription_overview_' + consumer, function (page) {
+ page.load('?module=Marketplace&action=subscriptionOverview');
+ }, '#content');
+ });
+ });
+
+ [noLicense, expiredLicense, exceededLicense].forEach(function (consumer) {
+ // when there is no license it should not show a warning! as it could be due to network problems etc
+ it('should show a warning if license is ' + consumer, function (done) {
+ setEnvironment('superuser', consumer);
+
+ assumePaidPluginsActivated();
+
+ captureSelector(done, 'notification_plugincheck_' + consumer, function (page) {
+ page.load('?module=UsersManager&action=index');
+ }, '#notificationContainer');
+ });
+ });
+
+}); \ No newline at end of file