diff --git a/app/src/renderer/App.vue b/app/src/renderer/App.vue index 7dfd4402e5..93517417f1 100644 --- a/app/src/renderer/App.vue +++ b/app/src/renderer/App.vue @@ -8,6 +8,7 @@ modal-help session(v-else) notifications(:notifications='notifications' theme='cosmos') + modal-error(v-if="config.modals.error.active") + + diff --git a/app/src/renderer/styles/variables.styl b/app/src/renderer/styles/variables.styl index 264925f87a..0b5eeac2b7 100644 --- a/app/src/renderer/styles/variables.styl +++ b/app/src/renderer/styles/variables.styl @@ -87,6 +87,7 @@ h6 = 0.75rem // z-index z-layers = { + modalError: 1002, modalHelp: 1001, modal: 1000, appHeader: 100, diff --git a/app/src/renderer/vuex/modules/config.js b/app/src/renderer/vuex/modules/config.js index e2466c02fd..7d3dcc74cd 100644 --- a/app/src/renderer/vuex/modules/config.js +++ b/app/src/renderer/vuex/modules/config.js @@ -9,6 +9,9 @@ export default ({ commit }) => { // TODO: change to atom bondingDenom: 'fermion', modals: { + error: { + active: false + }, help: { active: false }, @@ -25,6 +28,9 @@ export default ({ commit }) => { setDevMode (state, value) { state.devMode = value }, + setModalError (state, value) { + state.modals.error.active = value + }, setModalHelp (state, value) { state.modals.help.active = value }, diff --git a/test/unit/specs/components/common/NiModalError.spec.js b/test/unit/specs/components/common/NiModalError.spec.js new file mode 100644 index 0000000000..3aa938102c --- /dev/null +++ b/test/unit/specs/components/common/NiModalError.spec.js @@ -0,0 +1,80 @@ +import { mount } from '@vue/test-utils' +import htmlBeautify from 'html-beautify' +import NiModalError from 'common/NiModalError' + +jest.mock('electron', () => ({ + remote: { + app: { + getPath: () => { return '$HOME' } + } + } +})) + +describe('NiModalError', () => { + let wrapper + + beforeEach(() => { + wrapper = mount(NiModalError) + }) + + it('has the expected html structure', () => { + expect(htmlBeautify(wrapper.html())).toMatchSnapshot() + }) + + it('has an icon', () => { + expect(wrapper.find('.ni-modal-error__icon i.material-icons').text().trim()) + .toBe('error_outline') + }) + + it('shows an icon if specified', () => { + wrapper = mount(NiModalError, { + propsData: { + icon: 'icon-x' + } + }) + expect(wrapper.find('.ni-modal-error__icon i.material-icons').text().trim()) + .toBe('icon-x') + }) + + it('has a title', () => { + expect(wrapper.find('.ni-modal-error__title').text().trim()) + .toBe('Voyager ran into an error') + }) + + it('shows a title if specified', () => { + wrapper = mount(NiModalError, { + propsData: { + title: 'title-x' + } + }) + expect(wrapper.find('.ni-modal-error__title').text().trim()) + .toBe('title-x') + }) + + it('has a body', () => { + expect(wrapper.find('.ni-modal-error__body').text().trim()) + .toContain('Voyager has encountered a critical error that blocks the app from running. Please create an issue and include a copy of the app logs.') + }) + + it('shows a body if specified', () => { + wrapper = mount(NiModalError, { + propsData: { + body: 'body-x' + } + }) + expect(wrapper.find('.ni-modal-error__body').text().trim()) + .toBe('body-x') + }) + + it('knows the path to the app log', () => { + expect(wrapper.vm.logPath).toBe('$HOME/.Cosmos/main.log') + }) + + it('has a button to create an issue', () => { + wrapper.find('#ni-modal-error__btn-issue').trigger('click') + }) + + it('has a button to view the app logs', () => { + wrapper.find('#ni-modal-error__btn-logs').trigger('click') + }) +}) diff --git a/test/unit/specs/components/common/__snapshots__/NiModalError.spec.js.snap b/test/unit/specs/components/common/__snapshots__/NiModalError.spec.js.snap new file mode 100644 index 0000000000..17525e7cc0 --- /dev/null +++ b/test/unit/specs/components/common/__snapshots__/NiModalError.spec.js.snap @@ -0,0 +1,22 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`NiModalError has the expected html structure 1`] = ` +"
+
+
+ error_outline +
+
+ Voyager ran into an error +
+
+ Voyager has encountered a critical error that blocks the app from running. Please create an issue and include a copy of the app logs. +
+
+ bug_reportCreate an issue +
+
+
" +`;