chromium/components/commerce/core/price_tracking_utils_unittest.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/commerce/core/price_tracking_utils.h"

#include <memory>
#include <optional>

#include "base/functional/callback.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "base/uuid.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_uuids.h"
#include "components/bookmarks/test/test_bookmark_client.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/commerce/core/mock_shopping_service.h"
#include "components/commerce/core/pref_names.h"
#include "components/commerce/core/subscriptions/commerce_subscription.h"
#include "components/commerce/core/test_utils.h"
#include "components/power_bookmarks/core/power_bookmark_utils.h"
#include "components/power_bookmarks/core/proto/power_bookmark_meta.pb.h"
#include "components/power_bookmarks/core/proto/shopping_specifics.pb.h"
#include "components/prefs/testing_pref_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace commerce {
namespace {

class PriceTrackingUtilsTest : public testing::Test {};

// Test that the utility for setting the price tracking state of a bookmark
// updates all of the bookmarks with the same cluster ID if the subscription
// backend call is successful.
TEST_F(PriceTrackingUtilsTest,
       SetPriceTrackingStateUpdatesAll_UnsubscribeSuccess) {}

// Ensure bookmarks created by price tracking are kept when the product is
// unsubscribed if the "track by default" feature is enabled.
TEST_F(PriceTrackingUtilsTest,
       SetPriceTrackingState_Unsubscribe_TrackByDefault) {}

// Test that a bookmark is updated in-place if revisiting the page and it is
// detected to be a trackable product.
TEST_F(PriceTrackingUtilsTest, SetPriceTrackingState_SubscribeOldBookmark) {}

TEST_F(PriceTrackingUtilsTest, SetPriceTrackingState_ErrorCases_NoService) {}

TEST_F(PriceTrackingUtilsTest, SetPriceTrackingState_ErrorCases_NoBookmark) {}

TEST_F(PriceTrackingUtilsTest, SetPriceTrackingState_ErrorCases_NoInfo) {}

TEST_F(PriceTrackingUtilsTest, SetPriceTrackingForClusterId) {}

TEST_F(PriceTrackingUtilsTest, GetBookmarksWithClusterId) {}

TEST_F(PriceTrackingUtilsTest, GetBookmarksWithClusterId_CountRestricted) {}

TEST_F(PriceTrackingUtilsTest, GetAllPriceTrackedBookmarks) {}

TEST_F(PriceTrackingUtilsTest, GetBookmarksWithClusterId_NoProducts) {}

TEST_F(PriceTrackingUtilsTest, IsBookmarkPriceTracked_Tracked) {}

TEST_F(PriceTrackingUtilsTest, IsBookmarkPriceTracked_NonProduct) {}

TEST_F(PriceTrackingUtilsTest, PopulateOrUpdateBookmark) {}

TEST_F(PriceTrackingUtilsTest, PopulateOrUpdateBookmark_NoNewData) {}

TEST_F(PriceTrackingUtilsTest,
       PopulateOrUpdateBookmark_EmptyClusterIdReplaced) {}

TEST_F(PriceTrackingUtilsTest, PopulateOrUpdateBookmark_ClusterIdUnchanged) {}

TEST_F(PriceTrackingUtilsTest, PopulateOrUpdateBookmark_ImageRemoved) {}

TEST_F(PriceTrackingUtilsTest, PopulateOrUpdateBookmark_TitleUpdated) {}

TEST_F(PriceTrackingUtilsTest, PopulateOrUpdateBookmark_NonemptyTitleKept) {}

// Make sure the previous price is cleared if we're no longer receiving it from
// the backend.
TEST_F(PriceTrackingUtilsTest, PopulateOrUpdateBookmark_PreviousPriceCleared) {}

TEST_F(PriceTrackingUtilsTest, MaybeEnableEmailNotifications) {}

TEST_F(PriceTrackingUtilsTest, TestSubscriptionForClusterIdCreation) {}

TEST_F(PriceTrackingUtilsTest, TestGetBookmarkParentName) {}

// Ensure the utility to get the shopping collection knows when to create or
// simply lookup the folder. The folder's UUID should be deterministic.
TEST_F(PriceTrackingUtilsTest, GetShoppingCollection) {}

TEST_F(PriceTrackingUtilsTest, GetShoppingCollection_InvalidParams) {}

TEST_F(PriceTrackingUtilsTest, GetProductClusterIdFromBookmark) {}

TEST_F(PriceTrackingUtilsTest, RemoveDanglingSubscriptions) {}

// Ensure the callback runs even if there are no dangling
TEST_F(PriceTrackingUtilsTest, RemoveDanglingSubscriptions_NoDanglingSubs) {}

}  // namespace
}  // namespace commerce