@@ -2,6 +2,7 @@ import XCTest
22import enum Networking. DotcomError
33import enum Yosemite. StatsActionV4
44import enum Yosemite. ProductAction
5+ import enum Yosemite. AppSettingsAction
56import enum Yosemite. JustInTimeMessageAction
67import struct Yosemite. JustInTimeMessage
78@testable import WooCommerce
@@ -99,6 +100,14 @@ final class DashboardViewModelTests: XCTestCase {
99100 XCTFail ( " Received unsupported action: \( action) " )
100101 }
101102 }
103+ stores. whenReceivingAction ( ofType: AppSettingsAction . self) { action in
104+ switch action {
105+ case let . getFeatureAnnouncementVisibility( _, completion) :
106+ completion ( . success( true ) )
107+ default :
108+ XCTFail ( " Received unsupported action: \( action) " )
109+ }
110+ }
102111 stores. whenReceivingAction ( ofType: JustInTimeMessageAction . self) { action in
103112 switch action {
104113 case let . loadMessage( _, _, _, completion) :
@@ -116,6 +125,34 @@ final class DashboardViewModelTests: XCTestCase {
116125 XCTAssertEqual ( viewModel. announcementViewModel? . image, . emptyProductsImage)
117126 }
118127
128+ func test_onboarding_announcement_not_displayed_when_previously_dismissed( ) {
129+ // Given
130+ MockABTesting . setVariation ( . treatment( nil ) , for: . productsOnboardingBanner)
131+ stores. whenReceivingAction ( ofType: ProductAction . self) { action in
132+ switch action {
133+ case let . checkProductsOnboardingEligibility( _, completion) :
134+ completion ( . success( true ) )
135+ default :
136+ XCTFail ( " Received unsupported action: \( action) " )
137+ }
138+ }
139+ stores. whenReceivingAction ( ofType: AppSettingsAction . self) { action in
140+ switch action {
141+ case let . getFeatureAnnouncementVisibility( _, completion) :
142+ completion ( . success( false ) )
143+ default :
144+ XCTFail ( " Received unsupported action: \( action) " )
145+ }
146+ }
147+ let viewModel = DashboardViewModel ( stores: stores)
148+
149+ // When
150+ viewModel. syncAnnouncements ( for: sampleSiteID)
151+
152+ // Then
153+ XCTAssertNil ( viewModel. announcementViewModel)
154+ }
155+
119156 func test_view_model_syncs_just_in_time_messages_when_ineligible_for_products_onboarding( ) {
120157 // Given
121158 let message = Yosemite . JustInTimeMessage. fake ( ) . copy ( title: " JITM Message " )
0 commit comments