0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-02-23 04:18:07 +01: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
err = json.Unmarshal(resp.Body.Bytes(), &result)
assert.NoError(t, err)
assert.Equal(t, "NoActions", result["error"], "Error should be NoActions")
assert.NotEmpty(t, result["message"], "Error message should be provided")
assert.Equal(t, "At least one action must be configured", result["errorMessage"])
})
// 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
err = json.Unmarshal(resp.Body.Bytes(), &result)
assert.NoError(t, err)
assert.Equal(t, "NoActions", result["error"], "Error should be NoActions")
assert.NotEmpty(t, result["message"], "Error message should be provided")
assert.Equal(t, "At least one action must be configured", result["errorMessage"])
// Verify the workflow was not changed
unchangedWorkflow, err := project_model.GetWorkflowByID(t.Context(), workflow.ID)

View File

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