Skip to content

Commit

Permalink
Merge branch 'master' into feature-management-backend-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
havenbarnes authored Dec 18, 2024
2 parents 8e8b562 + 7dd30e3 commit 77a5a0c
Show file tree
Hide file tree
Showing 74 changed files with 1,884 additions and 804 deletions.
83 changes: 0 additions & 83 deletions cypress/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,19 +341,6 @@ describe('Dashboard', () => {
})
})

/**
* This test is currently failing because the query that runs when you open the dashboard includes the code
* select equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(properties, 'app_rating'), ''), 'null'), '^"|"$', ''), 5.) from events where event ilike '%rated%';
* This throws the error Code: 386. DB::Exception: There is no supertype for types String, Float64 because some of them are String/FixedString and some of them are not. (NO_COMMON_TYPE)
* All the 'app_ratings' are extracted as strings and 5. is a float
*/
// it('Opens dashboard item in insights', () => {
// cy.get('[data-attr=dashboard-name]').contains('App Analytics').click()
// cy.get('.InsightCard [data-attr=insight-card-title]').first().click()
// cy.location('pathname').should('include', '/insights')
// cy.get('[data-attr=funnel-bar-vertical]', { timeout: 30000 }).should('exist')
// })

it('Add insight from empty dashboard', () => {
const dashboardName = randomString('dashboard-')
dashboards.createAndGoToEmptyDashboard(dashboardName)
Expand All @@ -363,76 +350,6 @@ describe('Dashboard', () => {
cy.get('[data-attr="top-bar-name"] .EditableField__display').contains(dashboardName).should('exist')
})

it('Changing dashboard filter shows updated insights', () => {
const dashboardName = randomString('to add an insight to')
const firstInsight = randomString('insight to add to dashboard')

// Create and visit a dashboard to get it into turbo mode cache
dashboards.createAndGoToEmptyDashboard(dashboardName)
dashboard.addInsightToEmptyDashboard(firstInsight)

dashboard.addPropertyFilter()

cy.get('.PropertyFilterButton').should('have.length', 1)

// refresh the dashboard by changing date range
cy.get('[data-attr="date-filter"]').click()
cy.contains('span', 'Last 14 days').click()

cy.wait(2000)

// insight meta should be updated to show new date range
cy.get('h5').contains('Last 14 days').should('exist')

cy.get('button').contains('Save').click()

// should save filters
cy.get('.PropertyFilterButton').should('have.length', 1)
// should save updated date range
cy.get('span').contains('Last 14 days').should('exist')
})

// TODO: this test works locally, just not in CI
it.skip('Clicking cancel discards dashboard filter changes', () => {
const dashboardName = randomString('to add an insight to')
const firstInsight = randomString('insight to add to dashboard')

// Create and visit a dashboard to get it into turbo mode cache
dashboards.createAndGoToEmptyDashboard(dashboardName)
dashboard.addInsightToEmptyDashboard(firstInsight)

// add property filter
cy.get('.PropertyFilterButton').should('have.length', 0)
cy.get('[data-attr="property-filter-0"]').click()
cy.get('[data-attr="taxonomic-filter-searchfield"]').click().type('Browser').wait(1000)
cy.get('[data-attr="prop-filter-event_properties-0"]').click({ force: true }).wait(1000)
cy.get('.LemonInput').type('Chrome')
cy.contains('.LemonButton__content', 'Chrome').click({ force: true })

// added property is present
cy.get('.PropertyFilterButton').should('have.length', 1)

// refresh the dashboard by changing date range
cy.get('[data-attr="date-filter"]').click()
cy.contains('span', 'Last 14 days').click()

cy.wait(2000)

// insight meta should be updated to show new date range
// default date range is last 7 days
cy.get('h5').contains('Last 14 days').should('exist')

// discard changes
cy.get('button').contains('Cancel').click()

// should reset filters to be empty
cy.get('.PropertyFilterButton').should('have.length', 0)
// should reset date range to no override
cy.get('span').contains('No date range overrid').should('exist')
// should reset insight meta date range
cy.get('h5').contains('Last 7 days').should('exist')
})

it('clicking on insight carries through dashboard filters', () => {
const dashboardName = randomString('to add an insight to')
const firstInsight = randomString('insight to add to dashboard')
Expand Down
110 changes: 23 additions & 87 deletions cypress/e2e/events.cy.ts
Original file line number Diff line number Diff line change
@@ -1,54 +1,26 @@
const interceptPropertyDefinitions = (): void => {
cy.intercept('/api/event/values?key=%24browser').as('getBrowserValues')

cy.intercept('api/projects/@current/property_definitions/?limit=5000', {
fixture: 'api/event/property_definitions',
})

cy.intercept('/api/projects/*/property_definitions?is_feature_flag=false&search=&*', {
fixture: 'api/event/property_definitions',
})

cy.intercept('/api/projects/*/property_definitions?is_feature_flag=false&search=%24time*', {
fixture: 'api/event/only_time_property_definition',
})

cy.intercept('/api/projects/*/property_definitions?is_feature_flag=false&search=%24browser*', {
fixture: 'api/event/only_browser_version_property_definition',
})

cy.intercept('/api/projects/*/property_definitions?is_feature_flag=true*', {
fixture: 'api/event/feature_flag_property_definition',
})
}

const selectNewTimestampPropertyFilter = (): void => {
cy.get('[data-attr="new-prop-filter-EventPropertyFilters.0"]').click()
cy.get('[data-attr=taxonomic-filter-searchfield]').type('$time')
cy.get('.taxonomic-list-row').should('have.length', 1)
cy.get('[data-attr=prop-filter-event_properties-0]').click({ force: true })
}
describe('Events', () => {
beforeEach(() => {
cy.intercept('/api/event/values?key=%24browser').as('getBrowserValues')

const selectOperator = (operator: string, openPopover: boolean): void => {
if (openPopover) {
cy.get('[data-attr="property-filter-0"] .property-filter .property-filter-button-label').click()
}
cy.intercept('api/projects/@current/property_definitions/?limit=5000', {
fixture: 'api/event/property_definitions',
})

cy.get('[data-attr="taxonomic-operator"]').click()
cy.get('.operator-value-option').its('length').should('eql', 8)
cy.get('.operator-value-option').contains('< before').should('be.visible')
cy.get('.operator-value-option').contains('> after').should('be.visible')
cy.intercept('/api/projects/*/property_definitions?is_feature_flag=false&search=&*', {
fixture: 'api/event/property_definitions',
})

cy.get('.operator-value-option').contains(operator).click()
}
cy.intercept('/api/projects/*/property_definitions?is_feature_flag=false&search=%24time*', {
fixture: 'api/event/only_time_property_definition',
})

const changeSecondPropertyFilterToDateAfter = (): void => {
selectOperator('> after', true)
}
cy.intercept('/api/projects/*/property_definitions?is_feature_flag=false&search=%24browser*', {
fixture: 'api/event/only_browser_version_property_definition',
})

describe('Events', () => {
beforeEach(() => {
interceptPropertyDefinitions()
cy.intercept('/api/projects/*/property_definitions?is_feature_flag=true*', {
fixture: 'api/event/feature_flag_property_definition',
})

cy.intercept('/api/event/values/?key=$browser_version', (req) => {
return req.reply([{ name: '96' }, { name: '97' }])
Expand Down Expand Up @@ -85,7 +57,11 @@ describe('Events', () => {
})

it('use before and after with a DateTime property', () => {
selectNewTimestampPropertyFilter()
// Select the time property
cy.get('[data-attr="new-prop-filter-EventPropertyFilters.0"]').click()
cy.get('[data-attr=taxonomic-filter-searchfield]').type('$time')
cy.get('.taxonomic-list-row').should('have.length', 1)
cy.get('[data-attr=prop-filter-event_properties-0]').click({ force: true })

cy.get('[data-attr="taxonomic-operator"]').click()
cy.get('.operator-value-option').should('contain.text', '> after')
Expand Down Expand Up @@ -122,44 +98,4 @@ describe('Events', () => {
cy.wait(500)
cy.get('[data-attr="taxonomic-operator"]').should('be.visible')
})

/**
* Test fails because property filters act on properties.$time but not all events have that property
*
* Needs https://github.com/PostHog/posthog/issues/8250 before can query on timestamp
*/
it.skip('can filter after a date and can filter before it', () => {
cy.intercept(/api\/projects\/\d+\/activity\/explore\/.*/).as('getEvents')

selectNewTimestampPropertyFilter()

selectOperator('< before', undefined)
cy.get('[data-attr=taxonomic-value-select]').click()

cy.get('[data-attr="lemon-calendar-month-previous"]').first().click()
cy.get('[data-attr="lemon-calendar-day"]').first().click()
cy.get('[data-attr="lemon-calendar-select-apply"]').first().click()
cy.get('[data-attr="property-filter-0"]').should('include.text', 'Time < ')

cy.wait('@getEvents').then(() => {
cy.get('tr.event-row:first-child').should('contain.text', 'a day ago')
cy.get('tr.event-row').should((rows) => {
// test data setup is slightly random so...
expect(rows.length).to.be.greaterThan(50)
expect(rows.length).to.be.lessThan(110)
})

changeSecondPropertyFilterToDateAfter()

cy.wait('@getEvents').then(() => {
// as the seeded events are random(-ish) we can't assert on how long ago they will be
cy.get('tr.event-row:first-child').should('not.contain.text', 'a day ago')
cy.get('tr.event-row').should((rows) => {
// test data setup is slightly random so...
expect(rows.length).to.be.greaterThan(5)
expect(rows.length).to.be.lessThan(10)
})
})
})
})
})
75 changes: 0 additions & 75 deletions cypress/e2e/funnels.cy.ts

This file was deleted.

6 changes: 0 additions & 6 deletions cypress/e2e/insights-navigation-open-directly.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ describe('Insights', () => {
cy.get('.funnels-empty-state__title').should('exist')
})

it.skip('can open a new retention insight', () => {
insight.newInsight('RETENTION')
cy.get('.RetentionContainer canvas').should('exist')
cy.get('.RetentionTable__Tab').should('have.length', 66)
})

it('can open a new paths insight', () => {
insight.newInsight('PATHS')
cy.get('.Paths g').should('have.length.gte', 5) // not a fixed value unfortunately
Expand Down
24 changes: 0 additions & 24 deletions cypress/e2e/insights-saved.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,9 @@ import { urls } from 'scenes/urls'

import { createInsight } from '../productAnalytics'

chai.Assertion.addMethod('neverHaveChild', function (childSelector) {
this._obj.on('DOMNodeInserted', () => {
const matchCount = cy.$$(childSelector, this._obj).length
if (matchCount > 0) {
throw new Error(
`Expected element to never have child ${childSelector}, but found ${matchCount} match${
matchCount > 1 ? 'es' : ''
}`
)
}
})
})

// For tests related to trends please check trendsElements.js
// insight tests were split up because Cypress was struggling with this many tests in one file🙈
describe('Insights - saved', () => {
// TODO: this test works locally, just not in CI
// also change 'neverHaveChild' check to start right after page loads
it.skip('Data is available immediately', () => {
createInsight('saved insight').then((newInsightId) => {
cy.get('[data-attr=trend-line-graph]').should('exist') // Results cached
cy.visit(urls.insightView(newInsightId)) // Full refresh
cy.get('.InsightViz').should('exist').should('neverHaveChild', '.insight-empty-state') // Only cached data
cy.get('[data-attr=trend-line-graph]').should('exist')
})
})

it('If cache empty, initiate async refresh', () => {
cy.intercept('GET', /\/api\/environments\/\d+\/insights\/?\?[^/]*?refresh=async/).as('getInsightsRefreshAsync')
let newInsightId: string
Expand Down
12 changes: 0 additions & 12 deletions cypress/e2e/notebooks.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@ describe('Notebooks', () => {
cy.get('.NotebookRecordingTimestamp.opacity-50').should('not.exist')
})

// FIXME: fix commenting on recordings
it.skip('Can comment on a recording', () => {
cy.visit(urls.replay())

cy.get('[data-attr="notebooks-add-button"]').click()
cy.get('[data-attr="notebooks-select-button-create"]').click()

cy.get('.Notebook.Notebook--editable').should('be.visible')
cy.get('.ph-recording.NotebookNode').should('be.visible')
cy.get('.NotebookRecordingTimestamp').should('contain.text', '0:00')
})

describe('text types', () => {
beforeEach(() => {
cy.get('li').contains('Notebooks').should('exist').click()
Expand Down
Loading

0 comments on commit 77a5a0c

Please sign in to comment.