Merge pull request #812 from gradido/increase-coverage

feat: Increase Coverage Test Frontend
This commit is contained in:
Moriz Wahl 2021-09-16 12:16:43 +02:00 committed by GitHub
commit ae7665654a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 6 additions and 441 deletions

View File

@ -316,7 +316,7 @@ jobs:
report_name: Coverage Frontend report_name: Coverage Frontend
type: lcov type: lcov
result_path: ./coverage/lcov.info result_path: ./coverage/lcov.info
min_coverage: 61 min_coverage: 66
token: ${{ github.token }} token: ${{ github.token }}
############################################################################## ##############################################################################

View File

@ -1,79 +0,0 @@
<template>
<div id="accordion" role="tablist" aria-multiselectable="true" class="accordion">
<slot></slot>
</div>
</template>
<script>
export default {
name: 'collapse',
props: {
animationDuration: {
type: Number,
default: 250,
description: 'Collapse animation duration',
},
multipleActive: {
type: Boolean,
default: true,
description: 'Whether you can have multiple collapse items opened at the same time',
},
activeIndex: {
type: Number,
default: -1,
description: 'Active collapse item index',
},
},
provide() {
return {
animationDuration: this.animationDuration,
multipleActive: this.multipleActive,
addItem: this.addItem,
removeItem: this.removeItem,
deactivateAll: this.deactivateAll,
}
},
data() {
return {
items: [],
}
},
methods: {
addItem(item) {
const index = this.$slots.default.indexOf(item.$vnode)
if (index !== -1) {
this.items.splice(index, 0, item)
}
},
removeItem(item) {
const items = this.items
const index = items.indexOf(item)
if (index > -1) {
items.splice(index, 1)
}
},
deactivateAll() {
this.items.forEach((item) => {
item.active = false
})
},
activateItem() {
if (this.activeIndex !== -1) {
this.items[this.activeIndex].active = true
}
},
},
mounted() {
this.$nextTick(() => {
this.activateItem()
})
},
watch: {
activeIndex() {
this.activateItem()
},
},
}
</script>
<style scoped></style>

View File

@ -1,91 +0,0 @@
<template>
<b-card no-body>
<b-card-header role="tab" class="card-header" :aria-expanded="active">
<a
data-toggle="collapse"
data-parent="#accordion"
:href="`#${itemId}`"
@click.prevent="activate"
:aria-controls="`content-${itemId}`"
>
<slot name="title">{{ title }}</slot>
<i class="tim-icons icon-minimal-down"></i>
</a>
</b-card-header>
<collapse-transition :duration="animationDuration">
<div
v-show="active"
:id="`content-${itemId}`"
role="tabpanel"
:aria-labelledby="title"
class="collapsed"
>
<div class="card-body"><slot></slot></div>
</div>
</collapse-transition>
</b-card>
</template>
<script>
import { CollapseTransition } from 'vue2-transitions'
export default {
name: 'collapse-item',
components: {
CollapseTransition,
},
props: {
title: {
type: String,
default: '',
description: 'Collapse item title',
},
id: String,
},
inject: {
animationDuration: {
default: 250,
},
multipleActive: {
default: false,
},
addItem: {
default: () => {},
},
removeItem: {
default: () => {},
},
deactivateAll: {
default: () => {},
},
},
computed: {
itemId() {
return this.id || this.title
},
},
data() {
return {
active: false,
}
},
methods: {
activate() {
const wasActive = this.active
if (!this.multipleActive) {
this.deactivateAll()
}
this.active = !wasActive
},
},
mounted() {
this.addItem(this)
},
destroyed() {
if (this.$el && this.$el.parentNode) {
this.$el.parentNode.removeChild(this.$el)
}
this.removeItem(this)
},
}
</script>
<style></style>

View File

@ -1,8 +1,5 @@
import NavbarToggleButton from './Navbar/NavbarToggleButton' import NavbarToggleButton from './Navbar/NavbarToggleButton'
import Collapse from './Collapse/Collapse.vue'
import CollapseItem from './Collapse/CollapseItem.vue'
import SidebarPlugin from './SidebarPlugin' import SidebarPlugin from './SidebarPlugin'
export { SidebarPlugin, NavbarToggleButton, Collapse, CollapseItem } export { SidebarPlugin, NavbarToggleButton }

View File

