fix(channels): avoid expanding advanced settings for model mapping
- remove model mapping from advanced settings error detection so visible model configuration errors do not expand the advanced panel. - update the edit-time advanced settings auto-expand check to only depend on fields actually rendered in the advanced section. - add regression coverage to verify model_mapping errors are not classified as advanced settings errors.
This commit is contained in:
-1
@@ -205,7 +205,6 @@ function readAdvancedSettingsPreference(): boolean {
|
|||||||
|
|
||||||
function hasAdvancedSettingsValues(values: ChannelFormValues): boolean {
|
function hasAdvancedSettingsValues(values: ChannelFormValues): boolean {
|
||||||
return Boolean(
|
return Boolean(
|
||||||
values.model_mapping?.trim() ||
|
|
||||||
values.param_override?.trim() ||
|
values.param_override?.trim() ||
|
||||||
values.header_override?.trim() ||
|
values.header_override?.trim() ||
|
||||||
values.status_code_mapping?.trim() ||
|
values.status_code_mapping?.trim() ||
|
||||||
|
|||||||
@@ -49,6 +49,17 @@ describe('channel form errors', () => {
|
|||||||
assert.equal(hasAdvancedSettingsErrors(errors), false)
|
assert.equal(hasAdvancedSettingsErrors(errors), false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('does not treat model mapping errors as advanced settings errors', () => {
|
||||||
|
const errors = {
|
||||||
|
model_mapping: {
|
||||||
|
type: 'custom',
|
||||||
|
message: 'Invalid model mapping',
|
||||||
|
},
|
||||||
|
} satisfies FieldErrors<ChannelFormValues>
|
||||||
|
|
||||||
|
assert.equal(hasAdvancedSettingsErrors(errors), false)
|
||||||
|
})
|
||||||
|
|
||||||
test('classifies schema errors from invalid advanced JSON fields', () => {
|
test('classifies schema errors from invalid advanced JSON fields', () => {
|
||||||
const result = channelFormSchema.safeParse({
|
const result = channelFormSchema.safeParse({
|
||||||
...CHANNEL_FORM_DEFAULT_VALUES,
|
...CHANNEL_FORM_DEFAULT_VALUES,
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ const ADVANCED_SETTINGS_FIELDS = new Set<FieldPath<ChannelFormValues>>([
|
|||||||
'auto_ban',
|
'auto_ban',
|
||||||
'tag',
|
'tag',
|
||||||
'remark',
|
'remark',
|
||||||
'model_mapping',
|
|
||||||
'param_override',
|
'param_override',
|
||||||
'header_override',
|
'header_override',
|
||||||
'status_code_mapping',
|
'status_code_mapping',
|
||||||
|
|||||||
Reference in New Issue
Block a user