From bec5e687516524336482a8b755d9284b0446749a Mon Sep 17 00:00:00 2001 From: Alex Kyriakou Date: Mon, 25 Sep 2023 18:22:03 +0300 Subject: [PATCH] Skip loading plugins temporarily --- spec/plugins_manager_spec.coffee | 18 +++++++++--------- src/plugins_manager.coffee | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/spec/plugins_manager_spec.coffee b/spec/plugins_manager_spec.coffee index a012566f..9ff9143c 100644 --- a/spec/plugins_manager_spec.coffee +++ b/spec/plugins_manager_spec.coffee @@ -65,7 +65,7 @@ describe 'PluginsManager', -> @subject.session = @session context 'when action is set to trigger a plugin', -> - context 'and plugin is enabled', -> + xcontext 'and plugin is enabled', -> beforeEach -> @plugin = (plugin for plugin in @plugins_response.plugins when plugin.name is 'analytics_plugin')[0] it 'retrieves the enabled plugins', -> @@ -156,24 +156,24 @@ describe 'PluginsManager', -> @plugin_2 = (plugin for plugin in @plugins_response.plugins when plugin.name is 'analytics_plugin_2')[0] @not_enabled_plugin = (plugin for plugin in @plugins_response.plugins when plugin.name is 'not_enabled_plugin')[0] - it 'retrieves the enabled plugins', -> + xit 'retrieves the enabled plugins', -> data = shop_code: @session.shop_code @subject.notify('cancelOrder', { order_id: 1 }) expect(@jsonp_fetch_stub.withArgs(@plugins_settings.general.fetch_plugins_url, data).calledOnce).to.be.true - it 'caches the retrieved plugins', -> + xit 'caches the retrieved plugins', -> @subject.notify('cancelOrder', { order_id: 1 }) expect(@subject.enabled_plugins).to.equal(@plugins_response.plugins) - it 'loads the plugins', -> + xit 'loads the plugins', -> @subject.notify('cancelOrder', { order_id: 1 }) expect(@jsonp_load_stub.withArgs(@plugins_settings.plugins.analytics_plugin.url).calledOnce).to.be.true expect(@jsonp_load_stub.withArgs(@plugins_settings.plugins.analytics_plugin_2.url).calledOnce).to.be.true - it 'makes analytics settings available to the plugins', -> + xit 'makes analytics settings available to the plugins', -> @subject.notify('cancelOrder', { order_id: 1 }) settings = @@ -185,7 +185,7 @@ describe 'PluginsManager', -> expect(window.sa_plugins.settings).to.eql(settings) context 'when data is an object', -> - it 'makes data public', -> + xit 'makes data public', -> @subject.notify('cancelOrder', { order_id: 1 }) expect(window.sa_plugins.analytics_plugin) @@ -194,7 +194,7 @@ describe 'PluginsManager', -> .to.deep.equal({ order_id: 1, shop_code: @session.shop_code, analytics_session: @session.analytics_session, configuration: @plugin_2.configuration, data: @plugin_2.data }) context 'when data is json stringified', -> - it 'makes data public', -> + xit 'makes data public', -> @subject.notify('cancelOrder', JSON.stringify({ order_id: 1 })) expect(window.sa_plugins.analytics_plugin) @@ -216,11 +216,11 @@ describe 'PluginsManager', -> @subject.notify('cancelOrder', { order_id: 1 }) @subject.notify('cancelOrder', { order_id: 1 }) - it 'loads the plugins only once', -> + xit 'loads the plugins only once', -> expect(@jsonp_load_stub.withArgs(@plugins_settings.plugins.analytics_plugin.url).calledOnce).to.be.true expect(@jsonp_load_stub.withArgs(@plugins_settings.plugins.analytics_plugin_2.url).calledOnce).to.be.true - it 'does not make multiple api calls', -> + xit 'does not make multiple api calls', -> data = shop_code: @session.shop_code expect(@jsonp_fetch_stub.withArgs(@plugins_settings.general.fetch_plugins_url, data).calledOnce).to.be.true diff --git a/src/plugins_manager.coffee b/src/plugins_manager.coffee index acc0c9fb..aac36c98 100644 --- a/src/plugins_manager.coffee +++ b/src/plugins_manager.coffee @@ -21,6 +21,7 @@ define [ @param [Object, String] data Any additional data required by the plugins ### notify: (action, data) -> + return @_fetchEnabledPlugins().then => plugins = PluginsSettings.triggers[action] return unless plugins