diff --git a/frontend/src/components/Navbar/NavbarToggleButton.vue b/frontend/src/components/Navbar/NavbarToggleButton.vue deleted file mode 100644 index 5e6ab56b3..000000000 --- a/frontend/src/components/Navbar/NavbarToggleButton.vue +++ /dev/null @@ -1,21 +0,0 @@ - - - diff --git a/frontend/src/components/NavbarToggleButton.vue b/frontend/src/components/NavbarToggleButton.vue deleted file mode 100755 index 0f539df38..000000000 --- a/frontend/src/components/NavbarToggleButton.vue +++ /dev/null @@ -1,32 +0,0 @@ - - - diff --git a/frontend/src/components/SidebarPlugin/SideBar.spec.js b/frontend/src/components/SidebarPlugin/SideBar.spec.js deleted file mode 100644 index 7b12b6473..000000000 --- a/frontend/src/components/SidebarPlugin/SideBar.spec.js +++ /dev/null @@ -1,197 +0,0 @@ -import { mount, RouterLinkStub } from '@vue/test-utils' -import SideBar from './SideBar' - -const localVue = global.localVue - -const storeDispatchMock = jest.fn() - -describe('SideBar', () => { - let wrapper - - const stubs = { - RouterLink: RouterLinkStub, - } - - const propsData = { - balance: 1234.56, - } - - const mocks = { - $store: { - state: { - email: 'test@example.org', - publisherId: 123, - firstName: 'test', - lastName: 'example', - hasElopage: false, - }, - dispatch: storeDispatchMock, - }, - $i18n: { - locale: 'en', - }, - $t: jest.fn((t) => t), - $n: jest.fn((n) => n), - } - - const Wrapper = () => { - return mount(SideBar, { localVue, mocks, stubs, propsData }) - } - - describe('mount', () => { - beforeEach(() => { - wrapper = Wrapper() - }) - - it('renders the component', () => { - expect(wrapper.find('#sidenav-main').exists()).toBeTruthy() - }) - - describe('navbar button', () => { - it('has a navbar button', () => { - expect(wrapper.find('button.navbar-toggler').exists()).toBeTruthy() - }) - - it('calls showSidebar when clicked', async () => { - const spy = jest.spyOn(wrapper.vm.$sidebar, 'displaySidebar') - wrapper.find('button.navbar-toggler').trigger('click') - await wrapper.vm.$nextTick() - expect(spy).toHaveBeenCalledWith(true) - }) - }) - - describe('balance', () => { - it('shows em-dash as balance while loading', () => { - expect(wrapper.find('div.row.text-center').text()).toBe('— GDD') - }) - - it('shows the when loaded', async () => { - wrapper.setProps({ - pending: false, - }) - await wrapper.vm.$nextTick() - expect(wrapper.find('div.row.text-center').text()).toBe('1234.56 GDD') - }) - }) - - describe('close siedbar', () => { - it('calls closeSidebar when clicked', async () => { - const spy = jest.spyOn(wrapper.vm.$sidebar, 'displaySidebar') - wrapper.find('#sidenav-collapse-main').find('button.navbar-toggler').trigger('click') - await wrapper.vm.$nextTick() - expect(spy).toHaveBeenCalledWith(false) - }) - }) - - describe('static menu items', () => { - describe("member's area without publisher ID", () => { - it('has a link to the elopage', () => { - expect(wrapper.findAll('li').at(0).text()).toContain('members_area') - }) - - it('has a badge', () => { - expect(wrapper.findAll('li').at(0).text()).toContain('!') - }) - - it('links to the elopage registration', () => { - expect(wrapper.findAll('li').at(0).find('a').attributes('href')).toBe( - 'https://elopage.com/s/gradido/basic-de/payment?locale=en&prid=111&pid=123&firstName=test&lastName=example&email=test@example.org', - ) - }) - - describe('with locale="de"', () => { - beforeEach(() => { - mocks.$i18n.locale = 'de' - }) - - it('links to the German elopage registration when locale is set to de', () => { - expect(wrapper.findAll('li').at(0).find('a').attributes('href')).toBe( - 'https://elopage.com/s/gradido/basic-de/payment?locale=de&prid=111&pid=123&firstName=test&lastName=example&email=test@example.org', - ) - }) - }) - - describe("member's area with publisher ID", () => { - beforeEach(() => { - mocks.$store.state.hasElopage = true - }) - - it('links to the elopage member area', () => { - expect(wrapper.findAll('li').at(0).find('a').attributes('href')).toBe( - 'https://elopage.com/s/gradido/sign_in?locale=de', - ) - }) - - it('has no badge', () => { - expect(wrapper.findAll('li').at(0).text()).not.toContain('!') - }) - }) - - describe("member's area with default publisher ID and no elopage", () => { - beforeEach(() => { - mocks.$store.state.publisherId = null - mocks.$store.state.hasElopage = false - }) - - it('links to the elopage member area with default publisher ID', () => { - expect(wrapper.findAll('li').at(0).find('a').attributes('href')).toBe( - 'https://elopage.com/s/gradido/basic-de/payment?locale=de&prid=111&pid=2896&firstName=test&lastName=example&email=test@example.org', - ) - }) - - it('has a badge', () => { - expect(wrapper.findAll('li').at(0).text()).toContain('!') - }) - }) - }) - - describe('logout', () => { - it('has a logout button', () => { - expect(wrapper.findAll('li').at(1).text()).toBe('logout') - }) - - it('emits logout when logout is clicked', async () => { - wrapper.findAll('li').at(1).find('a').trigger('click') - await wrapper.vm.$nextTick() - expect(wrapper.emitted('logout')).toEqual([[]]) - }) - }) - - describe('admin-area', () => { - it('is not visible when not an admin', () => { - expect(wrapper.findAll('li').at(1).text()).not.toBe('admin_area') - }) - - describe('logged in as admin', () => { - const assignLocationSpy = jest.fn() - beforeEach(async () => { - mocks.$store.state.isAdmin = true - mocks.$store.state.token = 'valid-token' - window.location.assign = assignLocationSpy - wrapper = Wrapper() - }) - - it('is visible', () => { - expect(wrapper.findAll('li').at(1).text()).toBe('admin_area') - }) - - describe('click on admin area', () => { - beforeEach(async () => { - await wrapper.findAll('li').at(1).find('a').trigger('click') - }) - - it('opens a new window when clicked', () => { - expect(assignLocationSpy).toHaveBeenCalledWith( - 'http://localhost/admin/authenticate?token=valid-token', - ) - }) - - it('dispatches logout to store', () => { - expect(storeDispatchMock).toHaveBeenCalledWith('logout') - }) - }) - }) - }) - }) - }) -}) diff --git a/frontend/src/components/SidebarPlugin/SideBar.vue b/frontend/src/components/SidebarPlugin/SideBar.vue deleted file mode 100755 index 96882e816..000000000 --- a/frontend/src/components/SidebarPlugin/SideBar.vue +++ /dev/null @@ -1,145 +0,0 @@ - - - diff --git a/frontend/src/components/SidebarPlugin/SidebarItem.vue b/frontend/src/components/SidebarPlugin/SidebarItem.vue deleted file mode 100755 index 309af33b0..000000000 --- a/frontend/src/components/SidebarPlugin/SidebarItem.vue +++ /dev/null @@ -1,189 +0,0 @@ - - - diff --git a/frontend/src/components/SidebarPlugin/index.js b/frontend/src/components/SidebarPlugin/index.js deleted file mode 100755 index 4723f9952..000000000 --- a/frontend/src/components/SidebarPlugin/index.js +++ /dev/null @@ -1,41 +0,0 @@ -import Sidebar from './SideBar.vue' -import SidebarItem from './SidebarItem.vue' - -const SidebarStore = { - showSidebar: false, - sidebarLinks: [], - isMinimized: false, - displaySidebar(value) { - this.showSidebar = value - }, - toggleMinimize() { - document.body.classList.toggle('sidebar-mini') - const simulateWindowResize = setInterval(() => { - window.dispatchEvent(new Event('resize')) - }, 180) - - setTimeout(() => { - clearInterval(simulateWindowResize) - }, 1000) - - this.isMinimized = !this.isMinimized - }, -} - -const SidebarPlugin = { - install(Vue, options) { - if (options && options.sidebarLinks) { - SidebarStore.sidebarLinks = options.sidebarLinks - } - const app = new Vue({ - data: { - sidebarStore: SidebarStore, - }, - }) - Vue.prototype.$sidebar = app.sidebarStore - Vue.component('side-bar', Sidebar) - Vue.component('sidebar-item', SidebarItem) - }, -} - -export default SidebarPlugin diff --git a/frontend/src/components/index.js b/frontend/src/components/index.js deleted file mode 100755 index 656f05d91..000000000 --- a/frontend/src/components/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import NavbarToggleButton from './Navbar/NavbarToggleButton' - -import SidebarPlugin from './SidebarPlugin' - -export { SidebarPlugin, NavbarToggleButton } diff --git a/frontend/src/plugins/dashboard-plugin.js b/frontend/src/plugins/dashboard-plugin.js index 892a2d93c..d0113b631 100755 --- a/frontend/src/plugins/dashboard-plugin.js +++ b/frontend/src/plugins/dashboard-plugin.js @@ -1,6 +1,5 @@ import GlobalComponents from './globalComponents' import GlobalDirectives from './globalDirectives' -import SideBar from '@/components/SidebarPlugin' import Toasted from 'vue-toasted' @@ -28,7 +27,6 @@ export default { install(Vue) { Vue.use(GlobalComponents) Vue.use(GlobalDirectives) - Vue.use(SideBar) Vue.use(BootstrapVue) Vue.use(IconsPlugin) Vue.use(VueMoment) diff --git a/frontend/test/testSetup.js b/frontend/test/testSetup.js index 9ae5777ec..cb50ccdb6 100644 --- a/frontend/test/testSetup.js +++ b/frontend/test/testSetup.js @@ -8,7 +8,6 @@ import * as rules from 'vee-validate/dist/rules' import { messages } from 'vee-validate/dist/locale/en.json' import RegeneratorRuntime from 'regenerator-runtime' -import SideBar from '@/components/SidebarPlugin' import VueQrcode from 'vue-qrcode' import VueMoment from 'vue-moment' @@ -41,7 +40,6 @@ global.localVue.use(BootstrapVue) global.localVue.use(Vuex) global.localVue.use(IconsPlugin) global.localVue.use(RegeneratorRuntime) -global.localVue.use(SideBar) global.localVue.use(VueQrcode) global.localVue.use(VueMoment) global.localVue.component('validation-provider', ValidationProvider)