Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.7 KB
Raw Blame
import { Page } from '@playwright/test'

import { delay } from 'lib/utils/async'

import { expect } from '../utils/workspace-test-base'

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

    async createCohort(name: string): Promise<void> {
        await this.page.click('[data-attr="create-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"]')

        const categoryDropdown = this.page.getByTestId('taxonomic-category-dropdown-trigger-pill')
        await expect(categoryDropdown).toBeVisible()
        await categoryDropdown.click()

        const personPropertiesCategory = this.page.getByTestId('taxonomic-category-dropdown-item-person_properties')
        await expect(personPropertiesCategory).toBeVisible()
        await personPropertiesCategory.click()

        const personProperty = this.page.getByTestId('prop-filter-person_properties-0')
        await expect(personProperty).toBeVisible()
        await personProperty.click()
        await this.page.locator('[data-attr=prop-val]').pressSequentially('true')

        await this.page.click('[data-attr="scene-title-textarea"]')
        await this.page.locator('[data-attr="scene-title-textarea"]').pressSequentially(name)
        await delay(1000)
        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"]').first().click()
    }
}