From 92d976ebaf3ccb64d4156e1dfc5d1a5322ea01c9 Mon Sep 17 00:00:00 2001 From: Alessandro Boron Date: Fri, 13 Dec 2024 15:26:55 +0100 Subject: [PATCH] Fix tests --- .../SpecialErrorPageNavigationHandler.swift | 2 +- ...iciousSiteProtectionNavigationHandlerTests.swift | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/DuckDuckGo/SpecialErrorPage/SpecialErrorPageNavigationHandler.swift b/DuckDuckGo/SpecialErrorPage/SpecialErrorPageNavigationHandler.swift index 5b6e5a659c..caad2b2096 100644 --- a/DuckDuckGo/SpecialErrorPage/SpecialErrorPageNavigationHandler.swift +++ b/DuckDuckGo/SpecialErrorPage/SpecialErrorPageNavigationHandler.swift @@ -148,7 +148,7 @@ extension SpecialErrorPageNavigationHandler: SpecialErrorPageUserScriptDelegate } func closeTab(shouldCreateNewTab: Bool) { - delegate?.closeSpecialErrorPageTab(shouldCreateNewEmptyTab: true) + delegate?.closeSpecialErrorPageTab(shouldCreateNewEmptyTab: shouldCreateNewTab) } guard let errorData else { return } diff --git a/DuckDuckGoTests/SpecialErrorPage/MaliciousSiteProtectionNavigationHandlerTests.swift b/DuckDuckGoTests/SpecialErrorPage/MaliciousSiteProtectionNavigationHandlerTests.swift index b166e299df..fededb2660 100644 --- a/DuckDuckGoTests/SpecialErrorPage/MaliciousSiteProtectionNavigationHandlerTests.swift +++ b/DuckDuckGoTests/SpecialErrorPage/MaliciousSiteProtectionNavigationHandlerTests.swift @@ -115,11 +115,11 @@ struct MaliciousSiteProtectionNavigationHandlerTests { @Test("Do not handle navigation when Threat is nil") func whenThreatKindIsNilThenReturnNavigationNotHandled() async throws { // GIVEN + mockMaliciousSiteProtectionManager.threatKind = nil let url = try #require(URL(string: "https://www.example.com")) let navigationAction = MockNavigationAction(request: URLRequest(url: url)) sut.createMaliciousSiteDetectionTask(for: navigationAction, webView: webView) let navigationResponse = MockNavigationResponse.with(url: url) - mockMaliciousSiteProtectionManager.threatKind = nil // WHEN let result = try #require(sut.getMaliciousSiteDectionTask(for: navigationResponse, webView: webView)) @@ -133,16 +133,16 @@ struct MaliciousSiteProtectionNavigationHandlerTests { "Handle known threat in Main Frame", arguments: [ ThreatKind.phishing, - .malware + .malware ] ) func whenThreatKindIsNotNil_AndNavigationIsMainFrame_ThenReturnNavigationHandledMainFrame(threat: ThreatKind) async throws { // GIVEN + mockMaliciousSiteProtectionManager.threatKind = threat let url = try #require(URL(string: "https://www.example.com")) let navigationAction = MockNavigationAction(request: URLRequest(url: url), targetFrame: MockFrameInfo(isMainFrame: true)) sut.createMaliciousSiteDetectionTask(for: navigationAction, webView: webView) let navigationResponse = MockNavigationResponse.with(url: url) - mockMaliciousSiteProtectionManager.threatKind = threat // WHEN let result = try #require(sut.getMaliciousSiteDectionTask(for: navigationResponse, webView: webView)) @@ -156,16 +156,16 @@ struct MaliciousSiteProtectionNavigationHandlerTests { "Handle known threat in IFrame", arguments: [ ThreatKind.phishing, - .malware + .malware ] ) func whenThreatKindIsNotNil_AndNavigationIsIFrame_ThenReturnNavigationHandledIFrame(threat: ThreatKind) async throws { // GIVEN + mockMaliciousSiteProtectionManager.threatKind = threat let url = try #require(URL(string: "https://www.example.com")) let navigationAction = MockNavigationAction(request: URLRequest(url: url), targetFrame: MockFrameInfo(isMainFrame: false)) sut.createMaliciousSiteDetectionTask(for: navigationAction, webView: webView) let navigationResponse = MockNavigationResponse.with(url: url) - mockMaliciousSiteProtectionManager.threatKind = threat // WHEN let result = try #require(sut.getMaliciousSiteDectionTask(for: navigationResponse, webView: webView)) @@ -178,7 +178,8 @@ struct MaliciousSiteProtectionNavigationHandlerTests { @Test( "Visit Site sets Exemption URL and Threat Kind", arguments: [ - ThreatKind.phishing, .malware + ThreatKind.phishing, + .malware ] ) func whenVisitSiteActionThenSetExemptionURLAndThreatKind(threat: ThreatKind) throws {