test(e2e): Centralize cookie banner handling in global setup and cleanup test code#5333
Conversation
29b4bbb to
c5ba157
Compare
ba5acba to
dac5cbe
Compare
zoobestik
commented
Jan 27, 2026
| /reports* | ||
| /data/page_views_map.json | ||
| test-results | ||
| test/storage-state.json |
Collaborator
Author
There was a problem hiding this comment.
It is created each time the tests run, see shared account in all tests
| const test = base.extend({ | ||
| context: async function makeCleanContext({ browser }, use) { | ||
| const context = await browser.newContext({ | ||
| storageState: undefined |
Collaborator
Author
There was a problem hiding this comment.
New test, run without shared account for testing cookie banner on production.
For skipping tests on production, use snippet:
test.skip(({ baseURL }) => isProduction(baseURL), '...');
It works for any level: module, describe, test.
| expect(await link1.textContent()).toBe('Free IntelliJ IDEA Ultimate license ↗'); | ||
|
|
||
| const link2 = toolingSectionInfo.locator('a[href="https://play.kotlinlang.org/"]'); | ||
| const link2 = toolingSectionInfo.locator('a[href^="https://play.kotlinlang.org/"]'); |
Collaborator
Author
nikpachoo
approved these changes
Jan 30, 2026
| expect(await link4.textContent()).toBe('Code With Me ↗'); | ||
|
|
||
| const link5 = toolingSectionInfo.locator('a[href="https://hyperskill.org/tracks?category=4&utm_source=jbkotlin_hs&utm_medium=referral&utm_campaign=kotlinlang-education&utm_content=button_1&utm_term=22.03.23&"]'); | ||
| const link5 = toolingSectionInfo.locator('a[href^="https://hyperskill.org/tracks?category=4&utm_source=jbkotlin_hs&utm_medium=referral&utm_campaign=kotlinlang-education&utm_content=button_1&utm_term=22.03.23"]'); |
Collaborator
There was a problem hiding this comment.
WDYT, maybe it's better to omit the UTM tags?
Suggested change
| const link5 = toolingSectionInfo.locator('a[href^="https://hyperskill.org/tracks?category=4&utm_source=jbkotlin_hs&utm_medium=referral&utm_campaign=kotlinlang-education&utm_content=button_1&utm_term=22.03.23"]'); | |
| const link5 = toolingSectionInfo.locator('a[href^="https://hyperskill.org/tracks?category=4"]'); |
- Add global setup for Playwright tests with cookie banner functionality. - Simplify `closeExternalBanners` utility for better production handling. - Skip cookie banner tests in non-production environments. - Update test configurations and remove unnecessary consent banner logic. - Adjust case-study and navigation link verifications. - Amend storage state usage in Playwright settings. # Conflicts: # .gitignore
- Add `playwright-teamcity-reporter@1.0.5` to dependencies. - Update Playwright configuration to use `playwright-teamcity-reporter` as the default reporter in CI mode.
- Replace obsolete dependencies in E2E tests with simplified `BuildSitePages`. - Update artifact rules to consolidate output in `dist` directory. - Simplify Dockerfile by removing unused `libs` and `_assets` copies.
- Upgrade Playwright to version 1.57 in Docker and dependencies. - Replace custom Dockerfiles with official lightweight images. - Simplify `docker-compose-e2e-statics.yml` by using shared volumes and updated networks. - Refactor `global-setup.ts` to ensure consistent storage state initialization. - Adjust `closeExternalBanners` logic to improve development checks. - Fix test `beforeEach` hooks ordering in education-related specs for consistency.
…cy with production setup
- Add error handling for `waitForLoadState` to improve debugging of failed customer link loads. - Remove unused `isProduction` import from test utilities.
…spec.ts - Add `scrollIntoViewIfNeeded` to ensure visibility before hovering customer links.
- Add context-aware `test.step` usage to enhance customer link verification flow. - Refactor `scrollIntoViewIfNeeded` and `click` logic within `isVisible` check for clarity. - Update `waitForLoadState` with `domcontentloaded` and timeout for better performance.
- Add `try-catch` block to handle invalid URL parsing gracefully. - Update development environment check to validate `baseURL` and exclude `localhost`.
- Replace absolute URLs with relative path checks across multiple test specs. - Update `solutions-tab.spec.ts`, `main-page-buttons.spec.ts`, and `landings.spec.ts` to improve maintainability and alignment with production setup.
- across `solutions-tab.spec.ts`, `grammar.spec.ts`, and `landings.spec.ts`. - Remove unused `baseURL` parameter from tests for improved clarity and maintenance.
- Correct `isDevelopment` utility function to properly identify `localhost` as a development environment.
- Correct `isDevelopment` utility function to properly identify `localhost` as a development environment.
- Add `data-test` attributes to various components in `education`, replacing CSS-based selectors for improved test reliability. - Remove `closeExternalBanners` utility and its usage across tests as it is no longer needed. - Update Playwright specs (`courses.spec.ts`, `education.spec.ts`) to use `data-test` attributes. - Refactor relative path navigation in tests for `CoursesPage` and `TeachPage` initialization.
- Eliminate unnecessary `waitForTimeout` calls for improved test performance in `teach.spec.ts`. - Refactor `playwright.config.ts` to enhance `isDevelopment` logic, ensuring proper handling of CI and local development environments.
- Replace outdated CSS file references with updated paths (`hide-sticky-banner.css` → `sticky-navigation.css`) across E2E tests. - Improve `checkScreenshot` utility to handle lazy-loaded images by setting `loading` to `eager` and `decoding` to `sync`. - Extend `checkScreenshot` to support additional `stylePath` options for more flexible screenshot styling. - Refactor `global-setup.ts` to generalize banner handling (`closeConsentBanner` → `closeProductionElements`) and ensure DOM readiness. - Consolidate `isDevelopment` logic in `playwright.config.ts` for streamlined configuration management.
- Remove obsolete `utils.ts` in `e2e` and move relevant utilities to the main `utils.ts` file for centralized management. - Replace outdated `sticky-navigation.css` references with updated paths (`test/snapshots/assets/sticky-navigation.css`) across multiple specs. - Add `skipProduction` and `skipNonProduction` utilities to replace inline `test.skip` calls, improving readability and consistency. - Refactor `checkFullPageScreenshot` and `getElementScreenshotWithPadding` functionality for enhanced screenshot handling. - Simplify logic in production-related tests (`cookie-banner.spec.ts`, `landings.spec.ts`) with new utilities.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

The main changes include a new global setup for managing cookie consent on production, a refactor of banner dismissal logic, updates to Playwright configuration and dependencies, and cleanup of test code to remove redundant cookie banner interactions.
Test Infrastructure Improvements
global-setup.tsscript for Playwright that automatically handles cookie banner acceptance and storage state creation for production environments. This ensures tests run without manual banner interaction and maintains consistent state across test runs.playwright-teamcity-reporteras a dependency inpackage.jsonto support enhanced reporting in CI environments.🖼️ Teamcity Test Report
Cookie Banner Handling Refactor
closeCookiesConsentBannerfunction with a newcloseExternalBannersthat only dismisses development overlays, and moved cookie banner handling for production to global setup. Updated all test files to use the new approach and removed redundant cookie banner interactions from production tests.Test Logic Enhancements