From a58a943171a196d8d69f9055b56541b7e0080f0d Mon Sep 17 00:00:00 2001 From: Daniel Bernal Date: Fri, 26 Jul 2024 21:41:47 +0200 Subject: [PATCH] [DuckPlayer] 13. Add openInfo message to Overlay (#3151) Task/Issue URL: https://app.asana.com/0/1204099484721401/1207905905078570/f Description: Add a new JS message handler Fixes a failing test --- DuckDuckGo/DuckPlayer/YoutubeOverlayUserScript.swift | 3 +++ DuckDuckGoTests/YoutublePlayerNavigationHandlerTests.swift | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/DuckDuckGo/DuckPlayer/YoutubeOverlayUserScript.swift b/DuckDuckGo/DuckPlayer/YoutubeOverlayUserScript.swift index 951d041a13..1ec899ca54 100644 --- a/DuckDuckGo/DuckPlayer/YoutubeOverlayUserScript.swift +++ b/DuckDuckGo/DuckPlayer/YoutubeOverlayUserScript.swift @@ -76,6 +76,7 @@ final class YoutubeOverlayUserScript: NSObject, Subfeature { static let openDuckPlayer = "openDuckPlayer" static let sendDuckPlayerPixel = "sendDuckPlayerPixel" static let initialSetup = "initialSetup" + static let openInfo = "openInfo" } weak var broker: UserScriptMessageBroker? @@ -108,6 +109,8 @@ final class YoutubeOverlayUserScript: NSObject, Subfeature { return handleSendJSPixel case Handlers.initialSetup: return duckPlayer.initialSetupOverlay + case Handlers.openInfo: + return duckPlayer.openDuckPlayerInfo default: assertionFailure("YoutubeOverlayUserScript: Failed to parse User Script message: \(methodName)") // TODO: Send pixel here diff --git a/DuckDuckGoTests/YoutublePlayerNavigationHandlerTests.swift b/DuckDuckGoTests/YoutublePlayerNavigationHandlerTests.swift index 2b19d9b41d..1bf0672f35 100644 --- a/DuckDuckGoTests/YoutublePlayerNavigationHandlerTests.swift +++ b/DuckDuckGoTests/YoutublePlayerNavigationHandlerTests.swift @@ -100,6 +100,7 @@ class DuckPlayerNavigationHandlerTests: XCTestCase { // MARK: - Decide policyFor Tests + @MainActor func testDecidePolicyForVideoWasAlreadyHandled() { @@ -108,7 +109,7 @@ class DuckPlayerNavigationHandlerTests: XCTestCase { let expectation = self.expectation(description: "Completion handler called") let playerSettings = MockDuckPlayerSettings(appSettings: mockAppSettings, privacyConfigManager: mockPrivacyConfig) let player = MockDuckPlayer(settings: playerSettings) - let handler = DuckPlayerNavigationHandler(duckPlayer: player) + let handler = DuckPlayerNavigationHandler(duckPlayer: player, featureFlagger: featureFlagger) var navigationPolicy: WKNavigationActionPolicy? handler.lastHandledVideoID = "abc123"