This repository contains VSCode development container config to help you get started.
If you prefer not to use VSCode or Docker then you can see .devcontainer/Dockerfile and .devcontainer/postcreate.sh for config and build instructions.
There are two ways to "run" this website:
- The "fast" way: via eyeo/cms development test server
- clone cms server
- in your
.zshrcset path to your cms projectexport PYTHONPATH="$HOME/<path>/cms:$PYTHONPATH" npm run fast
- The "slow" way: via apache2
npm run slow
.htaccess features (e.g. redirect, geoip) only work the "slow" way.
Try 127.0.0.1 if localhost doesn't work (effects the fast way on macOS).
The navbar, header, toc, footer components mentioned below are optionally disabled via no${component} page attributes.
- minimal: contains navbar, footer, and no body container. Meant for landing pages.
- modern: contains navbar, spaced body container, and footer. Meant for modern content pages.
- default: contains navbar, spaced body container, header, toc, and footer. Meant for legacy content pages.
- fixed-toc: contains navbar, fixed left toc, content right, header, and footer. Meant for documentation pages.
A "flag" type below counts as "true" regardless of the query param value.
variantnumber - experiment variant to applycountrystring - 2 letter country codedefaultCurrencystring - 3 letter currency coderestrictPremiumboolean - used to disable buying premiumrestrictPrivacyboolean - used to disable some 3rd party servicessidstring - 32 char unique id used to associate access logs with one anothersstring - traffic source name for marketing purposesdevflag - used for development purposesdesignflag - used for development purpsoses
Unless a language is provided in the URL (e.g. via selecting language in the navbar dropdown) DE_EXCEPTION is used as part of an exception that forces German language in Germany despite browser preferences.
testmodeflag - changes the payment environment from "live" to "sandbox".has-subscriptionstring - Fake "prevent duplicate subscirption" intervention states and outcomesyes- The client will always have a subscriptionno- The client will never have a subscriptionerror- The subscription check will always failtimeout- The subscription check will always timeoutfinding- Show the subscription finding statefound- Show the subscription found state
bcnumber - show alternate CTA with block count
premium-checkout__handoffflag - used to communicate premium checkout handoff from one page to anotherpremium-checkout__flowstring - used to name a flow that a premium checkout handoff is completingpremium-checkout__pagestring - used to name a page that a premium checkout handoff is coming frompremium-checkout__productstring - product name being purchased by premium checkoutpremium-checkout__premiumIdstring - unique id for premium subscription (sometimes called userid)premium-checkout__currencystring - 3 letter currency code of premium checkoutpremium-checkout__frequencystring - premium checkout subscription frequency once|monthly|yearlypremium-checkout__amountnumber - premium checkout amount in centspremium-checkout__countrystring - 2 letter country code from premium checkoutpremium-checkout__localestring - 2-5 letter language code from premium checkoutpremium-checkout__timestampnumber - datetime stamp from premium checkoutreenrollflag - used to show an alternative premium CTA for reenrolling.
ap of firefox and av of greater or equal to 3.21.1 are used to show a message about data collection to Firefox users on the installed page.
When premium is purchased before ABP is installed then premium-checkout__install is used to trigger storing values in the browser to cause the post-install page to redirect to the premium activation page.
These test jobs run automatically in the GitLab pipeline:
- browser_tests - this is a subset of tests that run for all browsers (Chromium, Edge, Chrome, Safari, and Firefox)
- chromium_tests - this is all of the remaining tests (except third party link and visual regression tests) run on Chromium only
These test jobs are available in the Gitlab pipeline to be manually run as needed:
- platform_tests - this runs a downstream pipeline of https://gitlab.com/eyeo/browser-extensions-and-premium/user-accounts/platform-team-tests and will eventually be phased out
- visual_regression_tests - these compare snapshots of pages against baseline snapshots
Additionally there is a daily scheduled run of all tests on all browsers.
Can download the artifacts for any test fails and use the trace.zip file from the test-results folder with https://trace.playwright.dev to view detailed results.
Initial Playwright installation in Terminal from adblockplus.org folder:
npm installnpx playwright install
Running tests in Terminal from adblockplus.org folder:
npx playwright test --project chromium- To run on a staging URL:
STAGING=1 STAGING_URL=any_url_here npx playwright test --project chromium - Can run the tests on all browsers using simply
npx playwright test, but this will take longer to run- Running on all browsers may also require installation of Chrome/Edge:
npx playwright install chrome msedge
- Running on all browsers may also require installation of Chrome/Edge:
- Possible projects currently:
- chromium
- "Google Chrome"
- "Microsoft Edge"
- firefox
- webkit - this will run tests on Safari
Can also run tests only for specific tags:
- Run for a specific tag:
npx playwright test --grep @all_browsers - Exclude specific tags and only run on Chromium:
npx playwright test --project chromium --grep-invert "@third_party_link|@all_browsers"
Available tags:
- @all_browsers - these tests have different behaviour on different browsers
- @third_party_link - these tests can fail due to third party sites being down
- @visual_regression - compares snapshots for each page against an approved baseline snapshot
Currently visual regression snapshots are only included in the repository for Linux Chromium. In order to update these snapshots can download the visual_regression_tests:archive artifact after the test job has failed. Rename the actual file to be simply the browser name and then replace the existing file in the linux folder for the page.
If running snapshot tests locally and no existing snapshot exists, Playwright will automatically create the baseline snapshot. These can then be used as the baseline for future runs locally. If running locally and there are snapshot differences and want to confirm new changes can run npx playwright test --grep @visual_regression --update-snapshots to update all snapshots for that environment.
For some visual regression tests it can be useful to open the page for a specific country to control changing details such as currency and pricing. Can use the ?country=DE parameter in the URL as shown in premium.spec.js: await premiumPage.openPage('country=DE');
It is possible to mock the extension data for tests that require the extension to be installed. mockExtensionData can be found in /test-helpers/extension-helper.js and there is an example of it in use in /premium.spec.js.
Simply use await ExtensionHelper.mockExtensionData(page, '4.31.0', false); before opening the page to insert the relevant extension data into the page. You can include any extension version that may be needed, and true or false to indicate whether Premium should be enabled.
Some tests may require full extension installation, for example for links that open extension pages. This is not yet set up for the Adblock Plus website, but the AdBlock website has this enabled as a testWithExtension fixture in extension-helper.js so it would be easy to copy this example for Adblock Plus tests when needed. Mocking the extension data is preferable when suitable for faster test runs.