-
Notifications
You must be signed in to change notification settings - Fork 4.4k
chore: improve production test runner on TeamCity #5350
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
42517c0
fix(e2e): adjust Playwright config for TeamCity
zoobestik 870313b
fix(ci): add branch filter for production E2E notifications
zoobestik 04139c7
fix(e2e): handling cookie banner for production tests
zoobestik 43b1a68
fix(e2e): remove unused isStaging function and update tests
zoobestik ff9926b
test(e2e): add cookie banner test for production pages
zoobestik 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 |
|---|---|---|
|
|
@@ -50,4 +50,5 @@ generated | |
| /data/page_views_map.json | ||
| test-results | ||
|
|
||
| public/data | ||
| public/data | ||
| test/storage-state.json | ||
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
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
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
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
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
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
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
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,56 @@ | ||
| import { join } from 'node:path'; | ||
| import { writeFile } from 'node:fs/promises'; | ||
| import { chromium, FullConfig } from '@playwright/test'; | ||
| import { isProduction } from './utils'; | ||
|
|
||
| export default async function globalSetup(config: FullConfig) { | ||
| const storageStatePath = join(__dirname, 'storage-state.json'); | ||
| await writeFile(storageStatePath, '{}', 'utf-8'); | ||
|
|
||
| const project = config.projects[0]; | ||
| console.log(`[Global Setup] Processing project ${project.name}`); | ||
| const baseURL = project.use?.baseURL; | ||
|
|
||
| if (isProduction(baseURL)) { | ||
| await closeProductionElements(baseURL, storageStatePath); | ||
| } | ||
| } | ||
|
|
||
| async function closeProductionElements(baseURL: string, storageStatePath: string) { | ||
| console.log(`[Global Setup] Starting cookie banner setup for ${baseURL}`); | ||
|
|
||
| const browser = await chromium.launch(); | ||
| const context = await browser.newContext(); | ||
| const page = await context.newPage(); | ||
|
|
||
| try { | ||
| await page.goto(baseURL, { waitUntil: 'domcontentloaded' }); | ||
|
|
||
| try { | ||
| const acceptButton = page.getByRole('button', { name: 'Accept All' }); | ||
| await acceptButton.waitFor({ state: 'visible', timeout: 5000 }); | ||
| await acceptButton.click(); | ||
|
|
||
| await page.waitForTimeout(1000); | ||
| } catch (error) { | ||
| console.log('[Global Setup] Cookie banner not found - continuing'); | ||
| } | ||
|
|
||
| const closeBanner = page.locator('#optly-banner_close'); | ||
|
|
||
| if (await closeBanner.count() > 0) { | ||
| console.log('[Global Setup] Closing "purple" banner'); | ||
| await closeBanner.click(); | ||
| await page.waitForSelector('#optly-banner_close', { state: 'hidden' }); | ||
| } | ||
|
|
||
| await context.storageState({ path: storageStatePath }); | ||
| console.log(`[Global Setup] Storage state saved to ${storageStatePath}`); | ||
| } catch (error) { | ||
| console.error('[Global Setup] Error during setup:', error); | ||
| throw error; | ||
| } finally { | ||
| await context.close(); | ||
| await browser.close(); | ||
| } | ||
| } |
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
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
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
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
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,44 @@ | ||
| import { expect, test as base } from '@playwright/test'; | ||
| import { skipNonProduction } from '../utils'; | ||
|
|
||
| skipNonProduction('Cookie banner only on production'); | ||
|
|
||
| const test = base.extend({ | ||
| page: async ({ browser }, use) => { | ||
| const context = await browser.newContext({ | ||
| storageState: undefined | ||
| }); | ||
| const page = await context.newPage(); | ||
|
|
||
| await use(page); | ||
|
|
||
| await page.close(); | ||
| await context.close(); | ||
| } | ||
| }); | ||
|
|
||
| test.describe('Cookie banner functionality', () => { | ||
| const PAGE_TYPES_EXAMPLE = [ | ||
| '/', | ||
| '/docs/getting-started.html', | ||
| '/docs/multiplatform/get-started.html', | ||
| '/api/core/kotlin-stdlib/', | ||
| '/api/kotlinx.coroutines/kotlinx-coroutines-core/', | ||
| '/lp/multiplatform/case-studies/autodesk/' | ||
| ]; | ||
|
|
||
| for (const path of PAGE_TYPES_EXAMPLE) { | ||
| test(`Cookie banner should be visible and closeable: ${path}`, async ({ page, baseURL }) => { | ||
| await page.goto(`${baseURL}${path}`); | ||
|
|
||
| const acceptButton = page.getByRole('button', { name: 'Accept All' }); | ||
| await expect(acceptButton).toBeVisible({ timeout: 10000 }); | ||
|
|
||
| await acceptButton.click(); | ||
| await expect(acceptButton).toBeHidden({ timeout: 3000 }); | ||
|
|
||
| const cookies = await page.context().cookies(); | ||
| expect(cookies.length).toBeGreaterThan(0); | ||
| }); | ||
| } | ||
| }); |
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
Please check how the order in which tests are run affects the closing of a cookie banner.
For example, if we run a test for a cookie banner, it should reset the previously saved state (when the banner was closed) and check that it exists. This means we'll save the state when the banner should be open.
If we then run another test where the banner should already be closed, will it pass?