Repository navigation
Feat/multi 607 608 610 611 #651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wagmiiii
merged 4 commits into
accensa:main
from
oladayo2222:feat/multi-607-608-610-611
Oct 18, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2b1a52e
test(auth): reject a wallet challenge signed by the wrong keypair (#607)
oladayo2222 44187d6
test(stores): test the consolidated store reporting route end to end …
oladayo2222 0882847
test(settings): unit test notification preferences permission and ton…
oladayo2222 e11b747
test(disputes): test evidence upload file guards and status announcem…
oladayo2222 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
126 changes: 126 additions & 0 deletions
126
apps/web/components/settings/NotificationPreferences.test.tsx
This file contains hidden or 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,126 @@ | ||
| // @vitest-environment jsdom | ||
| import React from 'react'; | ||
| import { render, screen, fireEvent, waitFor } from '@testing-library/react'; | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; | ||
| import { NotificationPreferences } from './NotificationPreferences'; | ||
|
|
||
| const { mockRequestNotificationPermission, mockPlayAudioAlert } = vi.hoisted(() => ({ | ||
| mockRequestNotificationPermission: vi.fn(), | ||
| mockPlayAudioAlert: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock('../../lib/notifications/desktopPush', () => ({ | ||
| requestNotificationPermission: mockRequestNotificationPermission, | ||
| playAudioAlert: mockPlayAudioAlert, | ||
| })); | ||
|
|
||
| describe('NotificationPreferences', () => { | ||
| const originalNotification = Reflect.get(window, 'Notification'); | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| Reflect.deleteProperty(window, 'Notification'); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| if (originalNotification === undefined) { | ||
| Reflect.deleteProperty(window, 'Notification'); | ||
| } else { | ||
| Reflect.set(window, 'Notification', originalNotification); | ||
| } | ||
| vi.restoreAllMocks(); | ||
| }); | ||
|
|
||
| it('renders default status and displays the enable button when window.Notification is absent', () => { | ||
| Reflect.deleteProperty(window, 'Notification'); | ||
|
|
||
| render(<NotificationPreferences />); | ||
|
|
||
| expect(screen.getByText('default')).toBeDefined(); | ||
| expect(screen.getByRole('button', { name: /enable push notifications/i })).toBeDefined(); | ||
| }); | ||
|
|
||
| it('does not display the enable button when Notification.permission is preset to granted', () => { | ||
| Reflect.set(window, 'Notification', { | ||
| permission: 'granted', | ||
| requestPermission: vi.fn(), | ||
| }); | ||
|
|
||
| render(<NotificationPreferences />); | ||
|
|
||
| expect(screen.getByText('granted')).toBeDefined(); | ||
| expect(screen.queryByRole('button', { name: /enable push notifications/i })).toBeNull(); | ||
| }); | ||
|
|
||
| it('updates status and keeps the enable button when permission resolves to denied, but removes it when granted', async () => { | ||
| Reflect.set(window, 'Notification', { | ||
| permission: 'default', | ||
| requestPermission: vi.fn(), | ||
| }); | ||
|
|
||
| mockRequestNotificationPermission.mockResolvedValueOnce('denied'); | ||
|
|
||
| render(<NotificationPreferences />); | ||
|
|
||
| const enableButton = screen.getByRole('button', { name: /enable push notifications/i }); | ||
| fireEvent.click(enableButton); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByText('denied')).toBeDefined(); | ||
| }); | ||
| expect(screen.getByRole('button', { name: /enable push notifications/i })).toBeDefined(); | ||
|
|
||
| mockRequestNotificationPermission.mockResolvedValueOnce('granted'); | ||
| fireEvent.click(enableButton); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByText('granted')).toBeDefined(); | ||
| expect(screen.queryByRole('button', { name: /enable push notifications/i })).toBeNull(); | ||
| }); | ||
| }); | ||
|
|
||
| it('unmounts tone controls on sound toggle uncheck and remounts with retained frequency on re-check', () => { | ||
| render(<NotificationPreferences />); | ||
|
|
||
| const slider = screen.getByRole('slider'); | ||
| fireEvent.change(slider, { target: { value: '650' } }); | ||
| expect(screen.getByText('650 Hz')).toBeDefined(); | ||
|
|
||
| const soundCheckbox = screen.getByRole('checkbox', { | ||
| name: /enable sound for incoming payments/i, | ||
| }); | ||
| expect(soundCheckbox).toBeChecked(); | ||
|
|
||
| // Uncheck sound toggle | ||
| fireEvent.click(soundCheckbox); | ||
|
|
||
| expect(screen.queryByRole('slider')).toBeNull(); | ||
| expect(screen.queryByText('650 Hz')).toBeNull(); | ||
| expect(screen.queryByRole('button', { name: /test audio tone/i })).toBeNull(); | ||
|
|
||
| // Re-check sound toggle | ||
| fireEvent.click(soundCheckbox); | ||
|
|
||
| const remountedSlider = screen.getByRole('slider') as HTMLInputElement; | ||
| expect(remountedSlider).toBeDefined(); | ||
| expect(remountedSlider.value).toBe('650'); | ||
| expect(screen.getByText('650 Hz')).toBeDefined(); | ||
| expect(screen.getByRole('button', { name: /test audio tone/i })).toBeDefined(); | ||
| }); | ||
|
|
||
| it('calls playAudioAlert with 800 when slider is moved to 800 and test audio button is clicked, and asserts bounds', () => { | ||
| render(<NotificationPreferences />); | ||
|
|
||
| const slider = screen.getByRole('slider'); | ||
| expect(slider.getAttribute('min')).toBe('200'); | ||
| expect(slider.getAttribute('max')).toBe('1000'); | ||
|
|
||
| fireEvent.change(slider, { target: { value: '800' } }); | ||
| expect(screen.getByText('800 Hz')).toBeDefined(); | ||
|
|
||
| const testToneButton = screen.getByRole('button', { name: /test audio tone/i }); | ||
| fireEvent.click(testToneButton); | ||
|
|
||
| expect(mockPlayAudioAlert).toHaveBeenCalledWith(800); | ||
| }); | ||
| }); |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n '"format(:check)?"|prettier' package.json pnpm-workspace.yaml apps/web/package.jsonRepository: accensa/accensa-app
Length of output: 306
Format
route.test.tswith Prettier.The CI log lists this file as a formatting failure. Run:
🤖 Prompt for AI Agents