Add unit/component tests for proclamation admin forms

Server tests cover load content stripping per role and upsert/delete
role enforcement. Client tests verify field rendering, pre-fill on
edit, content visibility per role, and submit button dirty-state.

Switched selects from bind:value/value to selected attribute pattern
to work around Svelte 5 select value reactivity in test env.
This commit is contained in:
NeilClack
2026-07-07 22:27:19 -05:00
parent 9ddad9d834
commit f7d255b744
3 changed files with 318 additions and 8 deletions
@@ -108,14 +108,17 @@
<select
id="field-solfeggioFrequencyId"
name="solfeggioFrequencyId"
bind:value={solfeggioFrequencyId}
onchange={(e) => solfeggioFrequencyId = (e.target as HTMLSelectElement).value}
class="w-full border px-3 py-1.5 text-sm {fieldErrors.solfeggioFrequencyId
? 'border-red-400'
: 'border-gray-300 dark:border-gray-600'} dark:bg-gray-800 dark:text-gray-100"
>
<option value="">-- Select Frequency --</option>
{#each relationOptionsData.solfeggioFrequencyId ?? [] as opt (String(opt.value))}
<option value={opt.value}>{opt.label}</option>
<option
value={opt.value}
selected={String(opt.value) === solfeggioFrequencyId}
>{opt.label}</option>
{/each}
</select>
{#if fieldErrors.solfeggioFrequencyId}
@@ -133,7 +136,6 @@
<select
id="field-parentCategoryId"
name="parentCategoryId"
value={parentCategoryId}
onchange={handleParentChange}
class="w-full border px-3 py-1.5 text-sm {fieldErrors.parentCategoryId
? 'border-red-400'
@@ -141,7 +143,10 @@
>
<option value="">-- Select Category --</option>
{#each parentOptions as cat (String(cat.id))}
<option value={cat.id}>{cat.name}</option>
<option
value={cat.id}
selected={String(cat.id) === parentCategoryId}
>{cat.name}</option>
{/each}
</select>
{#if fieldErrors.parentCategoryId}
@@ -159,14 +164,17 @@
<select
id="field-categoryId"
name="categoryId"
bind:value={categoryId}
onchange={(e) => categoryId = (e.target as HTMLSelectElement).value}
class="w-full border px-3 py-1.5 text-sm {fieldErrors.categoryId
? 'border-red-400'
: 'border-gray-300 dark:border-gray-600'} dark:bg-gray-800 dark:text-gray-100"
>
<option value="">-- Select Sub-Category --</option>
{#each childOptions as cat (String(cat.id))}
<option value={cat.id}>{cat.name}</option>
<option
value={cat.id}
selected={String(cat.id) === categoryId}
>{cat.name}</option>
{/each}
</select>
{#if fieldErrors.categoryId}
@@ -184,14 +192,17 @@
<select
id="field-subscriptionLevelId"
name="subscriptionLevelId"
bind:value={subscriptionLevelId}
onchange={(e) => subscriptionLevelId = (e.target as HTMLSelectElement).value}
class="w-full border px-3 py-1.5 text-sm {fieldErrors.subscriptionLevelId
? 'border-red-400'
: 'border-gray-300 dark:border-gray-600'} dark:bg-gray-800 dark:text-gray-100"
>
<option value="">-- Select Level --</option>
{#each relationOptionsData.subscriptionLevelId ?? [] as opt (String(opt.value))}
<option value={opt.value}>{opt.label}</option>
<option
value={opt.value}
selected={String(opt.value) === subscriptionLevelId}
>{opt.label}</option>
{/each}
</select>
{#if fieldErrors.subscriptionLevelId}