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

Rewarded ads button callback #3552

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add more tests
  • Loading branch information
mhkawano committed Sep 9, 2024
commit 63e565efee4bda4f2ef12394cddbd0cc676249c6
35 changes: 35 additions & 0 deletions src/runtime/audience-action-local-flow-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,41 @@ describes.realWin('AudienceActionLocalFlow', (env) => {
expect(signinButton).to.be.null;
});

it('renders enterprise', async () => {
const params = {
...DEFAULT_PARAMS,
autoPromptType: undefined,
calledManually: true,
onAlternateAction: sandbox.spy(),
onSignIn: sandbox.spy(),
};
await renderAndAssertRewardedAd(params, DEFAULT_CONFIG);

const wrapper = await callReadyAndReturnWrapper();

expect(env.win.fetch).to.be.calledWith(
'https://news.google.com/swg/_/api/v1/publication/pub1/getactionconfigurationui?publicationId=pub1&configurationId=xyz&origin=about%3Asrcdoc&previewEnabled=false'
);

const subscribeButton = wrapper.shadowRoot.querySelector(
'.rewarded-ad-support-button'
);
expect(subscribeButton).to.not.be.null;
expect(subscribeButton.innerHTML).contains('Subscribe');
await subscribeButton.click();

const signinButton = wrapper.shadowRoot.querySelector(
'.rewarded-ad-sign-in-button'
);
expect(signinButton).to.not.be.null;
expect(signinButton.innerHTML).contains('Already a subscriber?');
await signinButton.click();

await tick();

expect(params.onAlternateAction).to.be.calledOnce;
expect(params.onSignIn).to.be.calledOnce;
});
it('escapes bad input', async () => {
const BAD_CONFIG = `
{
Expand Down
3 changes: 0 additions & 3 deletions src/runtime/audience-action-local-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,9 +815,6 @@ export class AudienceActionLocalFlow implements AudienceActionFlow {

private cleanUpGoogletag() {
const googletag = this.deps_.win().googletag;
if (!googletag) {
return;
}
if (this.rewardedSlot_) {
googletag.destroySlots?.([this.rewardedSlot_!]);
}
Expand Down
Loading