0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-22 17:24:41 +02:00
This commit is contained in:
Lunny Xiao 2025-12-29 18:34:16 -08:00
parent ce3755483d
commit a6eb361a23
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 5 additions and 9 deletions

View File

@ -488,8 +488,7 @@ func TestProjectWorkflowValidation(t *testing.T) {
var result map[string]any var result map[string]any
err = json.Unmarshal(resp.Body.Bytes(), &result) err = json.Unmarshal(resp.Body.Bytes(), &result)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "NoActions", result["error"], "Error should be NoActions") assert.Equal(t, "At least one action must be configured", result["errorMessage"])
assert.NotEmpty(t, result["message"], "Error message should be provided")
}) })
// Test 2: Try to update a workflow to have no actions (should fail) // Test 2: Try to update a workflow to have no actions (should fail)
@ -546,8 +545,7 @@ func TestProjectWorkflowValidation(t *testing.T) {
var result map[string]any var result map[string]any
err = json.Unmarshal(resp.Body.Bytes(), &result) err = json.Unmarshal(resp.Body.Bytes(), &result)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "NoActions", result["error"], "Error should be NoActions") assert.Equal(t, "At least one action must be configured", result["errorMessage"])
assert.NotEmpty(t, result["message"], "Error message should be provided")
// Verify the workflow was not changed // Verify the workflow was not changed
unchangedWorkflow, err := project_model.GetWorkflowByID(t.Context(), workflow.ID) unchangedWorkflow, err := project_model.GetWorkflowByID(t.Context(), workflow.ID)

View File

@ -241,7 +241,7 @@ export function createWorkflowStore(props: any): WorkflowStoreState {
); );
if (!hasAtLeastOneAction) { if (!hasAtLeastOneAction) {
showErrorToast(props.locale.atLeastOneActionRequired || 'At least one action must be configured'); showErrorToast(props.locale.atLeastOneActionRequired);
return; return;
} }
@ -268,10 +268,8 @@ export function createWorkflowStore(props: any): WorkflowStoreState {
let errorMessage = `${props.locale.failedToSaveWorkflow}: ${response.status} ${response.statusText}`; let errorMessage = `${props.locale.failedToSaveWorkflow}: ${response.status} ${response.statusText}`;
try { try {
const errorData = await response.json(); const errorData = await response.json();
if (errorData.message) { if (errorData.errorMessage) {
errorMessage = errorData.message; errorMessage = errorData.errorMessage;
} else if (errorData.error === 'NoActions') {
errorMessage = props.locale.atLeastOneActionRequired || 'At least one action must be configured';
} }
} catch { } catch {
const errorText = await response.text(); const errorText = await response.text();