diff --git a/src/xcode/ENA/ENA/Source/Scenes/AppInformation/AppInformationViewController.swift b/src/xcode/ENA/ENA/Source/Scenes/AppInformation/AppInformationViewController.swift index 28c4be65627..bda695a3fc6 100644 --- a/src/xcode/ENA/ENA/Source/Scenes/AppInformation/AppInformationViewController.swift +++ b/src/xcode/ENA/ENA/Source/Scenes/AppInformation/AppInformationViewController.swift @@ -13,10 +13,11 @@ class AppInformationViewController: DynamicTableViewController, NavigationBarOpa elsService: ErrorLogSubmissionProviding, finishedDeltaOnboardings: [String: [String]], cclService: CCLServable, - isHibernationState: Bool? = CWAHibernationProvider.shared.isHibernationState + cwaHibernationProvider: CWAHibernationProvider = CWAHibernationProvider.shared ) { self.cclService = cclService self.finishedDeltaOnboardings = finishedDeltaOnboardings + self.cwaHibernationProvider = cwaHibernationProvider self.model = [ .versionInfo: AppInformationCellModel( @@ -48,27 +49,23 @@ class AppInformationViewController: DynamicTableViewController, NavigationBarOpa text: AppStrings.AppInformation.legalNavigation, accessibilityIdentifier: AccessibilityIdentifiers.AppInformation.legalNavigation, action: .push(model: AppInformationViewController.legalModel, separators: true, withTitle: AppStrings.AppInformation.legalNavigation) - )] - - if let hibernationState = isHibernationState, !hibernationState { - self.model[.contact] = AppInformationCellModel( - text: AppStrings.AppInformation.contactNavigation, - accessibilityIdentifier: AccessibilityIdentifiers.AppInformation.contactNavigation, - action: .push(model: AppInformationModel.contactModel, withTitle: AppStrings.AppInformation.contactNavigation) - ) - - self.model[.errorReport] = AppInformationCellModel( + ), + .contact: AppInformationCellModel( + text: AppStrings.AppInformation.contactNavigation, + accessibilityIdentifier: AccessibilityIdentifiers.AppInformation.contactNavigation, + action: .push(model: AppInformationModel.contactModel, withTitle: AppStrings.AppInformation.contactNavigation) + ), + .errorReport: AppInformationCellModel( text: AppStrings.ErrorReport.title, accessibilityIdentifier: AccessibilityIdentifiers.ErrorReport.navigation, action: .pushErrorLogsCoordinator(elsService: elsService) + ), + .imprint: AppInformationCellModel( + text: AppStrings.AppInformation.imprintNavigation, + accessibilityIdentifier: AccessibilityIdentifiers.AppInformation.imprintNavigation, + action: .push(model: imprintViewModel.dynamicTable, withTitle: AppStrings.AppInformation.imprintNavigation) ) - } - - self.model[.imprint] = AppInformationCellModel( - text: AppStrings.AppInformation.imprintNavigation, - accessibilityIdentifier: AccessibilityIdentifiers.AppInformation.imprintNavigation, - action: .push(model: imprintViewModel.dynamicTable, withTitle: AppStrings.AppInformation.imprintNavigation) - ) + ] super.init(nibName: nil, bundle: nil) } @@ -143,6 +140,20 @@ class AppInformationViewController: DynamicTableViewController, NavigationBarOpa } } + override func tableView(_: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + guard cwaHibernationProvider.isHibernationState else { + return UITableView.automaticDimension + } + + switch Category(rawValue: indexPath.row) { + // Hibernation: hide the following cells + case .contact, .errorReport: + return 0 + default: + return UITableView.automaticDimension + } + } + // MARK: - Public // MARK: - Internal @@ -169,6 +180,7 @@ class AppInformationViewController: DynamicTableViewController, NavigationBarOpa private var cclService: CCLServable private var finishedDeltaOnboardings: [String: [String]] + private let cwaHibernationProvider: CWAHibernationProvider private func footerView() -> UIView { let versionLabel = ENALabel() diff --git a/src/xcode/ENA/ENA/Source/Scenes/AppInformation/AppInformationViewControllerTests.swift b/src/xcode/ENA/ENA/Source/Scenes/AppInformation/AppInformationViewControllerTests.swift index 04040d534c8..ff83dfe4d7c 100644 --- a/src/xcode/ENA/ENA/Source/Scenes/AppInformation/AppInformationViewControllerTests.swift +++ b/src/xcode/ENA/ENA/Source/Scenes/AppInformation/AppInformationViewControllerTests.swift @@ -29,25 +29,75 @@ class AppInformationViewControllerTests: XCTestCase { fakeCCSService = nil } - func testModel_WHEN_modelEntriesInHibernation_THEN_equalCount() throws { + func testModel_WHEN_modelEntries_THEN_equalCategoryCount() throws { + // WHEN + let modelEntriesCount = sut.model.count + + // THEN + XCTAssertEqual(modelEntriesCount, AppInformationViewController.Category.allCases.count) + } + + func testHeightForRowAt_shouldShowAllCategories() { // GIVEN - let store = MockTestStore() + let mockCWAHibernationProvider = MockCWAHibernationProvider() + mockCWAHibernationProvider.isHibernationStateToReturn = false + let mockTestStore = MockTestStore() let sut = AppInformationViewController( elsService: errorLogSubmissionProvidingMock, - finishedDeltaOnboardings: store.finishedDeltaOnboardings, + finishedDeltaOnboardings: mockTestStore.finishedDeltaOnboardings, cclService: fakeCCSService, - isHibernationState: true + cwaHibernationProvider: mockCWAHibernationProvider ) + + AppInformationViewController.Category.allCases.forEach { category in + + // WHEN + let heightForRow = sut.tableView( + sut.tableView, + heightForRowAt: IndexPath( + row: category.rawValue, + section: 0 + ) + ) - // THEN - XCTAssertEqual(sut.model.count, 7) + // THEN + switch category { + case .about, .accessibility, .contact, .errorReport, .imprint, .legal, .privacy, .terms, .versionInfo: + XCTAssertEqual(heightForRow, UITableView.automaticDimension) + } + } } - func testModel_WHEN_modelEntries_THEN_equalCategoryCount() throws { - // WHEN - let modelEntriesCount = sut.model.count + func testHeightForRowAt_EOL_shouldHideSomeCategories() { + // GIVEN + let mockCWAHibernationProvider = MockCWAHibernationProvider() + mockCWAHibernationProvider.isHibernationStateToReturn = true + let mockTestStore = MockTestStore() + let sut = AppInformationViewController( + elsService: errorLogSubmissionProvidingMock, + finishedDeltaOnboardings: mockTestStore.finishedDeltaOnboardings, + cclService: fakeCCSService, + cwaHibernationProvider: mockCWAHibernationProvider + ) + + AppInformationViewController.Category.allCases.forEach { category in - // THEN - XCTAssertEqual(modelEntriesCount, AppInformationViewController.Category.allCases.count) - } + // WHEN + let heightForRow = sut.tableView( + sut.tableView, + heightForRowAt: IndexPath( + row: category.rawValue, + section: 0 + ) + ) + + // THEN + switch category { + case .contact, .errorReport: + XCTAssertEqual(heightForRow, 0) + case .about, .accessibility, .imprint, .legal, .privacy, .terms, .versionInfo: + XCTAssertEqual(heightForRow, UITableView.automaticDimension) + } + } + } }