Fix linting

This commit is contained in:
Maximilian Harz 2025-04-07 16:57:10 +02:00 committed by Ulf Gebhardt
parent 0f25d124d4
commit 9115497c92
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
2 changed files with 36 additions and 26 deletions

View File

@ -1,6 +1,6 @@
import Vuex from 'vuex'
import { mount } from '@vue/test-utils'
import {render, fireEvent, screen} from '@testing-library/vue'
import { render, fireEvent, screen } from '@testing-library/vue'
import Notifications from './notifications.vue'
const localVue = global.localVue
@ -12,7 +12,7 @@ describe('notifications.vue', () => {
beforeEach(() => {
mocks = {
$t: jest.fn(v => v),
$t: jest.fn((v) => v),
$apollo: {
mutate: jest.fn(),
},
@ -29,37 +29,37 @@ describe('notifications.vue', () => {
name: 'MyAccount',
emailNotificationSettings: [
{
type: "post",
type: 'post',
settings: [
{
name: "commentOnObservedPost",
name: 'commentOnObservedPost',
value: true,
},
{
name: "mention",
name: 'mention',
value: false,
}
},
],
},
{
type: "group",
type: 'group',
settings: [
{
name: "groupMemberJoined",
name: 'groupMemberJoined',
value: true,
},
{
name: "groupMemberLeft",
name: 'groupMemberLeft',
value: true,
},
{
name: "groupMemberRemoved",
name: 'groupMemberRemoved',
value: false,
},
{
name: "groupMemberRoleChanged",
name: 'groupMemberRoleChanged',
value: true,
}
},
],
},
],

View File

@ -3,7 +3,7 @@
<h2 class="title">{{ $t('settings.notifications.name') }}</h2>
<ds-space margin-bottom="small" v-for="topic in emailNotificationSettings" :key="topic.type">
<h3>{{ $t(`settings.notifications.${topic.type}`) }}</h3>
<div v-for="setting in topic.settings" :key="setting.name" >
<div v-for="setting in topic.settings" :key="setting.name">
<input :id="setting.name" type="checkbox" v-model="setting.value" />
<label :for="setting.name">{{ $t(`settings.notifications.${setting.name}`) }}</label>
</div>
@ -35,29 +35,37 @@ export default {
currentUser: 'auth/user',
}),
isSubmitDisabled() {
return this.emailNotificationSettings.every(
(topic) => topic.settings.every(setting => setting.value === this.currentUser.emailNotificationSettings.find(t => t.type === topic.type).settings.find(s => s.name === setting.name).value),
return this.emailNotificationSettings.every((topic) =>
topic.settings.every(
(setting) =>
setting.value ===
this.currentUser.emailNotificationSettings
.find((t) => t.type === topic.type)
.settings.find((s) => s.name === setting.name).value,
),
)
},
isCheckAllDisabled() {
return this.emailNotificationSettings.every(
(topic) => topic.settings.every(setting => setting.value),
return this.emailNotificationSettings.every((topic) =>
topic.settings.every((setting) => setting.value),
)
},
isUncheckAllDisabled() {
return this.emailNotificationSettings.every(
(topic) => topic.settings.every(setting => !setting.value),
return this.emailNotificationSettings.every((topic) =>
topic.settings.every((setting) => !setting.value),
)
},
},
created() {
this.emailNotificationSettings = [ ...this.currentUser.emailNotificationSettings.map(topic => ({
type: topic.type,
settings: topic.settings.map(setting => ({
name: setting.name,
value: setting.value,
this.emailNotificationSettings = [
...this.currentUser.emailNotificationSettings.map((topic) => ({
type: topic.type,
settings: topic.settings.map((setting) => ({
name: setting.name,
value: setting.value,
})),
})),
}))]
]
},
methods: {
...mapMutations({
@ -94,7 +102,9 @@ export default {
mutation: updateUserMutation(),
variables: {
id: this.currentUser.id,
emailNotificationSettings: this.transformToEmailSettingsInput(this.emailNotificationSettings),
emailNotificationSettings: this.transformToEmailSettingsInput(
this.emailNotificationSettings,
),
},
update: (_, { data: { UpdateUser } }) => {
const { emailNotificationSettings } = UpdateUser