chore: do not require approval on an already accepted howto (#3614)

This commit is contained in:
benfurber
2024-05-30 14:15:59 +01:00
committed by GitHub
3 changed files with 11 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
import { faker } from '@faker-js/faker'
import { DifficultyLevel } from 'oa-shared'
import { DifficultyLevel, IModerationStatus } from 'oa-shared'
import {
HOWTO_STEP_DESCRIPTION_MAX_LENGTH,
@@ -109,6 +109,7 @@ describe('[How To]', () => {
_deleted: false,
category: 'Moulds',
description: 'After creating, the how-to will be deleted',
moderation: IModerationStatus.AWAITING_MODERATION,
difficulty_level: DifficultyLevel.MEDIUM,
time: '1-2 weeks',
title: 'Create a how-to test',
@@ -361,6 +362,7 @@ describe('[How To]', () => {
_createdBy: 'howto_editor',
_deleted: false,
category: 'exhibition',
moderation: IModerationStatus.ACCEPTED,
description: 'After editing, all changes are reverted',
difficulty_level: DifficultyLevel.HARD,
files: [],

View File

@@ -45,6 +45,7 @@ const eqHowto = (chaiObj) => {
title,
tags,
previousSlugs,
moderation,
} = expected
expect(subject, 'Basic info').to.containSubset({
_createdBy,
@@ -59,6 +60,8 @@ const eqHowto = (chaiObj) => {
})
expect(subject.category.label, 'Category').to.eq(category)
expect(subject.moderation).to.equal(moderation)
// We want to validate that uploaded filename matches that originally specified
// by the user. The filename will include a timestamp to avoid collisions with
// existing files that have been uploaded.

View File

@@ -94,9 +94,11 @@ export const HowtoForm = observer((props: IProps) => {
return
}
setState((state) => ({ ...state, showSubmitModal: true }))
formValues.moderation = formValues.allowDraftSave
? IModerationStatus.DRAFT
: IModerationStatus.AWAITING_MODERATION
if (formValues.moderation !== IModerationStatus.ACCEPTED) {
formValues.moderation = formValues.allowDraftSave
? IModerationStatus.DRAFT
: IModerationStatus.AWAITING_MODERATION
}
logger.debug('submitting form', formValues)
await howtoStore.uploadHowTo(formValues)
form.reset(formValues)