@ -6,6 +6,8 @@ sendMock.mockResolvedValue('success')
const localVue = global.localVue const localVue = global.localVue
window.scrollTo = jest.fn()
describe('AccountOverview', () => { describe('AccountOverview', () => {
let wrapper let wrapper

View File

@ -1,183 +0,0 @@
<template>
<div class="pt-4 pb-4">
<b-tabs content-class="mt-3" class="display-4" fill>
<b-tab :title="names.thisMonth" active>
<b-row>
<b-col lg="3">
<b-input :label="$t('communitys.form.hours')">
<b-form-input
type="number"
size="lg"
placeholder="23"
style="font-size: xx-large; padding-left: 5px"
/>
</b-input>
<b-input :label="$t('communitys.form.date_period')">
<flat-pickr
class="form-control"
v-model="date"
:config="config"
style="font-size: 0.5em; padding-left: 5px"
></flat-pickr>
</b-input>
</b-col>
<b-col lg="9">
<b-input :label="$t('communitys.form.hours_report')">
<textarea
class="form-control"
rows="5"
@focus="textFocus"
style="font-size: x-large; padding-left: 20px"
></textarea>
</b-input>
</b-col>
</b-row>
<b-row>
<div ref="mydiv"></div>
</b-row>
<b-row>
<b-col md="6">
<b-button @click.prevent="newWorkForm" variant="warning">
+ {{ $t('communitys.form.more_hours') }}
</b-button>
</b-col>
<b-col md="6" class="text-right">
<b-button variant="success" @click.prevent="submitForm2">
{{ $t('communitys.form.submit') }}
</b-button>
</b-col>
</b-row>
</b-tab>
<b-tab :title="names.lastMonth"></b-tab>
<b-tab :title="names.beforLastMonth"></b-tab>
</b-tabs>
</div>
</template>
<script>
export default {
name: 'GDDAddWork2',
data() {
return {
date: null,
config: {
altInput: false,
dateFormat: 'd-m-Y',
minDate: this.$moment().startOf('month').format('DD.MM.YYYY'),
maxDate: this.$moment().format('DD.MM.YYYY'),
mode: 'range',
},
index: 0,
form: [],
stundenSumme: 0,
messages: [],
submitted: false,
days: {
thisMonth: this.$moment().month(this.$moment().month()).daysInMonth(),
lastMonth: this.$moment()
.month(this.$moment().month() - 1)
.daysInMonth(),
beforLastMonth: this.$moment()
.month(this.$moment().month() - 2)
.daysInMonth(),
},
names: {
thisMonth: this.$moment().month(this.$moment().month()).format('MMMM'),
lastMonth: this.$moment()
.month(this.$moment().month() - 1)
.format('MMMM'),
beforLastMonth: this.$moment()
.month(this.$moment().month() - 2)
.format('MMMM'),
},
formular: null,
}
},
created() {},
watch: {
$form: function () {
this.stunden(this.form)
},
},
mounted() {},
methods: {
stunden(hour, i, mon) {
let n = 0
this.stundenSumme = 0
for (n; n < this.form.length; n++) {
if (this.form[n] > 0) {
this.stundenSumme += parseInt(this.form[n])
}
}
this.messages.push({
id: this.index,
MonthsNumber: mon,
DaysNumber: i,
HoursNumber: hour,
DestinationText: '',
TextDecoded: '',
})
this.index++
},
addNewMessage: function () {
this.messages.push({
DaysNumber: '',
TextDecoded: '',
})
},
deleteNewMessage: function (event) {
this.form.splice(event, null)
this.messages.splice(this.index, 1)
this.index--
},
submitForm: function (e) {
// console.log('submitForm')
this.messages = [{ DaysNumber: '', TextDecoded: '' }]
this.submitted = true
},
textFocus() {
// console.log('textFocus TODO')
},
newWorkForm() {
this.formular = `
<b-col lg="3">
<b-input label="Stunden">
<b-form-input
type="number"
size="lg"
placeholder="0"
style="font-size: xx-large; padding-left: 20px"
/>
</b-input>
<b-input label="Datum / Zeitraum">
<flat-pickr
class="form-control"
v-model="date"
:config="config"
style="font-size: xx-large; padding-left: 20px"
></flat-pickr>
</b-input>
</b-col>
<b-col lg="9">
<b-input label="Arbeitsreport">
<textarea
class="form-control"
rows="5"
@focus="textFocus"
style="font-size: x-large; padding-left: 20px"
></textarea>
</b-input>
</b-col>
`
// console.log('newWorkForm TODO')
const myElement = this.$refs.mydiv
myElement.append(this.formular)
this.$compile(myElement)
this.formular = null
},
},
}
</script>

View File

@ -1,83 +0,0 @@
<template>
<div>
<b-list-group>
<b-list-group-item v-for="item in items" :key="item.id">
<div class="d-flex w-100 justify-content-between" @click="toogle(item)">
<b-icon
v-if="item.status == 'submitted'"
icon="clock-history"
class="m-1"
font-scale="2"
style="color: orange"
></b-icon>
<b-icon v-else icon="check2-all" class="m-1" font-scale="2" style="color: green"></b-icon>
<h2 class="text-muted">
<small>{{ item.datel }}</small>
- {{ item.text }}
</h2>
</div>
</b-list-group-item>
</b-list-group>
<hr />
<b-icon icon="clock-history" class="m-1" font-scale="2" style="color: orange"></b-icon>
Wartet auf Bestätigung |
<b-icon icon="check2-all" class="m-1" font-scale="2" style="color: green"></b-icon>
bestätigt
</div>
</template>
<script>
export default {
name: 'GddWorkTable',
data() {
return {
form: [],
items: [
{
id: 1,
text: 'Zwei Säcke Plastikmüll im Wald gesammelt',
datel: '12.12.2020 14:04',
status: 'submitted',
},
{
id: 2,
text: 'Frau Schmidt bei der Gartenarbeit geholfen.',
datel: '22.06.2020 22:23',
status: 'submitted',
},
{
id: 3,
text: 'Ein online Kurs für nachhaltiges Mülltrennen erstellt',
datel: '15.04.2020 12:55',
status: 'confirmed',
},
{
id: 4,
text: 'Gradido bei meinen Freunden vorgestellt',
datel: '10.03.2020 18:20',
status: 'confirmed',
},
],
}
},
methods: {
rowClass(item, type) {
if (!item || type !== 'row') return
if (item.status === 'received') return 'table-success'
if (item.status === 'sent') return 'table-warning'
if (item.status === 'earned') return 'table-primary'
},
toogle(item) {
// eslint-disable-next-line no-unused-vars
const temp =
'<b-collapse visible v-bind:id="item.id">xxx <small class="text-muted">porta</small></b-collapse>'
},
},
}
</script>
<style>
.el-table .cell {
padding-left: 0px;
padding-right: 0px;
}
</style>

View File

@ -3,6 +3,8 @@ import UserProfileTransactionList from './UserProfileTransactionList'
const localVue = global.localVue const localVue = global.localVue
window.scrollTo = jest.fn()
describe('UserProfileTransactionList', () => { describe('UserProfileTransactionList', () => {
let wrapper let wrapper