Skip to content

Commit 34eade4

Browse files
feat(ui): add XOR validation for social platform/URL entries
1 parent 86c4437 commit 34eade4

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/edit_python_pe/screens/member_form.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,16 @@ def save_member(self) -> None:
250250
has_errors = True
251251

252252
for se in self.social_entries:
253+
plat = se.select.value
253254
urlval = se.url_input.value.strip()
254-
if urlval and not URL_REGEX.match(urlval):
255+
256+
# XOR: if one is set but not the other
257+
if bool(plat) != bool(urlval):
258+
se.show_error(
259+
_("Both platform and URL must be provided if either is set.")
260+
)
261+
has_errors = True
262+
elif urlval and not URL_REGEX.match(urlval):
255263
se.show_error(_("Invalid URL format for social network."))
256264
has_errors = True
257265

tests/e2e/test_app_e2e.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async def test_full_app_flow(
6464
assert app.forked_repo is not None
6565

6666
# 4. Dashboard -> Add Member
67-
await pilot.click("#dash-add")
67+
app.screen.query_one("#dash-add").press()
6868
await pilot.pause()
6969
assert isinstance(app.screen, MemberFormScreen)
7070

@@ -80,6 +80,7 @@ async def test_full_app_flow(
8080
screen.homepage_input.value = "not_a_url"
8181
if screen.social_entries:
8282
screen.social_entries[-1].url_input.value = "not_a_social_url"
83+
screen.social_entries[-1].select.value = "github"
8384

8485
screen.action_save()
8586
await pilot.pause()
@@ -96,11 +97,13 @@ async def test_full_app_flow(
9697
screen.homepage_input.value = "https://example.com"
9798
if screen.social_entries:
9899
screen.social_entries[-1].url_input.value = "https://github.com/john"
100+
screen.social_entries[-1].select.value = "github"
101+
if screen.alias_entries:
102+
screen.alias_entries[-1].alias_input.value = "john-gh"
99103

100104
await pilot.pause()
101105
screen.action_save()
102106

103-
104107
# 6. Save Loading Screen — give up to 5 s for the background work
105108
for _ in range(50):
106109
await pilot.pause(0.1)

0 commit comments

Comments
 (0)