Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Fix/14901 EOL - RampDown notice ("PostIt") still visible #5083

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/xcode/ENA/ENA/Source/Scenes/Home/HomeTableViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,7 @@ class HomeTableViewModel {
case .endOfLifeThankYou:
return isHibernationState ? 1 : 0
case .appClosureNotice:
#if DEBUG
if isUITesting, LaunchArguments.appClosureNotice.showAppClosureNoticeTile.boolValue {
return 1
}
#endif
return shouldShowAppClosureNotice ? 1 : 0
return numberOfRowsForAppClosureNotice()
case .exposureLogging:
return !isHibernationState ? 1 : 0
case .riskAndTestResults:
Expand Down Expand Up @@ -365,4 +360,16 @@ class HomeTableViewModel {
}
}

private func numberOfRowsForAppClosureNotice() -> Int {
#if DEBUG
if isUITesting, LaunchArguments.appClosureNotice.showAppClosureNoticeTile.boolValue {
return 1
}
#endif
if shouldShowAppClosureNotice, !isHibernationState {
return 1
} else {
return 0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import HealthCertificateToolkit
// swiftlint:disable type_body_length
class HomeTableViewModelTests: CWATestCase {

func testSectionsRowsAndHeightsInHibernation() throws {
func testNumberOfSections_isHibernation_true_showAppClosureNotice_false() throws {
// GIVEN
let store = MockTestStore()

let viewModel = HomeTableViewModel(
let sut = HomeTableViewModel(
state: .init(
store: store,
riskProvider: MockRiskProvider(),
Expand All @@ -36,22 +37,77 @@ class HomeTableViewModelTests: CWATestCase {
onTestResultCellTap: { _ in },
badgeWrapper: .fake()
)

// WHEN

// Number of Rows per Section
viewModel.isHibernationState = true
// Is hibernation and should not show app closure notice
sut.isHibernationState = true
sut.shouldShowAppClosureNotice = false

// THEN

// Number of Sections
XCTAssertEqual(viewModel.numberOfSections, 8)
XCTAssertEqual(sut.numberOfSections, 8)

// Number of Rows
XCTAssertEqual(sut.numberOfRows(in: 0), 1) // end of life tile visible
XCTAssertEqual(sut.numberOfRows(in: 1), 0) // app closure notice invisible
XCTAssertEqual(sut.numberOfRows(in: 2), 0) // exposure Logging invisible
XCTAssertEqual(sut.numberOfRows(in: 3), 0) // riskAndTestResults invisible
XCTAssertEqual(sut.numberOfRows(in: 4), 0) // testRegistration invisible
XCTAssertEqual(sut.numberOfRows(in: 5), 1) // statistics visible
XCTAssertEqual(sut.numberOfRows(in: 6), 0) // traceLocations invisible
XCTAssertEqual(sut.numberOfRows(in: 7), 1) // moreInfo visible
}

func testNumberOfSections_isHibernation_true_showAppClosureNotice_true() throws {
// GIVEN
let store = MockTestStore()

let sut = HomeTableViewModel(
state: .init(
store: store,
riskProvider: MockRiskProvider(),
exposureManagerState: .init(authorized: true, enabled: true, status: .active),
enState: .enabled,
statisticsProvider: StatisticsProvider(
client: CachingHTTPClientMock(),
store: store
),
localStatisticsProvider: LocalStatisticsProvider(
client: CachingHTTPClientMock(),
store: store
)
),
store: store,
appConfiguration: CachedAppConfigurationMock(),
coronaTestService: MockCoronaTestService(),
familyMemberCoronaTestService: MockFamilyMemberCoronaTestService(),
cclService: FakeCCLService(),
onTestResultCellTap: { _ in },
badgeWrapper: .fake()
)

// WHEN

// Is hibernation and should show app closure notice
sut.isHibernationState = true
sut.shouldShowAppClosureNotice = true

// THEN

// Number of Sections
XCTAssertEqual(sut.numberOfSections, 8)

// Number of Rows
XCTAssertEqual(viewModel.numberOfRows(in: 0), 1) // end of life tile visible
XCTAssertEqual(viewModel.numberOfRows(in: 1), 0) // app closure notice invisible
XCTAssertEqual(viewModel.numberOfRows(in: 2), 0) // exposure Logging invisible
XCTAssertEqual(viewModel.numberOfRows(in: 3), 0) // riskAndTestResults invisible
XCTAssertEqual(viewModel.numberOfRows(in: 4), 0) // testRegistration invisible
XCTAssertEqual(viewModel.numberOfRows(in: 5), 1) // statistics visible
XCTAssertEqual(viewModel.numberOfRows(in: 6), 0) // traceLocations invisible
XCTAssertEqual(viewModel.numberOfRows(in: 7), 1) // moreInfo visible
XCTAssertEqual(sut.numberOfRows(in: 0), 1) // end of life tile visible
XCTAssertEqual(sut.numberOfRows(in: 1), 0) // app closure notice invisible in hibernation although should show
XCTAssertEqual(sut.numberOfRows(in: 2), 0) // exposure Logging invisible
XCTAssertEqual(sut.numberOfRows(in: 3), 0) // riskAndTestResults invisible
XCTAssertEqual(sut.numberOfRows(in: 4), 0) // testRegistration invisible
XCTAssertEqual(sut.numberOfRows(in: 5), 1) // statistics visible
XCTAssertEqual(sut.numberOfRows(in: 6), 0) // traceLocations invisible
XCTAssertEqual(sut.numberOfRows(in: 7), 1) // moreInfo visible
}

func testSectionsRowsAndHeights() throws {
Expand Down