chromium/components/commerce/core/shopping_bookmark_model_observer_unittest.cc

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

#include <memory>

#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/metrics/user_action_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_node.h"
#include "components/bookmarks/common/bookmark_metrics.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/price_tracking_utils.h"
#include "components/commerce/core/shopping_bookmark_model_observer.h"
#include "components/commerce/core/subscriptions/mock_subscriptions_manager.h"
#include "components/commerce/core/test_utils.h"
#include "components/power_bookmarks/core/power_bookmark_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace commerce {
namespace {

class ShoppingBookmarkModelObserverTest : public testing::Test {};

// Ensure a subscription is removed if the owning bookmark is deleted and the
// relationship is 1:1.
TEST_F(ShoppingBookmarkModelObserverTest, TestUnsubscribeOnBookmarkDeletion) {}

// If there are multiple bookmarks with the same product ID, don't remove the
// subscription.
TEST_F(ShoppingBookmarkModelObserverTest,
       TestUnsubscribeOnBookmarkDeletion_MultipleBookmarks) {}

// Make sure that when a folder is deleted, the products that it contains are
// unsubscribed.
TEST_F(ShoppingBookmarkModelObserverTest,
       TestUnsubscribeOnBookmarkFolderDeletion) {}

// Make sure that when a folder is deleted and contains duplicate products in
// the subtree, it is correctly unsubscribed.
TEST_F(ShoppingBookmarkModelObserverTest,
       TestUnsubscribeOnBookmarkFolderDeletion_SameProduct_SameFolder) {}

// If there are duplicate products but they exist in different subtrees, make
// sure the product remains subscribed.
TEST_F(ShoppingBookmarkModelObserverTest,
       TestUnsubscribeOnBookmarkFolderDeletion_SameProduct_DifferentFolder) {}

// If the URL of a bookmark changes, we don't know if it still points to a valid
// product. The subscription and meta should be removed.
TEST_F(ShoppingBookmarkModelObserverTest,
       TestMetaRemovalAndUnsubscribeOnURLChange) {}

// Same test as above, but we shouldn't unsubscribe if there were multiple
// product bookmarks with the same cluster ID.
TEST_F(ShoppingBookmarkModelObserverTest,
       TestMetaRemovalAndUnsubscribeOnURLChange_MultipleBookmarks) {}

// Ensure a subscription is automatically tracked if that flag is enabled.
TEST_F(ShoppingBookmarkModelObserverTest, TestAutomaticTrackingOnAdd) {}

// Ensure a subscription is automatically tracked if that flag is enabled.
TEST_F(ShoppingBookmarkModelObserverTest, TestShoppingCollectionChangeMetrics) {}

}  // namespace
}  // namespace commerce