2022-01-25 23:34:34 +01:00
|
|
|
import { dayjs } from 'lib/dayjs'
|
2022-01-13 21:10:39 +01:00
|
|
|
|
2022-12-30 11:23:09 +01:00
|
|
|
const interceptPropertyDefinitions = (): void => {
|
2023-10-12 01:51:47 +02:00
|
|
|
cy.intercept('/api/event/values/?key=%24browser').as('getBrowserValues')
|
|
|
|
|
2022-01-13 21:10:39 +01:00
|
|
|
cy.intercept('api/projects/@current/property_definitions/?limit=5000', {
|
|
|
|
fixture: 'api/event/property_definitions',
|
|
|
|
})
|
|
|
|
|
2022-08-09 11:30:37 +02:00
|
|
|
cy.intercept('/api/projects/1/property_definitions?is_feature_flag=false&search=&*', {
|
2022-01-13 21:10:39 +01:00
|
|
|
fixture: 'api/event/property_definitions',
|
|
|
|
})
|
|
|
|
|
2022-08-09 11:30:37 +02:00
|
|
|
cy.intercept('/api/projects/1/property_definitions?is_feature_flag=false&search=%24time*', {
|
2022-01-13 21:10:39 +01:00
|
|
|
fixture: 'api/event/only_time_property_definition',
|
|
|
|
})
|
|
|
|
|
2022-08-09 11:30:37 +02:00
|
|
|
cy.intercept('/api/projects/1/property_definitions?is_feature_flag=false&search=%24browser*', {
|
2022-01-13 21:10:39 +01:00
|
|
|
fixture: 'api/event/only_browser_version_property_definition',
|
|
|
|
})
|
2022-08-09 11:30:37 +02:00
|
|
|
|
|
|
|
cy.intercept('/api/projects/1/property_definitions?is_feature_flag=true*', {
|
|
|
|
fixture: 'api/event/feature_flag_property_definition',
|
|
|
|
})
|
2022-01-13 21:10:39 +01:00
|
|
|
}
|
|
|
|
|
2022-12-30 11:23:09 +01:00
|
|
|
const selectNewTimestampPropertyFilter = (): void => {
|
2023-06-29 15:23:36 +02:00
|
|
|
cy.get('[data-attr="new-prop-filter-EventPropertyFilters.0"]').click()
|
2022-02-08 14:49:11 +01:00
|
|
|
cy.get('[data-attr=taxonomic-filter-searchfield]').type('$time')
|
2022-02-21 08:11:47 +01:00
|
|
|
cy.get('.taxonomic-list-row').should('have.length', 1)
|
|
|
|
cy.get('[data-attr=prop-filter-event_properties-0]').click({ force: true })
|
2022-01-25 17:25:20 +01:00
|
|
|
}
|
|
|
|
|
2023-02-03 12:40:22 +01:00
|
|
|
const selectOperator = (operator: string, openPopover: boolean): void => {
|
|
|
|
if (openPopover) {
|
2022-01-25 23:34:34 +01:00
|
|
|
cy.get('[data-attr="property-filter-0"] .property-filter .property-filter-button-label').click()
|
|
|
|
}
|
|
|
|
|
2022-09-10 17:40:13 +02:00
|
|
|
cy.get('[data-attr="taxonomic-operator"]').click()
|
2022-02-08 14:49:11 +01:00
|
|
|
cy.get('.operator-value-option').its('length').should('eql', 8)
|
2022-01-25 23:34:34 +01:00
|
|
|
cy.get('.operator-value-option').contains('< before').should('be.visible')
|
|
|
|
cy.get('.operator-value-option').contains('> after').should('be.visible')
|
|
|
|
|
|
|
|
cy.get('.operator-value-option').contains(operator).click()
|
|
|
|
}
|
|
|
|
|
2022-12-30 11:23:09 +01:00
|
|
|
const changeSecondPropertyFilterToDateAfter = (): void => {
|
2022-02-08 14:49:11 +01:00
|
|
|
selectOperator('> after', true)
|
2022-01-25 23:34:34 +01:00
|
|
|
}
|
|
|
|
|
2020-05-22 18:34:48 +02:00
|
|
|
describe('Events', () => {
|
|
|
|
beforeEach(() => {
|
2022-01-13 21:10:39 +01:00
|
|
|
interceptPropertyDefinitions()
|
|
|
|
|
|
|
|
cy.intercept('/api/event/values/?key=$browser_version', (req) => {
|
|
|
|
return req.reply([{ name: '96' }, { name: '97' }])
|
2021-05-13 23:13:54 +02:00
|
|
|
})
|
2022-01-13 21:10:39 +01:00
|
|
|
|
2020-06-17 11:46:22 +02:00
|
|
|
cy.visit('/events')
|
2020-05-22 18:34:48 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Events loaded', () => {
|
2023-06-29 15:23:36 +02:00
|
|
|
cy.get('.DataTable').should('exist')
|
2020-05-22 18:34:48 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Click on an event', () => {
|
2023-06-29 15:23:36 +02:00
|
|
|
cy.get('.DataTable [data-row-key]:nth-child(2) td:first-child').click()
|
2020-08-22 18:03:12 +02:00
|
|
|
cy.get('[data-attr=event-details]').should('exist')
|
2020-05-22 18:34:48 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Apply 1 overall filter', () => {
|
2023-06-29 15:23:36 +02:00
|
|
|
cy.get('[data-attr="new-prop-filter-EventPropertyFilters.0"]').click()
|
2021-07-22 20:40:49 +02:00
|
|
|
cy.get('[data-attr=taxonomic-filter-searchfield]').click()
|
2023-03-07 17:56:17 +01:00
|
|
|
cy.get('[data-attr=prop-filter-event_properties-0]').click()
|
|
|
|
cy.get('[data-attr=prop-val] .ant-select-selector').click({ force: true })
|
2023-10-12 01:51:47 +02:00
|
|
|
cy.wait('@getBrowserValues').then(() => {
|
|
|
|
cy.get('[data-attr=prop-val-0]').click()
|
|
|
|
cy.get('.DataTable').should('exist')
|
|
|
|
})
|
2020-05-22 18:34:48 +02:00
|
|
|
})
|
2022-01-13 21:10:39 +01:00
|
|
|
|
2022-08-09 11:30:37 +02:00
|
|
|
it('separates feature flag properties into their own tab', () => {
|
2023-06-29 15:23:36 +02:00
|
|
|
cy.get('[data-attr="new-prop-filter-EventPropertyFilters.0"]').click()
|
2022-08-09 11:30:37 +02:00
|
|
|
cy.get('[data-attr="taxonomic-tab-event_feature_flags"]').should('contain.text', 'Feature flags: 2').click()
|
2022-08-25 13:00:34 +02:00
|
|
|
// some virtualized rows remain in the dom, but hidden
|
|
|
|
cy.get('.taxonomic-list-row:visible').should('have.length', 2)
|
2022-08-09 11:30:37 +02:00
|
|
|
})
|
|
|
|
|
2022-01-25 17:25:20 +01:00
|
|
|
it('use before and after with a DateTime property', () => {
|
2022-03-28 09:13:37 +02:00
|
|
|
selectNewTimestampPropertyFilter()
|
2022-01-13 21:10:39 +01:00
|
|
|
|
2022-09-10 17:40:13 +02:00
|
|
|
cy.get('[data-attr="taxonomic-operator"]').click()
|
2022-03-28 09:13:37 +02:00
|
|
|
cy.get('.operator-value-option').should('contain.text', '> after')
|
|
|
|
cy.get('.operator-value-option').should('contain.text', '< before')
|
2022-01-13 21:10:39 +01:00
|
|
|
})
|
|
|
|
|
2022-01-25 23:34:34 +01:00
|
|
|
it('use less than and greater than with a numeric property', () => {
|
2023-06-29 15:23:36 +02:00
|
|
|
cy.get('[data-attr="new-prop-filter-EventPropertyFilters.0"]').click()
|
2022-01-13 21:10:39 +01:00
|
|
|
cy.get('[data-attr=taxonomic-filter-searchfield]').type('$browser_version')
|
|
|
|
cy.get('.taxonomic-list-row').should('have.length', 1).click()
|
|
|
|
|
2022-09-10 17:40:13 +02:00
|
|
|
cy.get('[data-attr="taxonomic-operator"]').click()
|
|
|
|
cy.get('.operator-value-option').its('length').should('eql', 11) // 10 + 1 for the label in the LemonSelect button
|
2022-06-23 17:05:45 +02:00
|
|
|
cy.get('.operator-value-option').contains('< less than').should('be.visible')
|
2022-01-13 21:10:39 +01:00
|
|
|
cy.get('.operator-value-option').contains('> greater than').should('be.visible')
|
|
|
|
})
|
2022-01-25 23:34:34 +01:00
|
|
|
|
2022-06-16 17:19:31 +02:00
|
|
|
it('adds and removes an additional column', () => {
|
|
|
|
cy.get('[data-attr=events-table-column-selector]').click()
|
|
|
|
cy.get('[data-attr=taxonomic-filter-searchfield]').type('$browser_version')
|
|
|
|
cy.get('.taxonomic-list-row').should('have.length', 1).click()
|
2023-06-29 15:23:36 +02:00
|
|
|
cy.get('.SelectedColumn').should('have.length', 7)
|
2022-06-16 17:19:31 +02:00
|
|
|
cy.get('[data-attr=column-display-item-remove-icon').last().click()
|
2023-06-29 15:23:36 +02:00
|
|
|
cy.get('.SelectedColumn').should('have.length', 6)
|
2022-06-16 17:19:31 +02:00
|
|
|
})
|
|
|
|
|
2022-09-15 10:42:08 +02:00
|
|
|
it('keeps the popop open after selecting an option', () => {
|
2023-06-29 15:23:36 +02:00
|
|
|
cy.get('[data-attr="new-prop-filter-EventPropertyFilters.0"]').click()
|
2022-09-15 10:42:08 +02:00
|
|
|
cy.get('[data-attr=taxonomic-filter-searchfield]').type('$browser_version')
|
|
|
|
cy.get('.taxonomic-list-row').should('have.length', 1).click()
|
|
|
|
|
|
|
|
cy.get('[data-attr="taxonomic-operator"]').click()
|
|
|
|
cy.get('.operator-value-option').contains('> greater than').click()
|
|
|
|
cy.wait(500)
|
|
|
|
cy.get('[data-attr="taxonomic-operator"]').should('be.visible')
|
|
|
|
})
|
|
|
|
|
2022-02-08 14:49:11 +01:00
|
|
|
/**
|
|
|
|
* 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', () => {
|
2022-01-25 23:34:34 +01:00
|
|
|
cy.intercept(/api\/projects\/\d+\/events\/.*/).as('getEvents')
|
|
|
|
|
|
|
|
selectNewTimestampPropertyFilter()
|
|
|
|
|
|
|
|
const oneDayAgo = dayjs().hour(19).minute(1).subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss')
|
2022-02-08 14:49:11 +01:00
|
|
|
selectOperator('< before', undefined)
|
2022-09-10 17:40:13 +02:00
|
|
|
cy.get('[data-attr=taxonomic-value-select]').click()
|
2022-01-25 23:34:34 +01:00
|
|
|
cy.get('.filter-date-picker').type(oneDayAgo)
|
2022-02-08 14:49:11 +01:00
|
|
|
cy.get('.ant-picker-ok').click()
|
|
|
|
cy.get('[data-attr="property-filter-0"]').should('include.text', 'Time < ')
|
2022-01-25 23:34:34 +01:00
|
|
|
|
|
|
|
cy.wait('@getEvents').then(() => {
|
2022-02-08 14:49:11 +01:00
|
|
|
cy.get('tr.event-row:first-child').should('contain.text', 'a day ago')
|
2022-01-25 23:34:34 +01:00
|
|
|
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
|
2022-02-08 14:49:11 +01:00
|
|
|
cy.get('tr.event-row:first-child').should('not.contain.text', 'a day ago')
|
2022-01-25 23:34:34 +01:00
|
|
|
cy.get('tr.event-row').should((rows) => {
|
|
|
|
// test data setup is slightly random so...
|
|
|
|
expect(rows.length).to.be.greaterThan(5)
|
2022-02-08 14:49:11 +01:00
|
|
|
expect(rows.length).to.be.lessThan(10)
|
2022-01-25 23:34:34 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2020-05-22 18:34:48 +02:00
|
|
|
})
|