-
Notifications
You must be signed in to change notification settings - Fork 3
Render mobile sticky ads only if reader revenue banner is absent #2351
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
Open
dskamiotis
wants to merge
7
commits into
main
Choose a base branch
from
ds/load-mobile-sticky-ads-conditionally
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+92
−19
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6b4a4c1
Load mobile sticky ads only when the reader revenue banner is not pre…
dskamiotis 9378857
refactor logic to render mobile sticky slot as discrete function
dskamiotis ee8ea22
add playright test for response to events from dcr
dskamiotis c35b562
fix mobile sticky tests to use manual event dispatch
dskamiotis ef002cd
fix linting issues
dskamiotis 1422c34
refactor mobile sticky tests with realistic banner dismissal flow
dskamiotis 7891d65
improve mobile sticky ad test description clarity
dskamiotis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { testAtBreakpoints } from '../lib/breakpoints'; | ||
| import { loadPage } from '../lib/load-page'; | ||
| import { cmpAcceptAll } from '../lib/cmp'; | ||
| import { articles } from '../fixtures/pages'; | ||
| import { GuPage } from '../fixtures/pages/Page'; | ||
|
|
||
| const { path } = articles[0] as unknown as GuPage; | ||
| testAtBreakpoints(['mobile']).forEach(({ width, height }) => { | ||
| test(`mobile sticky ad waits for StickyBottomBanner to be dismissed before loading`, async ({ | ||
| page, | ||
| }) => { | ||
| await page.setViewportSize({ width, height }); | ||
|
|
||
| await loadPage({ page, path, region: 'US' }); | ||
| await cmpAcceptAll(page); | ||
| await loadPage({ | ||
| page, | ||
| path, | ||
| region: 'US', | ||
| queryParams: { 'force-banner': '', adtest: 'mobileStickyTest' }, | ||
| }); | ||
|
|
||
| // Banner should be visible, ad slot should not exist | ||
| await expect( | ||
| page.locator('[name="StickyBottomBanner"] > *'), | ||
| ).toBeVisible(); | ||
| await expect(page.locator('#dfp-ad--mobile-sticky')).not.toBeAttached(); | ||
|
|
||
| // Dismiss banner | ||
| await page.getByRole('button', { name: 'Collapse banner' }).click(); | ||
| await page.getByText('Maybe later').click(); | ||
|
|
||
| // Banner hidden, ad slot should now appear | ||
| await expect( | ||
| page.locator('[name="StickyBottomBanner"]'), | ||
| ).not.toBeVisible(); | ||
| await expect(page.locator('#dfp-ad--mobile-sticky')).toBeAttached(); | ||
| }); | ||
| }); | ||
|
|
||
| testAtBreakpoints(['mobile']).forEach(({ width, height }) => { | ||
| test(`mobile sticky responds to banner:none event at mobile breakpoint`, async ({ | ||
| page, | ||
| }) => { | ||
| await page.setViewportSize({ width, height }); | ||
| await loadPage({ | ||
| page, | ||
| path, | ||
| region: 'US', | ||
| queryParams: { | ||
| adtest: 'mobileStickyTest', | ||
| }, | ||
| }); | ||
| await cmpAcceptAll(page); | ||
|
|
||
| await page.evaluate(() => { | ||
| document.dispatchEvent(new Event('banner:none')); | ||
| }); | ||
|
|
||
| await expect(page.locator('#dfp-ad--mobile-sticky')).toBeAttached(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This text could change so is a bit fragile, but we don't have anything better here due to the way it appears in the DOM! If we find this test fails due to text changes, we should try to establish a more concrete identifier for this button (and the previous "Collapse banner" one)