@@ -2363,6 +2363,102 @@ test("notification settings drive the Inbox badge and desktop alerts", async ({
23632363 await expect . poll ( getAppBadgeCount ) . toBe ( baseline ) ;
23642364} ) ;
23652365
2366+ test ( "Windows retries a false denied notification permission from settings" , async ( {
2367+ page,
2368+ } ) => {
2369+ await page . addInitScript ( ( ) => {
2370+ Object . defineProperty ( navigator , "platform" , {
2371+ configurable : true ,
2372+ value : "Win32" ,
2373+ } ) ;
2374+ ( window as Window & { isTauri ?: boolean } ) . isTauri = true ;
2375+ } ) ;
2376+ await page . goto ( "/" ) ;
2377+
2378+ await page . evaluate ( ( ) => {
2379+ (
2380+ window as Window & {
2381+ __BUZZ_E2E_SET_NOTIFICATION_PERMISSION__ ?: (
2382+ permission : NotificationPermission ,
2383+ requestResult ?: NotificationPermission ,
2384+ ) => void ;
2385+ }
2386+ ) . __BUZZ_E2E_SET_NOTIFICATION_PERMISSION__ ?.( "denied" , "granted" ) ;
2387+ } ) ;
2388+
2389+ await openSettings ( page , "notifications" ) ;
2390+ const desktopToggle = page . getByTestId ( "notifications-desktop-toggle" ) ;
2391+ const desktopState = page . getByTestId ( "notifications-desktop-state" ) ;
2392+
2393+ await desktopToggle . click ( ) ;
2394+ await expect ( desktopToggle ) . not . toBeChecked ( ) ;
2395+ await expect ( desktopState ) . toContainText ( "Blocked" ) ;
2396+
2397+ await desktopToggle . click ( ) ;
2398+ await expect ( desktopToggle ) . toBeChecked ( ) ;
2399+ await expect ( desktopState ) . toContainText ( "On" ) ;
2400+ await expect
2401+ . poll ( ( ) =>
2402+ page . evaluate (
2403+ ( ) =>
2404+ (
2405+ window as Window & {
2406+ __BUZZ_E2E_GET_NOTIFICATION_PERMISSION_REQUEST_COUNT__ ?: ( ) => number ;
2407+ }
2408+ ) . __BUZZ_E2E_GET_NOTIFICATION_PERMISSION_REQUEST_COUNT__ ?.( ) ?? 0 ,
2409+ ) ,
2410+ )
2411+ . toBe ( 1 ) ;
2412+ } ) ;
2413+
2414+ test ( "Windows boot-time recovery prevents false-denied from disabling persisted notifications" , async ( {
2415+ page,
2416+ } ) => {
2417+ // Simulates the scenario Joxyko reported: a persisted desktopEnabled=true
2418+ // is written off on every relaunch because the boot-time read sees the
2419+ // init shim's false "denied" before the app is registered as a notification
2420+ // sender. With the boot-time recovery in refreshPermission, the mount-time
2421+ // read should request once and see "granted", so the toggle stays on.
2422+ await page . addInitScript ( ( ) => {
2423+ Object . defineProperty ( navigator , "platform" , {
2424+ configurable : true ,
2425+ value : "Win32" ,
2426+ } ) ;
2427+ ( window as Window & { isTauri ?: boolean } ) . isTauri = true ;
2428+ } ) ;
2429+ await page . goto ( "/" ) ;
2430+
2431+ // Pre-seed a persisted desktopEnabled=true and set the shim to false-deny
2432+ // then grant on request — exactly what happens on a clean Windows relaunch.
2433+ await page . evaluate ( ( ) => {
2434+ const pubkey = ( window as Window & { __BUZZ_E2E_PUBKEY__ ?: string } )
2435+ . __BUZZ_E2E_PUBKEY__ ;
2436+ if ( pubkey ) {
2437+ window . localStorage . setItem (
2438+ `buzz-notification-settings.v2:${ pubkey } ` ,
2439+ JSON . stringify ( { desktopEnabled : true , homeBadgeEnabled : true , notifyWhileViewing : false , sounds : { } , slotAlertsEnabled : { } , slotAlertsSnapshot : null } ) ,
2440+ ) ;
2441+ }
2442+ (
2443+ window as Window & {
2444+ __BUZZ_E2E_SET_NOTIFICATION_PERMISSION__ ?: (
2445+ permission : NotificationPermission ,
2446+ requestResult ?: NotificationPermission ,
2447+ ) => void ;
2448+ }
2449+ ) . __BUZZ_E2E_SET_NOTIFICATION_PERMISSION__ ?.( "denied" , "granted" ) ;
2450+ } ) ;
2451+
2452+ await openSettings ( page , "notifications" ) ;
2453+ const desktopToggle = page . getByTestId ( "notifications-desktop-toggle" ) ;
2454+ const desktopState = page . getByTestId ( "notifications-desktop-state" ) ;
2455+
2456+ // The boot-time recovery should have fired during mount, so the toggle
2457+ // stays on without the user touching it.
2458+ await expect ( desktopState ) . toContainText ( "On" ) ;
2459+ await expect ( desktopToggle ) . toBeChecked ( ) ;
2460+ } ) ;
2461+
23662462test ( "desktop notification clicks open the matching forum thread" , async ( {
23672463 page,
23682464} ) => {
0 commit comments