Skip to content
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

chore: move two more to playwrt (2 plywrt 2 frious) #28802

Merged
merged 34 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
febe8b8
add cohorts
pauldambra Feb 17, 2025
d1154dd
and command bar
pauldambra Feb 17, 2025
b9fce20
Merge branch 'master' into chore/cyp-2-ply-8
pauldambra Feb 17, 2025
a67cb9f
no need to search during this test
pauldambra Feb 17, 2025
3f24682
better waiting
pauldambra Feb 17, 2025
9803d8a
Merge branch 'master' into chore/cyp-2-ply-8
pauldambra Feb 17, 2025
6194d9a
Merge branch 'master' into chore/cyp-2-ply-8
pauldambra Feb 18, 2025
14f3c10
this?
pauldambra Feb 18, 2025
8c3d4eb
Update UI snapshots for `chromium` (2)
github-actions[bot] Feb 18, 2025
ec8ea8e
this|
pauldambra Feb 18, 2025
f406cf7
this
pauldambra Feb 18, 2025
15c0000
Merge branch 'master' into chore/cyp-2-ply-8
pauldambra Feb 18, 2025
ded6385
Merge branch 'master' into chore/cyp-2-ply-8
pauldambra Feb 18, 2025
fc4a8b1
this
pauldambra Feb 18, 2025
6c1df3b
Merge branch 'master' into chore/cyp-2-ply-8
pauldambra Feb 18, 2025
298d620
fix
pauldambra Feb 18, 2025
29d86dc
Stop running these when cypress changes
pauldambra Feb 18, 2025
aa0c4db
code owner
pauldambra Feb 18, 2025
8643f28
even less
pauldambra Feb 18, 2025
6be6826
Merge branch 'master' into chore/cyp-2-ply-8
pauldambra Feb 18, 2025
a850de2
change slightly
pauldambra Feb 18, 2025
5ec3a82
Merge branch 'master' into chore/cyp-2-ply-8
pauldambra Feb 18, 2025
96c3fc1
htis?
pauldambra Feb 18, 2025
cfb3ac9
Merge branch 'master' into chore/cyp-2-ply-8
pauldambra Feb 18, 2025
e8de966
wat
pauldambra Feb 18, 2025
da079e6
Waat
pauldambra Feb 18, 2025
82bebd8
Waaat
pauldambra Feb 18, 2025
e49b67d
Merge branch 'master' into chore/cyp-2-ply-8
pauldambra Feb 18, 2025
7805429
fiddle
pauldambra Feb 18, 2025
53d5365
Waaaat
pauldambra Feb 18, 2025
839290d
Skip flaker
pauldambra Feb 18, 2025
0c9d3eb
Merge branch 'master' into chore/cyp-2-ply-8
pauldambra Feb 18, 2025
0d80a56
dang
pauldambra Feb 19, 2025
5742885
Merge branch 'master' into chore/cyp-2-ply-8
pauldambra Feb 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-e2e-playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
path: playwright/playwright-report/
retention-days: 30
if: ${{ failure() }}

Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/ci-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,12 @@ jobs:
- requirements-dev.txt
- package.json
- pnpm-lock.yaml
# Make sure we run if someone is explicitly change the workflow
- .github/workflows/ci-e2e.yml
- .github/actions/build-n-cache-image/action.yml
# We use docker compose for tests, make sure we rerun on
# changes to docker-compose.dev.yml e.g. dependency
# version changes
- docker-compose.dev.yml
- Dockerfile
- cypress/**

# Job that lists and chunks spec file names and caches node modules
chunks:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,3 @@ playwright-report/
test-results/
playwright/playwright-report/
playwright/test-results/

2 changes: 2 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ posthog/tasks/test/test_stop_surveys_reached_target.py @PostHog/team-surveys
plugin-server/src/ @PostHog/team-cdp
posthog/clickhouse/migrations/** @PostHog/clickhouse
posthog/clickhouse/migrations2/** @PostHog/clickhouse
cypress/** @pauldambra
playwright/** @pauldambra
2 changes: 1 addition & 1 deletion bin/e2e-test-runner
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,5 @@ python manage.py runserver 8080 &
if [ "$START_CYPRESS" -eq 1 ] 2>/dev/null; then
pnpm cypress open --config-file cypress.e2e.config.ts
elif [ "$START_PLAYWRIGHT" -eq 1 ] 2>/dev/null; then
pnpm exec playwright test --ui
pnpm --filter=@posthog/playwright exec playwright test --ui
fi
64 changes: 0 additions & 64 deletions cypress/e2e/cohorts.cy.ts

This file was deleted.

51 changes: 0 additions & 51 deletions cypress/e2e/commandBar.cy.ts

This file was deleted.

6 changes: 3 additions & 3 deletions playwright/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# End to End Testing
# End-to-End Testing

`/e2e/` directory contains all the end-to-end tests.
## `/e2e/` directory contains all the end-to-end tests.

to run the old cypress tests, run the following command:

Expand All @@ -16,5 +16,5 @@ START_PLAYWRIGHT=1 ./bin/e2e-test-runner

to run the new playwright tests against an already locally running PostHog instance
```bash
LOGIN_USERNAME='[email protected]' LOGIN_PASSWORD="the-password" BASE_URL='http://localhost:8010' pnpm exec playwright test --ui
LOGIN_USERNAME='[email protected]' LOGIN_PASSWORD="the-password" BASE_URL='http://localhost:8010' pnpm --filter=@posthog/playwright exec playwright test --ui
```
32 changes: 32 additions & 0 deletions playwright/e2e/command-bar.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { expect, test } from '../utils/playwright-test-base'

test.describe('Command Bar', () => {
test('Handles keyboard shortcuts', async ({ page }) => {
/** Show/hide search */
// show search
await page.keyboard.press('Control+K')
await expect(page.locator('[data-attr=search-bar-input]')).toBeVisible()

