[Rewards] Enable Rewards 3.0 feature by default (#28188)

This commit is contained in:
Kevin Smith
2025-03-18 14:18:25 -04:00
committed by GitHub
parent c6111550b2
commit b71cb25274
7 changed files with 2 additions and 636 deletions
-3
View File
@@ -29,15 +29,12 @@ source_set("browser_tests") {
# tests to run on Android as well.
if (!is_android) {
sources += [
"rewards_browsertest.cc",
"rewards_contribution_browsertest.cc",
"rewards_flag_browsertest.cc",
"rewards_notification_browsertest.cc",
"rewards_ofac_browsertest.cc",
"rewards_p3a_browsertest.cc",
"rewards_page_browsertest.cc",
"rewards_policy_browsertest.cc",
"rewards_publisher_browsertest.cc",
"util/rewards_browsertest_context_helper.cc",
"util/rewards_browsertest_context_helper.h",
"util/rewards_browsertest_context_util.cc",
@@ -1,251 +0,0 @@
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */
#include <algorithm>
#include <memory>
#include <string>
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "brave/browser/brave_rewards/rewards_service_factory.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_context_helper.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_context_util.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_contribution.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_network_util.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_response.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_util.h"
#include "brave/components/brave_rewards/content/rewards_service_impl.h"
#include "brave/components/brave_rewards/core/engine/global_constants.h"
#include "brave/components/brave_rewards/core/features.h"
#include "brave/components/brave_rewards/core/pref_names.h"
#include "brave/components/constants/brave_paths.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
// npm run test -- brave_browser_tests --filter=RewardsBrowserTest.*
namespace brave_rewards {
constexpr char kSelectCountryScript[] = R"(
const select = document.querySelector('[data-test-id=country-select]');
select.value = 'US';
select.dispatchEvent(new Event("change", { bubbles: true }));
true;
)";
class WalletUpdatedWaiter : public RewardsServiceObserver {
public:
explicit WalletUpdatedWaiter(RewardsService* rewards_service)
: rewards_service_(rewards_service) {
rewards_service_->AddObserver(this);
}
~WalletUpdatedWaiter() override { rewards_service_->RemoveObserver(this); }
void OnRewardsWalletCreated() override { run_loop_.Quit(); }
void Wait() { run_loop_.Run(); }
private:
base::RunLoop run_loop_;
raw_ptr<RewardsService> rewards_service_;
};
class RewardsBrowserTest : public InProcessBrowserTest {
public:
RewardsBrowserTest() {
response_ = std::make_unique<test_util::RewardsBrowserTestResponse>();
contribution_ =
std::make_unique<test_util::RewardsBrowserTestContribution>();
feature_list_.InitAndEnableFeature(features::kGeminiFeature);
}
void SetUpOnMainThread() override {
InProcessBrowserTest::SetUpOnMainThread();
context_helper_ =
std::make_unique<test_util::RewardsBrowserTestContextHelper>(browser());
// HTTP resolver
host_resolver()->AddRule("*", "127.0.0.1");
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_->RegisterRequestHandler(
base::BindRepeating(&test_util::HandleRequest));
ASSERT_TRUE(https_server_->Start());
// Rewards service
auto* profile = browser()->profile();
rewards_service_ = static_cast<RewardsServiceImpl*>(
RewardsServiceFactory::GetForProfile(profile));
// Response mock
base::ScopedAllowBlockingForTesting allow_blocking;
response_->LoadMocks();
rewards_service_->ForTestingSetTestResponseCallback(base::BindRepeating(
&RewardsBrowserTest::GetTestResponse, base::Unretained(this)));
rewards_service_->SetEngineEnvForTesting();
// Other
contribution_->Initialize(browser(), rewards_service_);
test_util::SetOnboardingBypassed(browser());
}
void TearDown() override { InProcessBrowserTest::TearDown(); }
void SetUpCommandLine(base::CommandLine* command_line) override {
// HTTPS server only serves a valid cert for localhost, so this is needed
// to load pages from other hosts without an error
command_line->AppendSwitch(switches::kIgnoreCertificateErrors);
}
void GetTestResponse(const std::string& url,
int32_t method,
int* response_status_code,
std::string* response,
base::flat_map<std::string, std::string>* headers) {
response_->SetExternalBalance(contribution_->GetExternalBalance());
response_->Get(url, method, response_status_code, response);
}
content::WebContents* contents() const {
return browser()->tab_strip_model()->GetActiveWebContents();
}
GURL uphold_auth_url() {
GURL url(
"chrome://rewards/uphold/authorization?"
"code=0c42b34121f624593ee3b04cbe4cc6ddcd72d&state=123456789");
return url;
}
double FetchBalance() {
double total = -1.0;
base::RunLoop run_loop;
rewards_service_->FetchBalance(base::BindLambdaForTesting(
[&](brave_rewards::mojom::BalancePtr balance) {
total = balance ? balance->total : -1.0;
run_loop.Quit();
}));
run_loop.Run();
return total;
}
base::test::ScopedFeatureList feature_list_;
raw_ptr<RewardsServiceImpl, DanglingUntriaged> rewards_service_ = nullptr;
std::unique_ptr<net::EmbeddedTestServer> https_server_;
std::unique_ptr<test_util::RewardsBrowserTestResponse> response_;
std::unique_ptr<test_util::RewardsBrowserTestContribution> contribution_;
std::unique_ptr<test_util::RewardsBrowserTestContextHelper> context_helper_;
};
IN_PROC_BROWSER_TEST_F(RewardsBrowserTest, ActivateSettingsModal) {
test_util::SetOnboardingBypassed(browser(), true);
test_util::StartProcess(rewards_service_);
context_helper_->LoadRewardsPage();
test_util::WaitForElementThenClick(contents(),
"[data-test-id=manage-wallet-button]");
test_util::WaitForElementToAppear(contents(),
"[data-test-id=rewards-reset-modal]");
}
IN_PROC_BROWSER_TEST_F(RewardsBrowserTest, SiteBannerDefaultTipChoices) {
test_util::StartProcessWithConnectedUser(browser()->profile());
test_util::NavigateToPublisherAndWaitForUpdate(browser(), https_server_.get(),
"3zsistemi.si");
base::WeakPtr<content::WebContents> site_banner =
context_helper_->OpenSiteBanner();
auto tip_options = test_util::GetSiteBannerTipOptions(site_banner.get());
ASSERT_EQ(tip_options, std::vector<double>({1, 5, 50}));
}
IN_PROC_BROWSER_TEST_F(RewardsBrowserTest, SiteBannerDefaultPublisherAmounts) {
test_util::StartProcessWithConnectedUser(browser()->profile());
test_util::NavigateToPublisherAndWaitForUpdate(browser(), https_server_.get(),
"laurenwags.github.io");
base::WeakPtr<content::WebContents> site_banner =
context_helper_->OpenSiteBanner();
const auto tip_options =
test_util::GetSiteBannerTipOptions(site_banner.get());
// Creator-specific default tip amounts are no longer supported, so just
// verify that the tip options match the global defaults
ASSERT_EQ(tip_options, std::vector<double>({1, 5, 50}));
}
IN_PROC_BROWSER_TEST_F(RewardsBrowserTest, ResetRewards) {
test_util::CreateRewardsWallet(rewards_service_);
context_helper_->LoadRewardsPage();
test_util::WaitForElementThenClick(contents(),
"[data-test-id=manage-wallet-button]");
test_util::WaitForElementToAppear(contents(),
"[data-test-id=rewards-reset-modal]");
test_util::WaitForElementToContain(
contents(), "[data-test-id=rewards-reset-modal]",
"By resetting, your current Brave Rewards profile will be deleted");
}
IN_PROC_BROWSER_TEST_F(RewardsBrowserTest, GeoDeclarationNewUser) {
auto* prefs = browser()->profile()->GetPrefs();
prefs->SetBoolean(prefs::kEnabled, false);
EXPECT_EQ(prefs->GetString(prefs::kDeclaredGeo), "");
auto popup_contents = context_helper_->OpenRewardsPopup();
ASSERT_TRUE(popup_contents);
test_util::WaitForElementThenClick(popup_contents.get(),
"[data-test-id=opt-in-button]");
test_util::WaitForElementToAppear(popup_contents.get(),
"[data-test-id=country-select]");
WalletUpdatedWaiter waiter(rewards_service_);
EXPECT_EQ(true, content::EvalJs(popup_contents.get(), kSelectCountryScript));
test_util::WaitForElementThenClick(popup_contents.get(),
"[data-test-id=select-country-button]");
waiter.Wait();
EXPECT_EQ(prefs->GetString(prefs::kDeclaredGeo), "US");
EXPECT_TRUE(prefs->GetBoolean(prefs::kEnabled));
}
IN_PROC_BROWSER_TEST_F(RewardsBrowserTest, GeoDeclarationExistingUser) {
test_util::CreateRewardsWallet(rewards_service_);
auto* prefs = browser()->profile()->GetPrefs();
prefs->SetString(prefs::kDeclaredGeo, "");
auto popup_contents = context_helper_->OpenRewardsPopup();
ASSERT_TRUE(popup_contents);
test_util::WaitForElementToAppear(popup_contents.get(),
"[data-test-id=select-country-button]");
WalletUpdatedWaiter waiter(rewards_service_);
EXPECT_EQ(true, content::EvalJs(popup_contents.get(), kSelectCountryScript));
test_util::WaitForElementThenClick(popup_contents.get(),
"[data-test-id=select-country-button]");
waiter.Wait();
EXPECT_EQ(prefs->GetString(prefs::kDeclaredGeo), "US");
EXPECT_TRUE(prefs->GetBoolean(prefs::kEnabled));
}
} // namespace brave_rewards
@@ -1,247 +0,0 @@
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */
#include <memory>
#include <string>
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/threading/platform_thread.h"
#include "brave/browser/brave_rewards/rewards_service_factory.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_context_helper.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_context_util.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_contribution.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_network_util.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_response.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_util.h"
#include "brave/components/brave_rewards/content/rewards_service_impl.h"
#include "brave/components/brave_rewards/core/pref_names.h"
#include "brave/components/constants/brave_paths.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "components/prefs/pref_service.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
// npm run test -- brave_browser_tests --filter=RewardsContributionBrowserTest.*
namespace brave_rewards {
class RewardsContributionBrowserTest : public InProcessBrowserTest {
public:
RewardsContributionBrowserTest() {
contribution_ =
std::make_unique<test_util::RewardsBrowserTestContribution>();
response_ = std::make_unique<test_util::RewardsBrowserTestResponse>();
}
void SetUpOnMainThread() override {
InProcessBrowserTest::SetUpOnMainThread();
context_helper_ =
std::make_unique<test_util::RewardsBrowserTestContextHelper>(browser());
// HTTP resolver
host_resolver()->AddRule("*", "127.0.0.1");
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_->RegisterRequestHandler(
base::BindRepeating(&test_util::HandleRequest));
ASSERT_TRUE(https_server_->Start());
// Rewards service
auto* profile = browser()->profile();
rewards_service_ = static_cast<RewardsServiceImpl*>(
RewardsServiceFactory::GetForProfile(profile));
// Response mock
base::ScopedAllowBlockingForTesting allow_blocking;
response_->LoadMocks();
rewards_service_->ForTestingSetTestResponseCallback(
base::BindRepeating(&RewardsContributionBrowserTest::GetTestResponse,
base::Unretained(this)));
rewards_service_->SetEngineEnvForTesting();
// Other
contribution_->Initialize(browser(), rewards_service_);
test_util::SetOnboardingBypassed(browser());
}
void TearDown() override { InProcessBrowserTest::TearDown(); }
void SetUpCommandLine(base::CommandLine* command_line) override {
InProcessBrowserTest::SetUpCommandLine(command_line);
// HTTPS server only serves a valid cert for localhost, so this is needed
// to load pages from other hosts without an error
command_line->AppendSwitch(switches::kIgnoreCertificateErrors);
}
void GetTestResponse(const std::string& url,
int32_t method,
int* response_status_code,
std::string* response,
base::flat_map<std::string, std::string>* headers) {
response_->SetExternalBalance(contribution_->GetExternalBalance());
response_->Get(url, method, response_status_code, response);
}
content::WebContents* contents() {
return browser()->tab_strip_model()->GetActiveWebContents();
}
std::string ExpectedTipSummaryAmountString() {
// The tip summary page formats 2.4999 as 2.4, so we do the same here.
double truncated_amount =
floor(contribution_->GetReconcileTipTotal() * 10) / 10;
return base::StringPrintf("%.2f BAT", -truncated_amount);
}
void RefreshPublisherListUsingRewardsPopup() {
test_util::WaitForElementThenClick(
context_helper_->OpenRewardsPopup().get(),
"[data-test-id=refresh-publisher-button]");
}
void SetSKUOrderResponse() {
std::vector<mojom::SKUOrderItemPtr> items;
auto item = mojom::SKUOrderItem::New();
item->order_item_id = "ed193339-e58c-483c-8d61-7decd3c24827";
item->order_id = "a38b211b-bf78-42c8-9479-b11e92e3a76c";
item->quantity = 80;
item->price = 0.25;
item->description = "description";
item->type = mojom::SKUOrderItemType::SINGLE_USE;
items.push_back(std::move(item));
auto order = mojom::SKUOrder::New();
order->order_id = "a38b211b-bf78-42c8-9479-b11e92e3a76c";
order->total_amount = 20;
order->merchant_id = "";
order->location = "brave.com";
order->items = std::move(items);
response_->SetSKUOrder(std::move(order));
}
raw_ptr<RewardsServiceImpl, DanglingUntriaged> rewards_service_ = nullptr;
std::unique_ptr<net::EmbeddedTestServer> https_server_;
std::unique_ptr<test_util::RewardsBrowserTestContribution> contribution_;
std::unique_ptr<test_util::RewardsBrowserTestResponse> response_;
std::unique_ptr<test_util::RewardsBrowserTestContextHelper> context_helper_;
};
IN_PROC_BROWSER_TEST_F(RewardsContributionBrowserTest,
TipVerifiedPublisherWithCustomAmount) {
contribution_->StartProcessWithBalance(30);
contribution_->TipPublisher(
test_util::GetUrl(https_server_.get(), "duckduckgo.com"), false, 1, 0,
1.25);
}
IN_PROC_BROWSER_TEST_F(RewardsContributionBrowserTest,
RecurringTipForVerifiedPublisher) {
contribution_->StartProcessWithBalance(30);
contribution_->TipPublisher(
test_util::GetUrl(https_server_.get(), "duckduckgo.com"), true, 1);
}
IN_PROC_BROWSER_TEST_F(RewardsContributionBrowserTest, TipWithVerifiedWallet) {
contribution_->StartProcessWithBalance(30);
const double amount = 5.0;
contribution_->TipViaCode("duckduckgo.com", amount,
mojom::PublisherStatus::UPHOLD_VERIFIED);
contribution_->VerifyTip(amount, false, true);
}
// TODO(https://github.com/brave/brave-browser/issues/12555): This test is known
// to fail intermittently. The likely cause is that after waiting for tips to
// reconcile, one or both of the generated fees may have already been removed
// from the ExternalWallet data.
IN_PROC_BROWSER_TEST_F(
RewardsContributionBrowserTest,
DISABLED_MultipleTipsProduceMultipleFeesWithVerifiedWallet) {
contribution_->StartProcessWithBalance(50);
double total_amount = 0.0;
const double amount = 5.0;
const double fee_percentage = 0.05;
const double tip_fee = amount * fee_percentage;
contribution_->TipViaCode("duckduckgo.com", amount,
mojom::PublisherStatus::UPHOLD_VERIFIED);
total_amount += amount;
contribution_->TipViaCode("laurenwags.github.io", amount,
mojom::PublisherStatus::UPHOLD_VERIFIED);
total_amount += amount;
base::RunLoop run_loop_first;
rewards_service_->GetExternalWallet(
base::BindLambdaForTesting([&](mojom::ExternalWalletPtr wallet) {
ASSERT_TRUE(wallet);
ASSERT_EQ(wallet->fees.size(), 2UL);
for (auto const& value : wallet->fees) {
ASSERT_EQ(value.second, tip_fee);
}
run_loop_first.Quit();
}));
run_loop_first.Run();
contribution_->VerifyTip(total_amount, false, true);
}
// Ensure that we can make a one-time tip of a non-integral amount.
IN_PROC_BROWSER_TEST_F(RewardsContributionBrowserTest, TipNonIntegralAmount) {
contribution_->StartProcessWithBalance(30);
rewards_service_->SendContribution("duckduckgo.com", 2.5, false,
base::DoNothing());
contribution_->WaitForTipReconcileCompleted();
ASSERT_EQ(contribution_->GetTipStatus(), mojom::Result::OK);
ASSERT_EQ(contribution_->GetReconcileTipTotal(), 2.5);
}
// Ensure that we can make a recurring tip of a non-integral amount.
IN_PROC_BROWSER_TEST_F(RewardsContributionBrowserTest,
RecurringTipNonIntegralAmount) {
contribution_->StartProcessWithBalance(30);
const bool verified = true;
context_helper_->VisitPublisher(
test_util::GetUrl(https_server_.get(), "duckduckgo.com"), verified);
rewards_service_->SendContribution("duckduckgo.com", 2.5, true,
base::DoNothing());
rewards_service_->StartContributionsForTesting();
contribution_->WaitForTipReconcileCompleted();
ASSERT_EQ(contribution_->GetTipStatus(), mojom::Result::OK);
ASSERT_EQ(contribution_->GetReconcileTipTotal(), 2.5);
}
IN_PROC_BROWSER_TEST_F(RewardsContributionBrowserTest, PanelMonthlyTipAmount) {
contribution_->StartProcessWithBalance(30);
test_util::NavigateToPublisherAndWaitForUpdate(browser(), https_server_.get(),
"3zsistemi.si");
// Add a recurring tip of 10 BAT.
contribution_->TipViaCode("3zsistemi.si", 10.0,
mojom::PublisherStatus::UPHOLD_VERIFIED, true);
// Verify current tip amount displayed on panel
base::WeakPtr<content::WebContents> popup =
context_helper_->OpenRewardsPopup();
const double tip_amount =
test_util::GetRewardsPopupMonthlyTipValue(popup.get());
ASSERT_EQ(tip_amount, 10.0);
}
} // namespace brave_rewards
@@ -104,14 +104,6 @@ IN_PROC_BROWSER_TEST_F(BraveRewardsOFACTest, AppMenuItemEnabled) {
// sanctioned region.
IN_PROC_BROWSER_TEST_F(BraveRewardsOFACTest, RewardsPagesAccess) {
const GURL url("chrome://rewards");
{
const brave_l10n::test::ScopedDefaultLocale locale("en_CA"); // "Canada"
auto* rfh = ui_test_utils::NavigateToURL(browser(), url);
EXPECT_TRUE(rfh);
EXPECT_FALSE(rfh->IsErrorDocument());
}
{
const brave_l10n::test::ScopedDefaultLocale locale("es_CU"); // "Cuba"
auto* rfh = ui_test_utils::NavigateToURL(browser(), url);
@@ -1,125 +0,0 @@
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */
#include <memory>
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "brave/browser/brave_rewards/rewards_service_factory.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_context_helper.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_context_util.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_network_util.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_response.h"
#include "brave/browser/brave_rewards/test/util/rewards_browsertest_util.h"
#include "brave/components/brave_rewards/content/rewards_service_impl.h"
#include "brave/components/constants/brave_paths.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "content/public/test/browser_test.h"
#include "net/dns/mock_host_resolver.h"
// npm run test -- brave_browser_tests --filter=RewardsPublisherBrowserTest.*
namespace brave_rewards {
class RewardsPublisherBrowserTest : public InProcessBrowserTest {
public:
RewardsPublisherBrowserTest() {
response_ = std::make_unique<test_util::RewardsBrowserTestResponse>();
}
void SetUpOnMainThread() override {
InProcessBrowserTest::SetUpOnMainThread();
context_helper_ =
std::make_unique<test_util::RewardsBrowserTestContextHelper>(browser());
// HTTP resolver
host_resolver()->AddRule("*", "127.0.0.1");
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS);
https_server_->SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_->RegisterRequestHandler(
base::BindRepeating(&test_util::HandleRequest));
ASSERT_TRUE(https_server_->Start());
// Rewards service
auto* profile = browser()->profile();
rewards_service_ = static_cast<RewardsServiceImpl*>(
RewardsServiceFactory::GetForProfile(profile));
// Response mock
base::ScopedAllowBlockingForTesting allow_blocking;
response_->LoadMocks();
rewards_service_->ForTestingSetTestResponseCallback(base::BindRepeating(
&RewardsPublisherBrowserTest::GetTestResponse, base::Unretained(this)));
rewards_service_->SetEngineEnvForTesting();
test_util::SetOnboardingBypassed(browser());
}
void TearDown() override { InProcessBrowserTest::TearDown(); }
void SetUpCommandLine(base::CommandLine* command_line) override {
// HTTPS server only serves a valid cert for localhost, so this is needed
// to load pages from other hosts without an error
command_line->AppendSwitch(switches::kIgnoreCertificateErrors);
}
void GetTestResponse(const std::string& url,
int32_t method,
int* response_status_code,
std::string* response,
base::flat_map<std::string, std::string>* headers) {
response_->Get(url, method, response_status_code, response);
}
content::WebContents* contents() {
return browser()->tab_strip_model()->GetActiveWebContents();
}
raw_ptr<RewardsServiceImpl, DanglingUntriaged> rewards_service_ = nullptr;
std::unique_ptr<net::EmbeddedTestServer> https_server_;
std::unique_ptr<test_util::RewardsBrowserTestResponse> response_;
std::unique_ptr<test_util::RewardsBrowserTestContextHelper> context_helper_;
};
IN_PROC_BROWSER_TEST_F(RewardsPublisherBrowserTest,
PanelShowsCorrectPublisherData) {
test_util::StartProcessWithConnectedUser(browser()->profile());
// Navigate to a verified site in a new tab
const std::string publisher = "duckduckgo.com";
test_util::NavigateToPublisherAndWaitForUpdate(browser(), https_server_.get(),
publisher);
// Open the Rewards popup
base::WeakPtr<content::WebContents> popup_contents =
context_helper_->OpenRewardsPopup();
ASSERT_TRUE(popup_contents);
// Retrieve the inner text of the wallet panel and verify that it
// looks as expected
std::string card_selector = "[data-test-id=publisher-card]";
test_util::WaitForElementToContain(popup_contents.get(), card_selector,
"Verified Creator");
test_util::WaitForElementToContain(popup_contents.get(), card_selector,
publisher);
// Retrieve the inner HTML of the wallet panel and verify that it
// contains the expected favicon
{
const std::string favicon =
"chrome://favicon2/?"
"size=64&amp;"
"pageUrl=https%3A%2F%2Fduckduckgo.com%2F";
test_util::WaitForElementToContainHTML(popup_contents.get(), card_selector,
favicon);
}
}
} // namespace brave_rewards
@@ -112,7 +112,7 @@ IN_PROC_BROWSER_TEST_F(BraveEducationPageUIBrowserTest, OpenRewardsOnboarding) {
command: 'open-rewards-onboarding'})");
auto* new_web_contents = added_observer.GetWebContents();
EXPECT_EQ(new_web_contents->GetVisibleURL(), GURL(kBraveRewardsPanelURL));
EXPECT_EQ(new_web_contents->GetVisibleURL(), GURL(kRewardsPageTopURL));
}
#if BUILDFLAG(ENABLE_BRAVE_VPN)
+1 -1
View File
@@ -35,7 +35,7 @@ BASE_FEATURE(kAllowSelfCustodyProvidersFeature,
BASE_FEATURE(kNewRewardsUIFeature,
"BraveRewardsNewRewardsUI",
base::FEATURE_DISABLED_BY_DEFAULT);
base::FEATURE_ENABLED_BY_DEFAULT);
BASE_FEATURE(kAnimatedBackgroundFeature,
"BraveRewardsAnimatedBackground",