diff --git a/contentcuration/contentcuration/frontend/settings/pages/SettingsIndex.vue b/contentcuration/contentcuration/frontend/settings/pages/SettingsIndex.vue index 3950a6f140..add98d3e5b 100644 --- a/contentcuration/contentcuration/frontend/settings/pages/SettingsIndex.vue +++ b/contentcuration/contentcuration/frontend/settings/pages/SettingsIndex.vue @@ -17,10 +17,7 @@ - + + + +
+ + {{ $tr('offlineText') }} +
+
+ + + + + + + + diff --git a/contentcuration/contentcuration/frontend/shared/views/__tests__/StudioOfflineAlert.spec.js b/contentcuration/contentcuration/frontend/shared/views/__tests__/StudioOfflineAlert.spec.js new file mode 100644 index 0000000000..dd75eb51fa --- /dev/null +++ b/contentcuration/contentcuration/frontend/shared/views/__tests__/StudioOfflineAlert.spec.js @@ -0,0 +1,40 @@ +import { mount } from '@vue/test-utils'; +import StudioOfflineAlert from '../StudioOfflineAlert.vue'; +import storeFactory from 'shared/vuex/baseStore'; + +function makeWrapper() { + const store = storeFactory(); + return { + wrapper: mount(StudioOfflineAlert, { + store, + }), + store, + }; +} + +describe('StudioOfflineAlert', () => { + let wrapper, store; + + beforeEach(() => { + const setup = makeWrapper(); + wrapper = setup.wrapper; + store = setup.store; + }); + + it('displays alert component when offline', async () => { + store.state.connection.online = false; + await wrapper.vm.$nextTick(); + + expect(wrapper.find('[data-test="studio-offline-alert"]').exists()).toBe(true); + expect(wrapper.text()).toMatch( + 'You seem to be offline. Your changes will be saved once your connection is back', + ); + }); + + it('hides alert component when online', async () => { + store.state.connection.online = true; + await wrapper.vm.$nextTick(); + + expect(wrapper.find('[data-test="studio-offline-alert"]').exists()).toBe(false); + }); +});