diff --git a/webapp/components/ContributionForm/ContributionForm.spec.js b/webapp/components/ContributionForm/ContributionForm.spec.js index cce187a63..ce432fc42 100644 --- a/webapp/components/ContributionForm/ContributionForm.spec.js +++ b/webapp/components/ContributionForm/ContributionForm.spec.js @@ -58,6 +58,9 @@ describe('ContributionForm.vue', () => { back: jest.fn(), push: jest.fn(), }, + $env: { + CATEGORIES_ACTIVE: false, + }, } propsData = {} }) @@ -132,6 +135,7 @@ describe('ContributionForm.vue', () => { variables: { title: postTitle, content: postContent, + categoryIds: [], id: null, image: null, }, @@ -254,6 +258,7 @@ describe('ContributionForm.vue', () => { variables: { title: propsData.contribution.title, content: propsData.contribution.content, + categoryIds: [], id: propsData.contribution.id, image: { sensitive: false, diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index e25dd6b0f..3d4bb8e7c 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -126,9 +126,9 @@ export default { imageBlurred: { required: false }, categoryIds: { type: 'array', - required: true, + required: this.categoriesActive, validator: (_, value = []) => { - if (value.length === 0 || value.length > 3) { + if (this.categoriesActive && (value.length === 0 || value.length > 3)) { return [new Error(this.$t('common.validations.categories'))] } return [] diff --git a/webapp/pages/post/create.spec.js b/webapp/pages/post/create.spec.js index 951edba03..5bfae19ed 100644 --- a/webapp/pages/post/create.spec.js +++ b/webapp/pages/post/create.spec.js @@ -5,13 +5,13 @@ const localVue = global.localVue describe('create.vue', () => { let wrapper - let mocks - beforeEach(() => { - mocks = { - $t: jest.fn(), - } - }) + const mocks = { + $t: jest.fn(), + $env: { + CATEGORIES_ACTIVE: false, + }, + } describe('mount', () => { const Wrapper = () => {