diff --git a/integ_tests/test_sharing_config.py b/integ_tests/test_sharing_config.py index 15710268..e67f19e0 100644 --- a/integ_tests/test_sharing_config.py +++ b/integ_tests/test_sharing_config.py @@ -129,6 +129,59 @@ def test_sharing_config_save_and_reload( page.click('#createeditsharescene button[data-name="cancel"]') +def test_sharing_config_bday_save_empty_reenter_edit_age( + context: BrowserContext, page: Page, radicale_server: str, config: Config +) -> None: + _create_addressbook_and_open_share( + context, page, radicale_server, config, "Addressbook for Empty Bday Edit" + ) + + # Select Birthday conversion + page.click('label[for="newshare_conv_bday"]') + + # Fill share map fields (user and href) + page.locator('input[data-name="shareuser"]').fill("max") + page.locator('input[data-name="sharehref"]').fill("mapped-bday-empty-reenter") + + # Save immediately without setting any config + page.click('#createeditsharescene button[data-name="submit"]') + + # Verify share created + expect( + page.locator("tr[data-name='sharemaprowtemplate']:not(.hidden)") + ).to_have_count(1) + + # Re-open share in edit mode + page.click( + "tr[data-name='sharemaprowtemplate']:not(.hidden) button[data-name='edit']", + strict=True, + ) + + # Change max age config value (previously triggered SyntaxError: JSON.parse: unexpected character) + page.locator("#newshare_config_conversion_bday_age_max").fill("123") + + # Save + page.click('#createeditsharescene button[data-name="submit"]') + + # Verify share updated and returned to share collection scene + expect( + page.locator("tr[data-name='sharemaprowtemplate']:not(.hidden)") + ).to_have_count(1) + + # Re-open share in edit mode again to verify it saved + page.click( + "tr[data-name='sharemaprowtemplate']:not(.hidden) button[data-name='edit']", + strict=True, + ) + + expect(page.locator("#newshare_config_conversion_bday_age_max")).to_have_value( + "123" + ) + + page.click('#createeditsharescene button[data-name="cancel"]') + page.click('#sharecollectionscene button[data-name="cancel"]') + + def test_sharing_config_delete_checkbox( context: BrowserContext, page: Page, radicale_server: str, config: Config ) -> None: diff --git a/radicale/web/internal_data/js/scenes/CreateEditShareScene.js b/radicale/web/internal_data/js/scenes/CreateEditShareScene.js index fba41fcb..35eca406 100644 --- a/radicale/web/internal_data/js/scenes/CreateEditShareScene.js +++ b/radicale/web/internal_data/js/scenes/CreateEditShareScene.js @@ -309,7 +309,10 @@ export class CreateEditShareScene { /** @type {Record} */ let new_actions = {}; if (this._edit && this._share && this._share.Actions) { - new_actions = JSON.parse(JSON.stringify(this._share.Actions)); + let actions_json = JSON.stringify(this._share.Actions); + if (actions_json) { + new_actions = JSON.parse(actions_json); + } } if (conversion_value === "bday") { let new_config = new ShareConfig();