diff --git a/resources/assets/src/views/admin/Plugins.vue b/resources/assets/src/views/admin/Plugins.vue deleted file mode 100644 index 3ef0fdc9..00000000 --- a/resources/assets/src/views/admin/Plugins.vue +++ /dev/null @@ -1,163 +0,0 @@ - - - - - diff --git a/resources/assets/src/views/user/Report.vue b/resources/assets/src/views/user/Report.vue deleted file mode 100644 index ee345e88..00000000 --- a/resources/assets/src/views/user/Report.vue +++ /dev/null @@ -1,82 +0,0 @@ - - - diff --git a/resources/assets/tests/views/admin/Plugins.test.ts b/resources/assets/tests/views/admin/Plugins.test.ts deleted file mode 100644 index b1ff5e2a..00000000 --- a/resources/assets/tests/views/admin/Plugins.test.ts +++ /dev/null @@ -1,138 +0,0 @@ -import Vue from 'vue' -import { mount } from '@vue/test-utils' -import { flushPromises } from '../../utils' -import { showModal, toast } from '@/scripts/notify' -import Plugins from '@/views/admin/Plugins.vue' - -jest.mock('@/scripts/notify') - -test('render config button', async () => { - Vue.prototype.$http.get.mockResolvedValue([ - { - name: 'a', icon: {}, enabled: true, config: true, - }, - { - name: 'b', icon: {}, enabled: false, config: true, - }, - { - name: 'c', icon: {}, enabled: false, config: false, - }, - ]) - const wrapper = mount(Plugins) - await flushPromises() - - expect(wrapper.find('.info-box:nth-child(1) .fa-cog').exists()).toBeTrue() - expect(wrapper.find('.info-box:nth-child(2) .fa-cog').exists()).toBeFalse() - expect(wrapper.find('.info-box:nth-child(3) .fa-cog').exists()).toBeFalse() -}) - -test('enable plugin', async () => { - Vue.prototype.$http.get.mockResolvedValue([ - { - name: 'a', icon: {}, enabled: false, - }, - ]) - Vue.prototype.$http.post - .mockResolvedValueOnce({ - code: 1, message: '1', data: { reason: ['abc'] }, - }) - .mockResolvedValue({ code: 0, message: '0' }) - const wrapper = mount(Plugins) - await flushPromises() - const checkbox = wrapper.find('input[type=checkbox]') - - checkbox.trigger('click') - await flushPromises() - expect(Vue.prototype.$http.post).toBeCalledWith( - '/admin/plugins/manage', - { action: 'enable', name: 'a' }, - ) - expect(showModal).toBeCalledWith({ - mode: 'alert', - dangerousHTML: expect.stringContaining('
  • abc
  • '), - }) - - checkbox.trigger('click') - await flushPromises() - expect(toast.success).toBeCalled() -}) - -test('disable plugin', async () => { - Vue.prototype.$http.get.mockResolvedValue([ - { - name: 'a', icon: {}, enabled: true, - }, - ]) - Vue.prototype.$http.post - .mockResolvedValueOnce({ code: 1, message: '1' }) - .mockResolvedValue({ code: 0, message: '0' }) - const wrapper = mount(Plugins) - await flushPromises() - const checkbox = wrapper.find('input[type="checkbox"]') - - checkbox.trigger('click') - await flushPromises() - expect(Vue.prototype.$http.post).toBeCalledWith( - '/admin/plugins/manage', - { action: 'disable', name: 'a' }, - ) - checkbox.trigger('click') - await flushPromises() - expect(toast.success).toBeCalledWith('0') - expect(checkbox.attributes('checked')).toBeFalsy() -}) - -test('delete plugin', async () => { - Vue.prototype.$http.get.mockResolvedValue([ - { - name: 'a', - title: 'My Plugin', - icon: {}, - }, - ]) - Vue.prototype.$http.post - .mockResolvedValueOnce({ code: 1, message: '1' }) - .mockResolvedValue({ code: 0, message: '0' }) - showModal - .mockRejectedValueOnce(null) - .mockResolvedValue({ value: '' }) - const wrapper = mount(Plugins) - await flushPromises() - const button = wrapper.find('.plugin-actions a') - - button.trigger('click') - await flushPromises() - expect(showModal).toBeCalledWith({ - title: 'My Plugin', - text: 'admin.confirmDeletion', - okButtonType: 'danger', - }) - expect(Vue.prototype.$http.post).not.toBeCalled() - - button.trigger('click') - await flushPromises() - expect(Vue.prototype.$http.post).toBeCalledWith( - '/admin/plugins/manage', - { action: 'delete', name: 'a' }, - ) - expect(toast.error).toBeCalledWith('1') - - button.trigger('click') - await flushPromises() - expect(wrapper.text()).not.toContain('My Plugin') -}) - -test('readme link', async () => { - Vue.prototype.$http.get.mockResolvedValue([ - { - name: 'a', - readme: true, - icon: {}, - }, - ]) - const wrapper = mount(Plugins) - await flushPromises() - - const link = wrapper.find('.plugin-actions > a:nth-child(1)') - expect(link.attributes('href')).toBe('/admin/plugins/readme/a') -}) diff --git a/resources/assets/tests/views/user/Report.test.ts b/resources/assets/tests/views/user/Report.test.ts deleted file mode 100644 index a12dedf7..00000000 --- a/resources/assets/tests/views/user/Report.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import Vue from 'vue' -import { mount } from '@vue/test-utils' -import { flushPromises } from '../../utils' -import Report from '@/views/user/Report.vue' - -test('basic render', async () => { - Vue.prototype.$http.get.mockResolvedValue([ - { - id: 1, tid: 1, reason: 'abc', status: 1, - }, - ]) - const wrapper = mount(Report) - await flushPromises() - - expect(wrapper.find('a').attributes('href')).toBe('/skinlib/show/1') - expect(wrapper.text()).toContain('report.status.1') -})