-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into clj/spike-deploy-with…
…-riff-raff
- Loading branch information
Showing
29 changed files
with
346 additions
and
56 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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,28 @@ | ||
name: 'Stale PR Handler' | ||
|
||
on: | ||
schedule: | ||
# Every morning at 1AM, Mondays to Fridays | ||
- cron: '0 1 * * MON-FRI' | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
stale: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/stale@v9 | ||
id: stale | ||
# Read about options here: https://github.com/actions/stale#all-options | ||
with: | ||
# never automatically mark issues as stale | ||
days-before-issue-stale: -1 | ||
days-before-stale: 30 | ||
stale-pr-message: > | ||
"This PR is stale because it has been open 30 days with no activity. | ||
Unless a comment is added or the “stale” label removed, this will be closed in 3 days" | ||
days-before-close: 3 | ||
close-pr-message: 'This PR was closed because it has been stalled for 3 days with no activity.' | ||
delete-branch: true | ||
exempt-pr-labels: 'dependencies' |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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,97 @@ | ||
import { isEligibleForTeads } from './teads-eligibility'; | ||
|
||
// Mocking the IAS keywords | ||
const pubAds = { | ||
getTargeting: jest.fn(() => ['']), | ||
}; | ||
|
||
window.googletag = { | ||
/* @ts-expect-error -- no way to override types */ | ||
pubads() { | ||
return pubAds; | ||
}, | ||
}; | ||
|
||
describe('Teads Eligibility', () => { | ||
it('should be eligible for teads when slot is inline1, on an allowed content type, not sensitive, and there are no banned keywords', () => { | ||
window.guardian = { | ||
config: { | ||
page: { | ||
contentType: 'Article', | ||
isSensitive: false, | ||
pageId: 'lifeandstyle/2024/sep/30/the-electrolytes-boom-a-wonder-supplement-or-an-unnecessary-expense', | ||
} as unknown as typeof window.guardian.config.page, | ||
}, | ||
} as typeof window.guardian; | ||
|
||
expect(isEligibleForTeads('dfp-ad--inline1')).toBe(true); | ||
}); | ||
|
||
it('should not be eligible for teads when slot is not inline1', () => { | ||
window.guardian = { | ||
config: { | ||
page: { | ||
contentType: 'Article', | ||
isSensitive: false, | ||
pageId: 'lifeandstyle/2024/sep/30/the-electrolytes-boom-a-wonder-supplement-or-an-unnecessary-expense', | ||
} as unknown as typeof window.guardian.config.page, | ||
}, | ||
} as typeof window.guardian; | ||
|
||
expect(isEligibleForTeads('dfp-ad--inline2')).toBe(false); | ||
}); | ||
|
||
it('should not be eligible for teads when content type is not article or liveblog', () => { | ||
window.guardian = { | ||
config: { | ||
page: { | ||
contentType: 'Interactive', | ||
isSensitive: false, | ||
pageId: 'books/ng-interactive/2024/sep/04/this-months-best-paperbacks-stephen-king-anne-michaels-and-more', | ||
} as unknown as typeof window.guardian.config.page, | ||
}, | ||
} as typeof window.guardian; | ||
|
||
expect(isEligibleForTeads('dfp-ad--inline1')).toBe(false); | ||
}); | ||
|
||
it('should not be eligible for teads when content is marked as sensitive', () => { | ||
window.guardian = { | ||
config: { | ||
page: { | ||
contentType: 'Article', | ||
isSensitive: true, | ||
pageId: 'society/2020/oct/08/take-life-grateful-alive-surgeon-suicide-attempt', | ||
} as unknown as typeof window.guardian.config.page, | ||
}, | ||
} as typeof window.guardian; | ||
|
||
expect(isEligibleForTeads('dfp-ad--inline1')).toBe(false); | ||
}); | ||
|
||
it('should not be eligible for teads when IAS indicates that content is not brand safe', () => { | ||
// Mocking the IAS keywords - need to mock a non brand safe article | ||
const pubAds = { | ||
getTargeting: jest.fn(() => ['IAS_16425_KW']), | ||
}; | ||
|
||
window.googletag = { | ||
/* @ts-expect-error -- no way to override types */ | ||
pubads() { | ||
return pubAds; | ||
}, | ||
}; | ||
|
||
window.guardian = { | ||
config: { | ||
page: { | ||
contentType: 'Article', | ||
isSensitive: false, | ||
pageId: 'us-news/2024/nov/10/trump-putin-ukraine-war', | ||
} as unknown as typeof window.guardian.config.page, | ||
}, | ||
} as typeof window.guardian; | ||
|
||
expect(isEligibleForTeads('dfp-ad--inline1')).toBe(false); | ||
}); | ||
}); |
This file contains 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,24 @@ | ||
const allowedContentTypes = ['Article', 'LiveBlog']; | ||
|
||
const isEligibleForTeads = (slotId: string) => { | ||
const { contentType, isSensitive } = window.guardian.config.page; | ||
|
||
// This IAS value is returned when a page is thought to contain content which is not brand safe | ||
const isBrandSafe = !window.googletag | ||
.pubads() | ||
.getTargeting('ias-kw') | ||
.includes('IAS_16425_KW'); | ||
|
||
if ( | ||
slotId === 'dfp-ad--inline1' && | ||
allowedContentTypes.includes(contentType) && | ||
!isSensitive && | ||
isBrandSafe | ||
) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
export { isEligibleForTeads }; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.