// hide search with esc
await page.keyboard.press('Escape')
await expect(page.locator('[data-attr=search-bar-input]')).not.toBeVisible()

/** Show/hide actions */
// show actions
await page.keyboard.press('Control+Shift+K')
await expect(page.locator('[data-attr=action-bar-input]')).toBeVisible()

// hide actions with esc
await page.keyboard.press('Escape')
await expect(page.locator('[data-attr=action-bar-input]')).not.toBeVisible()

/** Show/hide shortcuts */
// show shortcuts
await page.keyboard.press('Shift+?')
await expect(page.locator('text=Keyboard shortcuts')).toBeVisible()

// hide shortcuts with esc
await page.keyboard.press('Escape')
await expect(page.locator('text=Keyboard shortcuts')).not.toBeVisible()
})
})
55 changes: 55 additions & 0 deletions playwright/e2e/product-analytics/cohorts.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { expect, test } from '../../utils/playwright-test-base'
import { randomString } from '../../utils'
import { CohortPage } from '../../page-models/cohortPage'

test.describe('Cohorts', () => {
test.beforeEach(async ({ page }) => {
await page.goToMenuItem('personsmanagement')
await page.click('[data-attr=persons-management-cohorts-tab]')

await expect(page).toHaveTitle('Cohorts • People • PostHog')
await expect(page.locator('[data-attr="create-cohort"]')).toBeVisible()
await expect(page.locator('[data-attr="product-introduction-docs-link"]')).toHaveText(/Learn more/)
})

test('Can create a cohort', async ({ page }) => {
const name = randomString('Test-Cohort-')

await new CohortPage(page).createCohort(name)

await page.goToMenuItem('personsmanagement')
await page.click('[data-attr=persons-management-cohorts-tab]')

await expect(page.locator('tbody')).toContainText(name)
})

// works locally fails in CI
test.skip('Duplicate a cohort', async ({ page }) => {
const name = randomString('Test-Cohort-')

await new CohortPage(page).createCohort(name)

await page.goToMenuItem('personsmanagement')
await page.click('[data-attr=persons-management-cohorts-tab]')

// navigate to the page
await page.click('tbody >> text=' + name)
await expect(page.getByTestId('top-bar-name').getByText('Test-Cohort--')).toBeVisible()
await page.click('.TopBar3000 [data-attr="more-button"]', { force: true })
// click edit
await page.click('.Popover__content >> text=Duplicate as dynamic cohort')
await page.click('.Toastify__toast-body >> text=View cohort')

await page.click('.TopBar3000 [data-attr="more-button"]')
await page.click('.Popover__content >> text=Duplicate as static cohort')
await page.click('.Toastify__toast-body >> text=View cohort')

await page.click('[data-attr="more-button"]')
await page.click('.Popover__content >> text=Delete cohort')

await page.goToMenuItem('personsmanagement')
await page.click('[data-attr=persons-management-cohorts-tab]')

await expect(page.locator('tbody')).not.toContainText(name + ' (dynamic copy) (static copy)')
})
})
23 changes: 23 additions & 0 deletions playwright/page-models/cohortPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Page } from '@playwright/test'
import { expect } from '../utils/playwright-test-base'

export class CohortPage {
constructor(private readonly page: Page) {}

async createCohort(name: string): Promise<void> {
await this.page.click('[data-attr="new-cohort"]')
await this.page.click('[data-attr="cohort-selector-field-value"]')
await this.page.click('[data-attr="cohort-personPropertyBehavioral-have_property-type"]')
await this.page.click('[data-attr="cohort-taxonomic-field-key"]')

await this.page.click('[data-attr=prop-filter-person_properties-0]', { force: true })
await this.page.locator('[data-attr=prop-val]').type('true')

await this.page.click('[data-attr="cohort-name"]')

await this.page.fill('[data-attr="cohort-name"]', name)
await this.page.click('[data-attr="save-cohort"]')
await expect(this.page.locator('[data-attr=success-toast]')).toHaveText(/Cohort saved/)
await this.page.locator('[data-attr="toast-close-button"]').click()
}
}
2 changes: 1 addition & 1 deletion playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { defineConfig, devices } from '@playwright/test'
export default defineConfig({
testDir: '.',
/* Maximum time one test can run for. */
timeout: 90 * 1000,
timeout: 45 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
Expand Down
Loading