fix task remove label test

This commit is contained in:
Dominik Pschenitschni 2021-11-30 20:48:48 +01:00
parent 700fce3c2c
commit f3358269e5
Signed by: dpschen
GPG Key ID: B257AC0149F43A77
5 changed files with 19 additions and 23 deletions

View File

@ -373,13 +373,13 @@ describe('Task', () => {
cy.visit(`/tasks/${tasks[0].id}`) cy.visit(`/tasks/${tasks[0].id}`)
cy.get('.task-view .details.labels-list .multiselect .input-wrapper') cy.getSettled('.task-view .details.labels-list .multiselect .input-wrapper')
.should('be.visible') .should('be.visible')
.should('contain', labels[0].title) .should('contain', labels[0].title)
cy.get('.task-view .details.labels-list .multiselect .input-wrapper') cy.getSettled('.task-view .details.labels-list .multiselect .input-wrapper')
.children() .children()
.first() .first()
.get('a.delete') .get('[data-cy="taskDetail.removeLabel"]')
.click() .click()
cy.get('.global-notification') cy.get('.global-notification')

View File

@ -152,7 +152,7 @@
</template> </template>
<script> <script>
import AsyncEditor from '@/components/input/AsyncEditor' import Editor from '@/components/input/editor.vue'
import TaskCommentService from '../../../services/taskComment' import TaskCommentService from '../../../services/taskComment'
import TaskCommentModel from '../../../models/taskComment' import TaskCommentModel from '../../../models/taskComment'
@ -162,7 +162,7 @@ import {mapState} from 'vuex'
export default { export default {
name: 'comments', name: 'comments',
components: { components: {
editor: AsyncEditor, Editor,
}, },
props: { props: {
taskId: { taskId: {

View File

@ -30,7 +30,7 @@
</template> </template>
<script> <script>
import AsyncEditor from '@/components/input/AsyncEditor' import Editor from '@/components/input/editor.vue'
import {LOADING} from '@/store/mutation-types' import {LOADING} from '@/store/mutation-types'
import {mapState} from 'vuex' import {mapState} from 'vuex'
@ -38,7 +38,7 @@ import {mapState} from 'vuex'
export default { export default {
name: 'description', name: 'description',
components: { components: {
editor: AsyncEditor, Editor,
}, },
data() { data() {
return { return {

View File

@ -19,7 +19,7 @@
:style="{'background': props.item.hexColor, 'color': props.item.textColor}" :style="{'background': props.item.hexColor, 'color': props.item.textColor}"
class="tag"> class="tag">
<span>{{ props.item.title }}</span> <span>{{ props.item.title }}</span>
<a @click="removeLabel(props.item)" class="delete is-small"></a> <button type="button" v-cy="'taskDetail.removeLabel'" @click="removeLabel(props.item)" class="delete is-small" />
</span> </span>
</template> </template>
<template #searchResult="props"> <template #searchResult="props">
@ -114,23 +114,17 @@ export default {
}, },
async removeLabel(label) { async removeLabel(label) {
const removeFromState = () => { if (!this.taskId === 0) {
for (const l in this.labels) { await this.$store.dispatch('tasks/removeLabel', {label: label, taskId: this.taskId})
if (this.labels[l].id === label.id) { }
this.labels.splice(l, 1)
} for (const l in this.labels) {
if (this.labels[l].id === label.id) {
this.labels.splice(l, 1)
} }
this.$emit('update:modelValue', this.labels)
this.$emit('change', this.labels)
} }
this.$emit('update:modelValue', this.labels)
if (this.taskId === 0) { this.$emit('change', this.labels)
removeFromState()
return
}
await this.$store.dispatch('tasks/removeLabel', {label: label, taskId: this.taskId})
removeFromState()
this.$message.success({message: this.$t('task.label.removeSuccess')}) this.$message.success({message: this.$t('task.label.removeSuccess')})
}, },

View File

@ -453,8 +453,10 @@ import {CURRENT_LIST} from '@/store/mutation-types'
import {uploadFile} from '@/helpers/attachments' import {uploadFile} from '@/helpers/attachments'
import ChecklistSummary from '../../components/tasks/partials/checklist-summary' import ChecklistSummary from '../../components/tasks/partials/checklist-summary'
export default { export default {
name: 'TaskDetailView', name: 'TaskDetailView',
compatConfig: { ATTR_FALSE_VALUE: false },
components: { components: {
ChecklistSummary, ChecklistSummary,
TaskSubscription, TaskSubscription,