Skip to content

Commit

Permalink
Remove feature flag from tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
selanthiraiyan committed Dec 4, 2024
1 parent 7ad2844 commit 04edf72
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ struct MockFeatureFlagService: FeatureFlagService {
private let blazeCampaignObjective: Bool
private let revampedShippingLabelCreation: Bool
private let viewEditCustomFieldsInProductsAndOrders: Bool
private let favoriteProducts: Bool
private let paymentsOnboardingInPointOfSale: Bool
private let isProductGlobalUniqueIdentifierSupported: Bool
private let isSendReceiptAfterPaymentEnabled: Bool
Expand All @@ -45,7 +44,6 @@ struct MockFeatureFlagService: FeatureFlagService {
blazeCampaignObjective: Bool = false,
revampedShippingLabelCreation: Bool = false,
viewEditCustomFieldsInProductsAndOrders: Bool = false,
favoriteProducts: Bool = false,
paymentsOnboardingInPointOfSale: Bool = false,
isProductGlobalUniqueIdentifierSupported: Bool = false,
isSendReceiptAfterPaymentEnabled: Bool = false) {
Expand All @@ -68,7 +66,6 @@ struct MockFeatureFlagService: FeatureFlagService {
self.blazeCampaignObjective = blazeCampaignObjective
self.revampedShippingLabelCreation = revampedShippingLabelCreation
self.viewEditCustomFieldsInProductsAndOrders = viewEditCustomFieldsInProductsAndOrders
self.favoriteProducts = favoriteProducts
self.paymentsOnboardingInPointOfSale = paymentsOnboardingInPointOfSale
self.isProductGlobalUniqueIdentifierSupported = isProductGlobalUniqueIdentifierSupported
self.isSendReceiptAfterPaymentEnabled = isSendReceiptAfterPaymentEnabled
Expand Down Expand Up @@ -114,8 +111,6 @@ struct MockFeatureFlagService: FeatureFlagService {
return revampedShippingLabelCreation
case .viewEditCustomFieldsInProductsAndOrders:
return viewEditCustomFieldsInProductsAndOrders
case .favoriteProducts:
return favoriteProducts
case .paymentsOnboardingInPointOfSale:
return paymentsOnboardingInPointOfSale
case .productGlobalUniqueIdentifierSupport:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ final class ProductFormViewModelTests: XCTestCase {
// Given
let product = Product.fake()
let viewModel = createViewModel(product: product,
formType: .edit,
featureFlagService: MockFeatureFlagService(favoriteProducts: true))
formType: .edit)

// When
XCTAssertTrue(viewModel.canFavoriteProduct())
Expand All @@ -243,19 +242,7 @@ final class ProductFormViewModelTests: XCTestCase {
// Given
let product = Product.fake()
let viewModel = createViewModel(product: product,
formType: .add,
featureFlagService: MockFeatureFlagService(favoriteProducts: true))

// When
XCTAssertFalse(viewModel.canFavoriteProduct())
}

func test_canFavoriteProduct_is_false_when_feature_flag_off() {
// Given
let product = Product.fake()
let viewModel = createViewModel(product: product,
formType: .add,
featureFlagService: MockFeatureFlagService(favoriteProducts: false))
formType: .add)

// When
XCTAssertFalse(viewModel.canFavoriteProduct())
Expand All @@ -267,8 +254,7 @@ final class ProductFormViewModelTests: XCTestCase {
let mockUseCase = MockFavoriteProductsUseCase()
let viewModel = createViewModel(product: product,
formType: .add,
favoriteProductsUseCase: mockUseCase,
featureFlagService: MockFeatureFlagService(favoriteProducts: true))
favoriteProductsUseCase: mockUseCase)

// When
viewModel.markAsFavorite()
Expand All @@ -284,8 +270,7 @@ final class ProductFormViewModelTests: XCTestCase {
let mockUseCase = MockFavoriteProductsUseCase()
let viewModel = createViewModel(product: product,
formType: .add,
favoriteProductsUseCase: mockUseCase,
featureFlagService: MockFeatureFlagService(favoriteProducts: true))
favoriteProductsUseCase: mockUseCase)

// When
viewModel.removeFromFavorite()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ final class FilterProductListViewModelTests: XCTestCase {

func test_criteria_with_non_nil_filters_then_it_returns_all_active_filters() {
// Given
let featureFlagService = MockFeatureFlagService(favoriteProducts: true)
let filters = FilterProductListViewModel.Filters(stockStatus: .inStock,
productStatus: .draft,
promotableProductType: PromotableProductType(productType: .grouped,
Expand All @@ -36,8 +35,7 @@ final class FilterProductListViewModelTests: XCTestCase {

// When
let viewModel = FilterProductListViewModel(filters: filters,
siteID: 0,
featureFlagService: featureFlagService)
siteID: 0)

// Then
let expectedCriteria = filters
Expand Down Expand Up @@ -83,27 +81,4 @@ final class FilterProductListViewModelTests: XCTestCase {
// Then
XCTAssertEqual(filters.analyticsDescription, "instock,draft,grouped,category,favorite_products")
}

// MARK: Favorite product feature flag

func test_filterTypeViewModels_does_not_contain_favorite_filter_view_model_when_feature_flag_off() {
// Given
let featureFlagService = MockFeatureFlagService(favoriteProducts: false)
let filters = FilterProductListViewModel.Filters(stockStatus: .inStock,
productStatus: .draft,
promotableProductType: PromotableProductType(productType: .grouped,
isAvailable: true,
promoteUrl: nil),
productCategory: filterProductCategory,
favoriteProduct: FavoriteProductsFilter(),
numberOfActiveFilters: 5)

// When
let viewModel = FilterProductListViewModel(filters: filters,
siteID: 0,
featureFlagService: featureFlagService)

// Then
XCTAssertFalse(viewModel.filterTypeViewModels.contains(where: { $0.title == FilterProductListViewModel.ProductListFilter.Localization.favoriteProduct } ))
}
}

0 comments on commit 04edf72

Please sign in to comment.