Skip to content

Commit

Permalink
fixed some unit tests, submodule updated
Browse files Browse the repository at this point in the history
  • Loading branch information
federicocappelli committed Nov 16, 2023
1 parent fa933f1 commit f066d70
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo/MainViewController+Segues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ extension MainViewController {
hideAllHighlightsIfNeeded()

let brokenSiteInfo = currentTab?.getCurrentWebsiteInfo()
guard let currentURL = brokenSiteInfo?.url,
guard let currentURL = currentTab?.url,
let privacyInfo = currentTab?.makePrivacyInfo(url: currentURL) else {
assertionFailure("Missing fundamental data")
return
Expand Down
96 changes: 48 additions & 48 deletions DuckDuckGo/PrivacyDashboard/BrokenSiteInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,44 @@ public struct BrokenSiteInfo {

static let allowedQueryReservedCharacters = CharacterSet(charactersIn: ",")

enum Key: String {
case siteUrl
case category
case description
case upgradedHttps
case tds
case blockedTrackers
case surrogates
case atb
case os
case manufacturer
case model
case siteType
case gpc
case ampUrl
case urlParametersRemoved
case protectionsState
case reportFlow
private struct Keys {
static let url = "siteUrl"
static let category = "category"
static let reportFlow = "reportFlow"
static let description = "description"
static let upgradedHttps = "upgradedHttps"
static let tds = "tds"
static let blockedTrackers = "blockedTrackers"
static let surrogates = "surrogates"
static let atb = "atb"
static let os = "os"
static let manufacturer = "manufacturer"
static let model = "model"
static let siteType = "siteType"
static let gpc = "gpc"
static let ampUrl = "ampUrl"
static let urlParametersRemoved = "urlParametersRemoved"
static let protectionsState = "protectionsState"
}

public enum Source: String {
case menu
case dashboard
}

public let url: URL?
public let httpsUpgrade: Bool
public let blockedTrackerDomains: [String]
public let installedSurrogates: [String]
public let isDesktop: Bool
public let tdsETag: String?
public let ampUrl: String?
public let urlParametersRemoved: Bool
public let model: String
public let manufacturer: String
public let systemVersion: String
public let gpc: Bool
public let protectionsState: Bool
private let url: URL?
private let httpsUpgrade: Bool
private let blockedTrackerDomains: [String]
private let installedSurrogates: [String]
private let isDesktop: Bool
private let tdsETag: String?
private let ampUrl: String?
private let urlParametersRemoved: Bool
private let model: String
private let manufacturer: String
private let systemVersion: String
private let gpc: Bool
private let protectionsState: Bool

public init(url: URL?, httpsUpgrade: Bool,
blockedTrackerDomains: [String],
Expand Down Expand Up @@ -99,23 +99,23 @@ public struct BrokenSiteInfo {
func send(with category: String?, description: String, source: Source) {

let parameters: [String: String] = [
Key.siteUrl.rawValue: normalize(url),
Key.category.rawValue: category ?? "",
Key.description.rawValue: description,
Key.reportFlow.rawValue: source.rawValue,
Key.upgradedHttps.rawValue: httpsUpgrade ? "true" : "false",
Key.siteType.rawValue: isDesktop ? "desktop" : "mobile",
Key.tds.rawValue: tdsETag?.trimmingCharacters(in: CharacterSet(charactersIn: "\"")) ?? "",
Key.blockedTrackers.rawValue: blockedTrackerDomains.joined(separator: ","),
Key.surrogates.rawValue: installedSurrogates.joined(separator: ","),
Key.atb.rawValue: StatisticsUserDefaults().atb ?? "",
Key.os.rawValue: systemVersion,
Key.manufacturer.rawValue: manufacturer,
Key.model.rawValue: model,
Key.gpc.rawValue: gpc ? "true" : "false",
Key.ampUrl.rawValue: ampUrl ?? "",
Key.urlParametersRemoved.rawValue: urlParametersRemoved ? "true" : "false",
Key.protectionsState.rawValue: protectionsState ? "true" : "false"
Keys.url: normalize(url),
Keys.category: category ?? "",
Keys.description: description,
Keys.reportFlow: source.rawValue,
Keys.upgradedHttps: httpsUpgrade ? "true" : "false",
Keys.siteType: isDesktop ? "desktop" : "mobile",
Keys.tds: tdsETag?.trimmingCharacters(in: CharacterSet(charactersIn: "\"")) ?? "",
Keys.blockedTrackers: blockedTrackerDomains.joined(separator: ","),
Keys.surrogates: installedSurrogates.joined(separator: ","),
Keys.atb: StatisticsUserDefaults().atb ?? "",
Keys.os: systemVersion,
Keys.manufacturer: manufacturer,
Keys.model: model,
Keys.gpc: gpc ? "true" : "false",
Keys.ampUrl: ampUrl ?? "",
Keys.urlParametersRemoved: urlParametersRemoved ? "true" : "false",
Keys.protectionsState: protectionsState ? "true" : "false"
]

Pixel.fire(pixel: .brokenSiteReport,
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGoTests/BrokenSiteReportingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ final class BrokenSiteReportingTests: XCTestCase {

func testBrokenSiteReporting() throws {
let testJSON = data.fromJsonFile(Resource.tests)
let testString = String(data: testJSON, encoding: .utf8)
let testData = try JSONDecoder().decode(BrokenSiteReportingTestData.self, from: testJSON)

referenceTests = testData.reportURL.tests.filter {
Expand Down Expand Up @@ -133,7 +134,6 @@ private struct ReportURL: Codable {
}

// MARK: - Test

private struct Test: Codable {
let name: String
let siteURL: String
Expand Down

0 comments on commit f066d70

Please sign in to comment.