diff --git a/.gitignore b/.gitignore index 149d8d245..3d7f34078 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.log *.bak .turbo +vite.config.mjs.timestamp-* /node_modules/* messages.pot nbproject diff --git a/admin/package.json b/admin/package.json index 82528c3a2..fd2d0bddc 100644 --- a/admin/package.json +++ b/admin/package.json @@ -11,12 +11,15 @@ "start": "vite preview", "postbuild": "uname | grep -q Linux && find build -type f -regex '.*\\.\\(html\\|js\\|css\\|svg\\|json\\)' -exec gzip -9 -k {} + || echo 'Skip precompress on non-Linux'", "lint": "eslint --max-warnings=0 --ext .js,.vue,.json .", + "lint:fix": "eslint --max-warnings=0 --ext .js,.vue,.json . --fix", "stylelint": "stylelint --max-warnings=0 '**/*.{scss,vue}'", + "stylelint:fix": "stylelint --max-warnings=0 '**/*.{scss,vue}' --fix", "test": "cross-env TZ=UTC vitest run", "test:coverage": "cross-env TZ=UTC vitest run --coverage", "test:debug": "cross-env TZ=UTC node --inspect-brk ./node_modules/vitest/vitest.mjs", "test:watch": "cross-env TZ=UTC vitest", - "locales": "scripts/sort.sh" + "locales": "scripts/sort.sh", + "locales:fix": "scripts/sort.sh --fix" }, "dependencies": { "@iconify/json": "^2.2.228", diff --git a/admin/turbo.json b/admin/turbo.json index 27b122712..d6a0194e5 100644 --- a/admin/turbo.json +++ b/admin/turbo.json @@ -5,6 +5,11 @@ "locales": {}, "lint": { "dependsOn": ["stylelint", "locales"] + }, + "stylelint:fix": {}, + "locales:fix": {}, + "lint:fix": { + "dependsOn": ["stylelint:fix", "locales:fix"] } } } diff --git a/backend/package.json b/backend/package.json index 490f7aa0c..4dcd55f50 100644 --- a/backend/package.json +++ b/backend/package.json @@ -20,6 +20,7 @@ "lint:fix": "biome check --error-on-warnings . --write", "lint:fix:unsafe": "biome check --fix --unsafe", "locales": "scripts/sort.sh", + "locales:fix": "scripts/sort.sh --fix", "start": "cross-env TZ=UTC NODE_ENV=production node build/index.js", "typecheck": "tsc --noEmit" }, diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 3fe28c5e5..0fc5a2a09 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -177,7 +177,8 @@ export class ContributionResolver { } // filter out moderator messages for this call contribution.messages = contribution.messages?.filter( - (message) => (message.type as ContributionMessageType) !== ContributionMessageType.MODERATOR, + (message) => + (message.type as ContributionMessageType) !== ContributionMessageType.MODERATOR, ) return contribution }), diff --git a/backend/turbo.json b/backend/turbo.json index 7427fa978..e4dfea9a8 100644 --- a/backend/turbo.json +++ b/backend/turbo.json @@ -6,9 +6,13 @@ "cache": false }, "locales": {}, + "locales:fix": {}, "lint": { "dependsOn": ["locales", "database#build"] }, + "lint:fix": { + "dependsOn": ["locales:fix", "database#build"] + }, "typecheck": { "dependsOn": ["database#build", "config-schema#build"] }, diff --git a/frontend/package.json b/frontend/package.json index bd27fea29..429f14a11 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -9,12 +9,15 @@ "postbuild": "uname | grep -q Linux && find build -type f -regex '.*\\.\\(html\\|js\\|css\\|svg\\|json\\)' -exec gzip -9 -k {} + || echo 'Skip precompress on non-Linux'", "analyse-bundle": "yarn build && webpack-bundle-analyzer build/webpack.stats.json", "lint": "eslint --max-warnings=0 --ext .js,.vue,.json .", + "lint:fix": "eslint --max-warnings=0 --ext .js,.vue,.json . --fix", "stylelint": "stylelint --max-warnings=0 '**/*.{scss,vue}'", + "stylelint:fix": "stylelint --max-warnings=0 '**/*.{scss,vue}' --fix", "test": "cross-env TZ=UTC vitest run", "test:coverage": "cross-env TZ=UTC vitest run --coverage", "test:debug": "cross-env TZ=UTC node --inspect-brk ./node_modules/vitest/vitest.mjs", "test:watch": "cross-env TZ=UTC vitest", "locales": "scripts/sort.sh", + "locales:fix": "scripts/sort.sh --fix", "compile-scss": "sass --load-path=../node_modules --load-path=src/assets/scss src/assets/scss/gradido.scss src/assets/css/gradido.css", "watch-scss": "sass --watch --load-path=../node_modules --load-path=src/assets/scss src/assets/scss/gradido.scss src/assets/css/gradido.css" }, diff --git a/frontend/src/components/ContributionMessages/ContributionMessagesFormular.vue b/frontend/src/components/ContributionMessages/ContributionMessagesFormular.vue index 6738d84a9..69edcc5dc 100644 --- a/frontend/src/components/ContributionMessages/ContributionMessagesFormular.vue +++ b/frontend/src/components/ContributionMessages/ContributionMessagesFormular.vue @@ -3,13 +3,7 @@ {{ $t('form.reply') }}
- + {{ $t('form.cancel') }} @@ -39,7 +33,7 @@ const props = defineProps({ }, }) -const emit = defineEmits(['get-list-contribution-messages', 'add-contribution-message']) +const emit = defineEmits(['add-contribution-message']) const { t } = useI18n() const { toastSuccess, toastError } = useAppToast() @@ -62,7 +56,6 @@ async function onSubmit() { message: formText.value, }) - // emit('get-list-contribution-messages', false) formText.value = '' emit('add-contribution-message', result.data.createContributionMessage) toastSuccess(t('message.reply')) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 237d38c66..cb2a31c09 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -103,7 +103,7 @@ const props = defineProps({ maxGddThisMonth: { type: Number, required: true }, }) -const emit = defineEmits(['upsert-contribution', 'update:modelValue', 'abort']) +const emit = defineEmits(['upsert-contribution', 'abort']) const { t } = useI18n() diff --git a/frontend/src/components/Contributions/ContributionList.vue b/frontend/src/components/Contributions/ContributionList.vue index c43e7bc77..6badabbf9 100644 --- a/frontend/src/components/Contributions/ContributionList.vue +++ b/frontend/src/components/Contributions/ContributionList.vue @@ -53,10 +53,9 @@ const emit = defineEmits(['update-contribution-form']) // refs const currentPage = ref(1) - -// computed const openMessagesListId = ref(null) +// queries const { result, loading, refetch, onResult } = useQuery( listContributions, { @@ -77,6 +76,7 @@ const { result, loading, refetch, onResult } = useQuery( }, ) +// computed const contributionCount = computed(() => { return result.value?.listContributions.contributionCount || 0 }) @@ -85,6 +85,7 @@ const items = computed(() => { }) // callbacks +// scroll to anchor, if hash ist present in url and after data where loaded onResult(({ _data }) => { nextTick(() => { if (!route.hash) { diff --git a/frontend/src/pages/Community.spec.js b/frontend/src/pages/Community.spec.js index 4d1050a52..f39bc2725 100644 --- a/frontend/src/pages/Community.spec.js +++ b/frontend/src/pages/Community.spec.js @@ -1,12 +1,8 @@ import { useAppToast } from '@/composables/useToast' -import { countContributionsInProgress } from '@/graphql/contributions.graphql' -import { createContribution, deleteContribution, updateContribution } from '@/graphql/mutations' -import { listAllContributions, listContributions, openCreations } from '@/graphql/queries' -import { useMutation, useQuery } from '@vue/apollo-composable' +import { useQuery } from '@vue/apollo-composable' import { mount } from '@vue/test-utils' import { BTab, BTabs } from 'bootstrap-vue-next' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { reactive, ref } from 'vue' import { useRoute, useRouter } from 'vue-router' import Community from './Community' @@ -18,13 +14,10 @@ vi.mock('vue-router', () => ({ vi.mock('@vue/apollo-composable', () => ({ useQuery: vi.fn(), - useMutation: vi.fn(), })) vi.mock('@/composables/useToast', () => ({ useAppToast: vi.fn(() => ({ - toastError: vi.fn(), - toastSuccess: vi.fn(), toastInfo: vi.fn(), })), })) @@ -35,33 +28,6 @@ vi.mock('vue-i18n', () => ({ })), })) -vi.mock('vee-validate', () => ({ - useField: vi.fn(() => ({ - value: ref(''), - errorMessage: ref(''), - handleChange: vi.fn(), - meta: reactive({ - valid: true, - touched: false, - dirty: false, - }), - })), - useForm: vi.fn(() => ({ - handleSubmit: vi.fn(), - errors: reactive({}), - resetForm: vi.fn(), - })), - defineRule: vi.fn(), -})) - -// Mock child components -vi.mock('@/components/Contributions/OpenCreationsAmount', () => ({ - default: { - name: 'OpenCreationsAmount', - template: '
', - }, -})) - vi.mock('@/components/Contributions/ContributionEdit', () => ({ default: { name: 'ContributionEdit', @@ -96,61 +62,24 @@ describe('Community', () => { let mockToast const mockCountContributionsInProgress = vi.fn() - const mockOpenCreationsQuery = vi.fn() - const mockCreateContributionMutation = vi.fn() - const mockUpdateContributionMutation = vi.fn() - const mockDeleteContributionMutation = vi.fn() beforeEach(() => { mockRouter = { push: vi.fn() } vi.mocked(useRouter).mockReturnValue(mockRouter) mockToast = { - toastError: vi.fn(), - toastSuccess: vi.fn(), toastInfo: vi.fn(), } vi.mocked(useAppToast).mockReturnValue(mockToast) - vi.mocked(useQuery).mockImplementation((query) => { - if (query === openCreations) { - return { - onResult: mockOpenCreationsQuery, - refetch: vi.fn(), - } - } - - if (query === countContributionsInProgress) { - return { onResult: mockCountContributionsInProgress } - } - }) - - vi.mocked(useMutation).mockImplementation((mutation) => { - if (mutation === createContribution) { - return { - mutate: mockCreateContributionMutation, - } - } - if (mutation === updateContribution) { - return { - mutate: mockUpdateContributionMutation, - } - } - if (mutation === deleteContribution) { - return { - mutate: mockDeleteContributionMutation, - } - } - }) - - const { defineRule } = require('vee-validate') - defineRule('required', (value) => !!value) + vi.mocked(useQuery).mockImplementation((query) => ({ + onResult: mockCountContributionsInProgress, + })) wrapper = mount(Community, { global: { mocks: { $t: (key) => key, // Mock $t function - $d: (date) => date.toISOString(), // Mock $d function if needed }, components: { BTabs, diff --git a/frontend/turbo.json b/frontend/turbo.json index 434acaba2..77b247f01 100644 --- a/frontend/turbo.json +++ b/frontend/turbo.json @@ -6,6 +6,11 @@ "lint": { "dependsOn": ["stylelint", "locales"] }, + "stylelint:fix": {}, + "locales:fix": {}, + "lint:fix": { + "dependsOn": ["stylelint:fix", "locales:fix"] + }, "compile-scss": {}, "watch-scss": { "cache": false,