From 0551a8c1b19f46fcd62909c379b0eaa888bc6c1d Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 16 Oct 2021 15:13:53 +0200 Subject: [PATCH 1/5] remove polyfills (this is the task of babel, not ours) remove unused portal-vue library --- frontend/package.json | 1 - frontend/src/plugins/dashboard-plugin.js | 4 - frontend/src/polyfills.js | 96 ------------------------ 3 files changed, 101 deletions(-) delete mode 100644 frontend/src/polyfills.js diff --git a/frontend/package.json b/frontend/package.json index 038bf8816..80b4ded54 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -54,7 +54,6 @@ "nouislider": "^12.1.0", "particles-bg-vue": "1.2.3", "perfect-scrollbar": "^1.3.0", - "portal-vue": "^2.1.7", "prettier": "^2.2.1", "qrcode": "^1.4.4", "quill": "^1.3.6", diff --git a/frontend/src/plugins/dashboard-plugin.js b/frontend/src/plugins/dashboard-plugin.js index 448675d20..892a2d93c 100755 --- a/frontend/src/plugins/dashboard-plugin.js +++ b/frontend/src/plugins/dashboard-plugin.js @@ -1,10 +1,7 @@ -import '@/polyfills' import GlobalComponents from './globalComponents' import GlobalDirectives from './globalDirectives' import SideBar from '@/components/SidebarPlugin' -import PortalVue from 'portal-vue' - import Toasted from 'vue-toasted' // vue-bootstrap @@ -32,7 +29,6 @@ export default { Vue.use(GlobalComponents) Vue.use(GlobalDirectives) Vue.use(SideBar) - Vue.use(PortalVue) Vue.use(BootstrapVue) Vue.use(IconsPlugin) Vue.use(VueMoment) diff --git a/frontend/src/polyfills.js b/frontend/src/polyfills.js deleted file mode 100644 index a743ee3e3..000000000 --- a/frontend/src/polyfills.js +++ /dev/null @@ -1,96 +0,0 @@ -/* eslint-disable */ -import 'es6-promise/auto' - -export default (function initPollyFills () { - if (!Array.prototype.find) { - Object.defineProperty(Array.prototype, 'find', { - value: function (predicate) { - // 1. Let O be ? ToObject(this value). - if (this == null) { - throw new TypeError('"this" is null or not defined'); - } - - var o = Object(this); - - // 2. Let len be ? ToLength(? Get(O, "length")). - var len = o.length >>> 0; - - // 3. If IsCallable(predicate) is false, throw a TypeError exception. - if (typeof predicate !== 'function') { - throw new TypeError('predicate must be a function'); - } - - // 4. If thisArg was supplied, let T be thisArg; else let T be undefined. - var thisArg = arguments[1]; - - // 5. Let k be 0. - var k = 0; - - // 6. Repeat, while k < len - while (k < len) { - // a. Let Pk be ! ToString(k). - // b. Let kValue be ? Get(O, Pk). - // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). - // d. If testResult is true, return kValue. - var kValue = o[k]; - if (predicate.call(thisArg, kValue, k, o)) { - return kValue; - } - // e. Increase k by 1. - k++; - } - - // 7. Return undefined. - return undefined; - } - }); - } - if (typeof Object.assign !== 'function') { - // Must be writable: true, enumerable: false, configurable: true - Object.defineProperty(Object, "assign", { - value: function assign (target, varArgs) { // .length of function is 2 - 'use strict'; - if (target == null) { // TypeError if undefined or null - throw new TypeError('Cannot convert undefined or null to object'); - } - - var to = Object(target); - - for (var index = 1; index < arguments.length; index++) { - var nextSource = arguments[index]; - - if (nextSource != null) { // Skip over if undefined or null - for (var nextKey in nextSource) { - // Avoid bugs when hasOwnProperty is shadowed - if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { - to[nextKey] = nextSource[nextKey]; - } - } - } - } - return to; - }, - writable: true, - configurable: true - }); - } - if (!String.prototype.startsWith) { - String.prototype.startsWith = function(search, pos) { - return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; - }; - } - if (!String.prototype.includes) { - String.prototype.includes = function(search, start) { - 'use strict'; - if (typeof start !== 'number') { - start = 0; - } - - if (start + search.length > this.length) { - return false; - } else { - return this.indexOf(search, start) !== -1; - } - }; - } -}()) From 97a43795272392af8cac5a6717f7b95f080a0349 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 16 Oct 2021 15:14:18 +0200 Subject: [PATCH 2/5] remove throttle.js since its not used at all --- frontend/src/util/throttle.js | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 frontend/src/util/throttle.js diff --git a/frontend/src/util/throttle.js b/frontend/src/util/throttle.js deleted file mode 100644 index d035cb748..000000000 --- a/frontend/src/util/throttle.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Simple throttle function that executes a passed function only once in the specified timeout - * @param handlerFunc - * @param [timeout] the throttle interval - */ -export function throttle(handlerFunc, timeout = 66) { - let resizeTimeout - if (!resizeTimeout) { - resizeTimeout = setTimeout(() => { - resizeTimeout = null - handlerFunc() - // The actualResizeHandler will execute at a rate of 15fps - }, timeout) - } -} From e539298c982be03f6f5755c38f494587265e9b60 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 16 Oct 2021 15:14:38 +0200 Subject: [PATCH 3/5] Test AuthLayout --- .../src/views/Layout/AuthLayout_gdd.spec.js | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 frontend/src/views/Layout/AuthLayout_gdd.spec.js diff --git a/frontend/src/views/Layout/AuthLayout_gdd.spec.js b/frontend/src/views/Layout/AuthLayout_gdd.spec.js new file mode 100644 index 000000000..aa05b772a --- /dev/null +++ b/frontend/src/views/Layout/AuthLayout_gdd.spec.js @@ -0,0 +1,51 @@ +import { mount } from '@vue/test-utils' +import AuthLayoutGdd from './AuthLayout_gdd' + +const localVue = global.localVue + +describe('AuthLayoutGdd', () => { + let wrapper + + const mocks = { + $i18n: { + locale: 'en', + }, + $t: jest.fn((t) => t), + $route: { + meta: { + hideFooter: false, + }, + }, + $store: { + state: {}, + commit: jest.fn(), + }, + } + + const stubs = { + // RouterLink: RouterLinkStub, + RouterView: true, + } + + const Wrapper = () => { + return mount(AuthLayoutGdd, { localVue, mocks, stubs }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('has no sidebar', () => { + expect(wrapper.find('nav#sidenav-main').exists()).not.toBeTruthy() + }) + + it('has a main content div', () => { + expect(wrapper.find('div.main-content').exists()).toBeTruthy() + }) + + it('has a footer inside the main content', () => { + expect(wrapper.find('div.main-content').find('footer.footer').exists()).toBeTruthy() + }) + }) +}) From f30e5388281c45fd57cb7a79a1a3acfc17d28ec5 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 16 Oct 2021 15:14:47 +0200 Subject: [PATCH 4/5] Test NotFoundPage --- frontend/src/views/NotFoundPage.spec.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 frontend/src/views/NotFoundPage.spec.js diff --git a/frontend/src/views/NotFoundPage.spec.js b/frontend/src/views/NotFoundPage.spec.js new file mode 100644 index 000000000..709b24807 --- /dev/null +++ b/frontend/src/views/NotFoundPage.spec.js @@ -0,0 +1,22 @@ +import { mount } from '@vue/test-utils' +import NotFoundPage from './NotFoundPage' + +const localVue = global.localVue + +describe('NotFoundPage', () => { + let wrapper + + const Wrapper = () => { + return mount(NotFoundPage, { localVue }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('has a svg', () => { + expect(wrapper.find('svg').exists()).toBeTruthy() + }) + }) +}) From 726cc0e6014ee85289ed577906abba03da9fe9c8 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 16 Oct 2021 15:14:57 +0200 Subject: [PATCH 5/5] Increase Coverage to 82 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1049aaccd..1efaf19d2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -344,7 +344,7 @@ jobs: report_name: Coverage Frontend type: lcov result_path: ./coverage/lcov.info - min_coverage: 76 + min_coverage: 82 token: ${{ github.token }} ##############################################################################