feat(native): the small things that give a WebView away

- A short haptic tap on success, warning and error toasts, which is where
  every save and delete already reports. Info toasts stay silent.
- No "‹ › Done" strip above the iOS keyboard.
- No Safari preview when a link is long-pressed.
- The swipe from the left edge goes back on iOS, through the same history
  Android's back button walks.
This commit is contained in:
Maurice
2026-09-24 13:11:25 +02:00
parent be211c22ed
commit 9a69b092e8
13 changed files with 100 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { Haptics, NotificationType } from '@capacitor/haptics'
import { toastHaptic } from './haptics'
import { isNativeApp } from './platform'
vi.mock('@capacitor/haptics', () => ({
Haptics: { notification: vi.fn() },
NotificationType: { Success: 'SUCCESS', Warning: 'WARNING', Error: 'ERROR' },
}))
vi.mock('./platform', () => ({ isNativeApp: vi.fn() }))
beforeEach(() => {
vi.mocked(Haptics.notification).mockReset().mockResolvedValue()
vi.mocked(isNativeApp).mockReturnValue(true)
})
describe('toastHaptic', () => {
it('taps for success, warning and error toasts in the app', () => {
toastHaptic('success')
toastHaptic('warning')
toastHaptic('error')
expect(vi.mocked(Haptics.notification).mock.calls.map(([o]) => o.type)).toEqual([
NotificationType.Success, NotificationType.Warning, NotificationType.Error,
])
})
it('stays still for info toasts and in a browser', () => {
toastHaptic('info')
vi.mocked(isNativeApp).mockReturnValue(false)
toastHaptic('success')
expect(Haptics.notification).not.toHaveBeenCalled()
})
it('does not let a missing vibrator surface as an error', async () => {
const debug = vi.spyOn(console, 'debug').mockImplementation(() => {})
vi.mocked(Haptics.notification).mockRejectedValue(new Error('not available'))
toastHaptic('error')
await vi.waitFor(() => expect(debug).toHaveBeenCalledWith('[haptics]', expect.any(Error)))
})
})