-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: maintain category order when updating notification preferences (#…
…370)
- Loading branch information
Showing
12 changed files
with
99 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@magicbell/magicbell-react': patch | ||
--- | ||
|
||
maintain order of categories and channels when updating notification preferences |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@magicbell/react-headless': patch | ||
--- | ||
|
||
return categories and category channels from useNotificationPreferences hook in stable order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
import { config, wsAuth } from './fake'; | ||
import { config, notificationPreferences, wsAuth } from './fake'; | ||
import { ablyAuth, ablyRequestToken } from './fake/ably'; | ||
import { mockHandler } from './mock-server'; | ||
|
||
async function updateNotificationPreferences(req) { | ||
const payload = await req.json(); | ||
const category = payload.categories[0]; | ||
return { | ||
notificationPreferences: { | ||
categories: notificationPreferences.categories.map((cat) => { | ||
if (cat.slug !== category.slug) return cat; | ||
return { | ||
...cat, | ||
channels: cat.channels.map((channel) => { | ||
if (channel.slug !== category.channels[0].slug) return channel; | ||
return category.channels[0]; | ||
}), | ||
}; | ||
}), | ||
}, | ||
}; | ||
} | ||
|
||
export const mockHandlers = [ | ||
mockHandler('get', '/config', config), | ||
mockHandler('post', '/ws/auth', wsAuth), | ||
mockHandler('get', '/notification_preferences', { notificationPreferences }), | ||
mockHandler('put', '/notification_preferences', updateNotificationPreferences), | ||
mockHandler('post', 'https://api.magicbell.com/ably/auth', ablyAuth), | ||
mockHandler('post', 'https://rest.ably.io/keys/:key/requestToken', ablyRequestToken), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'jest'; | ||
|
||
import { type TestingLibraryMatchers } from '@testing-library/jest-dom/matchers'; | ||
|
||
declare global { | ||
namespace jest { | ||
interface Matchers<R> extends TestingLibraryMatchers<ReturnType<typeof expect.stringContaining>, R> {} | ||
} | ||
} | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters