From 1a51978ea2d28b1e9f6fcdd5a3434c96750b4a62 Mon Sep 17 00:00:00 2001 From: xnerhu Date: Sun, 26 Nov 2023 16:55:16 +0100 Subject: [PATCH] fix testrs --- playground/index.ts | 2 ++ src/sources/notification_permissions.test.ts | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/playground/index.ts b/playground/index.ts index aa0ce36d..4a12bdaa 100644 --- a/playground/index.ts +++ b/playground/index.ts @@ -8,6 +8,7 @@ import { isDesktopWebKit, isIPad, } from '../src/utils/browser' +import { getBrowserVersion } from '../tests/utils' import './style.css' type DetectionResult = @@ -41,6 +42,7 @@ const runDetection = async (): Promise => { const debugData = { browserEngineKind: getBrowserEngineKind(), browserKind: getBrowserKind(), + browserVersion: getBrowserVersion(), documentFocus: getDocumentFocus(), mozAppearanceSupport: getMozAppearanceSupport(), isAndroid: isAndroid(), diff --git a/src/sources/notification_permissions.test.ts b/src/sources/notification_permissions.test.ts index 3074e5e0..3d4df20f 100644 --- a/src/sources/notification_permissions.test.ts +++ b/src/sources/notification_permissions.test.ts @@ -1,11 +1,19 @@ import { getBrowserMajorVersion, getBrowserVersion, isHeadlessChrome, isMobile, isWebKit } from '../../tests/utils' -import { BotdError, BrowserKind } from '../types' -import { getBrowserKind, isDesktopWebKit } from '../utils/browser' +import { BotdError, BrowserEngineKind, BrowserKind } from '../types' +import { getBrowserEngineKind, getBrowserKind, isDesktopWebKit } from '../utils/browser' import getNotificationPermissions from './notification_permissions' describe('Sources', () => { describe('notificaionPermissions', () => { it('returns an expected value or throws', async () => { + if ( + getBrowserKind() === BrowserKind.Safari && + getBrowserEngineKind() === BrowserEngineKind.Webkit && + !isDesktopWebKit() + ) { + return + } + const { major, minor } = getBrowserVersion() ?? { major: 0, minor: 0 } if (isWebKit() && (major < 16 || (major === 16 && minor < 5))) { await expectAsync(getNotificationPermissions()).toBeRejectedWithError( @@ -21,7 +29,7 @@ describe('Sources', () => { const result = await getNotificationPermissions() - if (isHeadlessChrome() || (isWebKit() && !isDesktopWebKit() && getBrowserKind() !== BrowserKind.Safari)) { + if (isHeadlessChrome() || isWebKit()) { // It's true because HeadlessChrome returns "denied" and not "default". expect(result).toBeTrue() return