fix(KB-241): use form values for ntfy test notifications
- Update frontend API client to accept config parameter for testNtfyNotification - Modify SettingsModal to pass current form values when testing notifications - Update SettingsModal test to expect config object in API call - Add changeset documenting the test notification fix
This commit is contained in:
7
.changeset/fix-test-notification-ntfy.md
Normal file
7
.changeset/fix-test-notification-ntfy.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@dustinbyrne/kb": patch
|
||||
---
|
||||
|
||||
Fix test notification feature to use current form values instead of saved settings
|
||||
|
||||
Previously, clicking "Test notification" in settings would fail with a 400 error if ntfy was enabled in the form but not yet saved. The test notification now correctly uses the current form values (ntfyEnabled, ntfyTopic) when available, falling back to stored settings for backward compatibility.
|
||||
@@ -222,9 +222,10 @@ export function fetchSettingsByScope(): Promise<{ global: GlobalSettings; projec
|
||||
return api<{ global: GlobalSettings; project: Partial<ProjectSettings> }>("/settings/scopes");
|
||||
}
|
||||
|
||||
export function testNtfyNotification(): Promise<{ success: boolean }> {
|
||||
export function testNtfyNotification(config?: { ntfyEnabled?: boolean; ntfyTopic?: string }): Promise<{ success: boolean }> {
|
||||
return api<{ success: boolean }>("/settings/test-ntfy", {
|
||||
method: "POST",
|
||||
body: config ? JSON.stringify(config) : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,10 @@ export function SettingsModal({
|
||||
|
||||
setTestNotificationLoading(true);
|
||||
try {
|
||||
const result = await testNtfyNotification();
|
||||
const result = await testNtfyNotification({
|
||||
ntfyEnabled: form.ntfyEnabled,
|
||||
ntfyTopic: form.ntfyTopic,
|
||||
});
|
||||
if (result.success) {
|
||||
addToast("Test notification sent — check your ntfy app!", "success");
|
||||
} else {
|
||||
|
||||
@@ -1208,6 +1208,7 @@ describe("SettingsModal", () => {
|
||||
fireEvent.click(testButton);
|
||||
|
||||
await waitFor(() => expect(testNtfyNotification).toHaveBeenCalledTimes(1));
|
||||
expect(testNtfyNotification).toHaveBeenCalledWith({ ntfyEnabled: true, ntfyTopic: "my-valid-topic" });
|
||||
});
|
||||
|
||||
it("Success toast is shown when test notification succeeds", async () => {
|
||||
|
||||
Reference in New Issue
Block a user