Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes AC with more then 4 publishers #6164

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ void EnableRewards(Browser* browser, const bool use_new_tab) {
GURL page_url = use_new_tab
? rewards_browsertest_util::GetNewTabUrl()
: rewards_browsertest_util::GetRewardsUrl();
ui_test_utils::NavigateToURL(browser, page_url);
auto* contents = browser->tab_strip_model()->GetActiveWebContents();
WaitForLoadStop(contents);
LoadURL(browser, page_url);

auto* contents = browser->tab_strip_model()->GetActiveWebContents();
// Opt in and create wallet to enable rewards
rewards_browsertest_util::WaitForElementThenClick(
contents,
Expand Down Expand Up @@ -194,4 +193,11 @@ void VisitPublisher(
}
}

void LoadURL(Browser* browser, GURL url) {
DCHECK(browser);
ui_test_utils::NavigateToURL(browser, url);
auto* contents = browser->tab_strip_model()->GetActiveWebContents();
WaitForLoadStop(contents);
}

} // namespace rewards_browsertest_helper
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ void VisitPublisher(
const bool verified,
const bool last_add = false);

void LoadURL(Browser* browser, GURL url);

} // namespace rewards_browsertest_helper

#endif // BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_TEST_COMMON_REWARDS_BROWSERTEST_CONTEXT_HELPER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@ double IsRewardsEnabled(Browser* browser, const bool private_window) {
}

GURL GetRewardsUrl() {
GURL rewards_url("brave://rewards");
return rewards_url;
GURL url("brave://rewards");
return url;
}

GURL GetRewardsInternalsUrl() {
GURL url("brave://rewards-internals");
return url;
}

GURL GetNewTabUrl() {
GURL new_tab_url("brave://newtab");
return new_tab_url;
GURL url("brave://newtab");
return url;
}

void EnableRewardsViaCode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ double IsRewardsEnabled(Browser* browser, const bool private_window = false);

GURL GetRewardsUrl();

GURL GetRewardsInternalsUrl();

GURL GetNewTabUrl();

void EnableRewardsViaCode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ IN_PROC_BROWSER_TEST_F(
https_server_.get(),
"laurenwags.github.io"),
true);
rewards_browsertest_helper::VisitPublisher(
browser(),
rewards_browsertest_util::GetUrl(https_server_.get(), "site1.com"),
true);
rewards_browsertest_helper::VisitPublisher(
browser(),
rewards_browsertest_util::GetUrl(https_server_.get(), "site2.com"),
true);
rewards_browsertest_helper::VisitPublisher(
browser(),
rewards_browsertest_util::GetUrl(https_server_.get(), "site3.com"),
true);
rewards_browsertest_helper::VisitPublisher(
browser(),
rewards_browsertest_util::GetUrl(https_server_.get(), "3zsistemi.si"),
true);

rewards_service_->StartMonthlyContributionForTest();

Expand All @@ -168,6 +184,25 @@ IN_PROC_BROWSER_TEST_F(
contents(),
"[color=contribute]",
"-20.000BAT");

rewards_browsertest_helper::LoadURL(
browser(),
rewards_browsertest_util::GetRewardsInternalsUrl());

rewards_browsertest_util::WaitForElementThenClick(
contents(),
"#internals-tabs > div > div:nth-of-type(4)");

for (int i = 1; i <= 6; i++) {
const std::string query = base::StringPrintf(
"[data-test-id='publisher-wrapper'] > div:nth-of-type(%d) "
"[data-test-id='contributed-amount']",
i);
LOG(ERROR) << query;
EXPECT_NE(
rewards_browsertest_util::WaitForElementThenGetContent(contents(), query),
"0 BAT");
}
}

IN_PROC_BROWSER_TEST_F(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export class RewardsInternalsPage extends React.Component<Props, State> {
<Wrapper id='rewardsInternalsPage'>
<MainTitle level={2}>{getLocale('mainTitle')}</MainTitle>
<Tabs
id={'internals-tabs'}
activeTabId={this.state.currentTabId}
onChange={this.onTabChange}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const Contribution = (props: Props) => (
<div>
{getLocale('contributionProcessor')} {getProcessorString(props.contribution.processor)}
</div>
<ContributionPublishersWrapper>
<ContributionPublishersWrapper data-test-id={'publisher-wrapper'}>
{props.contribution.publishers.map((item: RewardsInternals.ContributionPublisher) => (
<ContributionPublisher publisher={item} key={`publisher-${item.publisherKey}`} />
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const ContributionPublisher = (props: Props) => {
{getLocale('totalAmount')} {props.publisher.totalAmount} {getLocale('bat')}
</div>
<div>
{getLocale('contributedAmount')} {props.publisher.contributedAmount} {getLocale('bat')}
{getLocale('contributedAmount')} <span data-test-id={'contributed-amount'}>{props.publisher.contributedAmount} {getLocale('bat')}</span>
</div>
</Publisher>)
}
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,8 @@ void Contribution::SetRetryCounter(ledger::ContributionInfoPtr contribution) {
return;
}

if (contribution->retry_count == 3) {
if (contribution->retry_count == 3 &&
contribution->step != ledger::ContributionStep::STEP_PREPARE) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the fix, so we should ignore limit of 3 retries for step STEP_PREPARE

BLOG(0, "Contribution failed after 3 retries");
ledger_->ContributionCompleted(
ledger::Result::TOO_MANY_RESULTS,
Expand Down