fix(calendar): persist settings on PUT/POST
CI / test (push) Successful in 7m4s
CI / deploy-ift (push) Successful in 3m21s
CI / e2e-ift (push) Failing after 52s
CI / deploy-stage (push) Has been skipped
CI / e2e-stage (push) Has been skipped

Accept calendar.settings (e.g. week_patterns) in validate_update
and convert_field; apply on create like tags. Unblocks Front#42
pattern save which previously got 200 with empty settings.
This commit is contained in:
2026-07-29 15:00:55 +03:00
parent 7e14dbcf8b
commit faf251b11d
5 changed files with 93 additions and 3 deletions
@@ -23,6 +23,7 @@ test() ->
test_get_calendar_unauthorized(CalId),
test_get_calendar_not_found(Token),
test_update_calendar(Token, CalId),
test_update_calendar_settings(Token, CalId),
test_update_calendar_forbidden(OtherToken, CalId),
test_delete_calendar(Token, CalId),
test_delete_calendar_forbidden(OtherToken, CalId),
@@ -60,6 +61,26 @@ test_update_calendar(Token, CalId) ->
?assertEqual(<<"New desc">>, maps:get(<<"description">>, Updated)),
ct:pal(" OK").
test_update_calendar_settings(Token, CalId) ->
ct:pal(" TEST: Persist calendar.settings.week_patterns"),
Path = <<"/v1/calendars/", CalId/binary>>,
Settings = #{
<<"week_patterns">> => [
#{
<<"id">> => <<"pat1">>,
<<"name">> => <<"Mon-Fri">>,
<<"slots">> => [
#{<<"weekday">> => 1, <<"time">> => <<"10:00">>, <<"duration">> => 60, <<"title">> => <<"Open">>}
]
}
]
},
Updated = api_test_runner:client_put(Path, Token, #{settings => Settings}),
?assertEqual(Settings, maps:get(<<"settings">>, Updated)),
Got = api_test_runner:client_get(Path, Token),
?assertEqual(Settings, maps:get(<<"settings">>, Got)),
ct:pal(" OK").
test_update_calendar_forbidden(OtherToken, CalId) ->
ct:pal(" TEST: Update calendar by non-owner (403)"),
Path = <<"/v1/calendars/", CalId/binary>>,