Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Skip loading plugins temporarily" #97

Merged
merged 1 commit into from Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions spec/plugins_manager_spec.coffee
Expand Up @@ -65,7 +65,7 @@ describe 'PluginsManager', ->
@subject.session = @session

context 'when action is set to trigger a plugin', ->
xcontext 'and plugin is enabled', ->
context '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', ->
Expand Down Expand Up @@ -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]

xit 'retrieves the enabled plugins', ->
it '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

xit 'caches the retrieved plugins', ->
it 'caches the retrieved plugins', ->
@subject.notify('cancelOrder', { order_id: 1 })

expect(@subject.enabled_plugins).to.equal(@plugins_response.plugins)

xit 'loads the plugins', ->
it '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

xit 'makes analytics settings available to the plugins', ->
it 'makes analytics settings available to the plugins', ->
@subject.notify('cancelOrder', { order_id: 1 })

settings =
Expand All @@ -185,7 +185,7 @@ describe 'PluginsManager', ->
expect(window.sa_plugins.settings).to.eql(settings)

context 'when data is an object', ->
xit 'makes data public', ->
it 'makes data public', ->
@subject.notify('cancelOrder', { order_id: 1 })

expect(window.sa_plugins.analytics_plugin)
Expand All @@ -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', ->
xit 'makes data public', ->
it 'makes data public', ->
@subject.notify('cancelOrder', JSON.stringify({ order_id: 1 }))

expect(window.sa_plugins.analytics_plugin)
Expand All @@ -216,11 +216,11 @@ describe 'PluginsManager', ->
@subject.notify('cancelOrder', { order_id: 1 })
@subject.notify('cancelOrder', { order_id: 1 })

xit 'loads the plugins only once', ->
it '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

xit 'does not make multiple api calls', ->
it '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

Expand Down
1 change: 0 additions & 1 deletion src/plugins_manager.coffee
Expand Up @@ -21,7 +21,6 @@ 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
Expand Down