2022-01-25 23:34:34 +01:00
|
|
|
import { dayjs } from 'lib/dayjs'
|
2022-01-13 21:10:39 +01:00
|
|
|
|
2022-01-25 23:34:34 +01:00
|
|
|
const interceptPropertyDefinitions = () => {
|
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-01-25 17:25:20 +01:00
|
|
|
const selectNewTimestampPropertyFilter = () => {
|
|
|
|
cy.get('[data-attr=new-prop-filter-EventsTable]').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
|
|
|
}
|
|
|
|
|
2022-02-08 14:49:11 +01:00
|
|
|
const selectOperator = (operator, openPopUp) => {
|
2022-01-25 23:34:34 +01:00
|
|
|
if (openPopUp) {
|
|
|
|
cy.get('[data-attr="property-filter-0"] .property-filter .property-filter-button-label').click()
|
|
|
|
}
|
|
|
|
|
|
|
|
cy.get('.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()
|
|
|
|
}
|
|
|
|
|
|
|
|
const changeSecondPropertyFilterToDateAfter = () => {
|
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', () => {
|
2020-08-22 18:03:12 +02:00
|
|
|
cy.get('[data-attr=events-table]').should('exist')
|
2020-05-22 18:34:48 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Click on an event', () => {
|
2021-05-13 23:13:54 +02:00
|
|
|
cy.get('[data-attr=events-table] .event-row: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', () => {
|
|
|
|
cy.get('[data-attr=new-prop-filter-EventsTable]').click()
|
2021-07-22 20:40:49 +02:00
|
|
|
cy.get('[data-attr=taxonomic-filter-searchfield]').click()
|
2022-02-08 14:49:11 +01:00
|
|
|
cy.get('[data-attr=prop-filter-event_properties-0]').click({ force: true })
|
2020-05-22 18:34:48 +02:00
|
|
|
cy.get('[data-attr=prop-val]').click()
|
2020-10-23 15:52:59 +02:00
|
|
|
cy.get('[data-attr=prop-val-0]').click({ force: true })
|
2020-08-22 18:03:12 +02:00
|
|
|
cy.get('[data-attr=events-table]').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', () => {
|
|
|
|
cy.get('[data-attr=new-prop-filter-EventsTable]').click()
|
|
|
|
cy.get('[data-attr="taxonomic-tab-event_feature_flags"]').should('contain.text', 'Feature flags: 2').click()
|
|
|
|
cy.get('.taxonomic-list-row').should('have.length', 2)
|
|
|
|
})
|
|
|
|
|
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-03-28 09:13:37 +02:00
|
|
|
cy.get('.taxonomic-operator').click()
|
|
|
|
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', () => {
|
2022-01-13 21:10:39 +01:00
|
|
|
cy.get('[data-attr=new-prop-filter-EventsTable]').click()
|
|
|
|
cy.get('[data-attr=taxonomic-filter-searchfield]').type('$browser_version')
|
|
|
|
cy.get('.taxonomic-list-row').should('have.length', 1).click()
|
|
|
|
|
|
|
|
cy.get('.taxonomic-operator').click()
|
|
|
|
cy.get('.operator-value-option').its('length').should('eql', 10)
|
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()
|
|
|
|
cy.get('.column-display-item').should('have.length', 5)
|
|
|
|
cy.get('[data-attr=column-display-item-remove-icon').last().click()
|
|
|
|
cy.get('.column-display-item').should('have.length', 4)
|
|
|
|
})
|
|
|
|
|
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-01-25 23:34:34 +01:00
|
|
|
cy.get('.taxonomic-value-select').click()
|
|
|
|
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
|
|
|
})
|