0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00
posthog/cypress/e2e/insights-date-picker.ts
Paul D'Ambra 5da50e633a
fix: throw error so test failures are not swallowed (#17926)
So obvious in retrospect

If you listen to the Cypress fail event without re-throwing then you swallow all test failures

"fun"

When reviewing #17919 I knew the Cypress tests would have to be failing which is what prompted me to check

Introduced in bbb7ed9 (July 10th!)
2023-10-12 00:51:47 +01:00

35 lines
1.4 KiB
TypeScript

import { decideResponse } from '../fixtures/api/decide'
import { urls } from 'scenes/urls'
describe('insights date picker', () => {
beforeEach(() => {
cy.intercept('https://app.posthog.com/decide/*', (req) =>
req.reply(
decideResponse({
hogql: true,
'data-exploration-insights': true,
})
)
)
cy.visit(urls.insightNew())
})
it('Can set the date filter and show the right grouping interval', () => {
cy.get('[data-attr=date-filter]').click()
cy.get('div').contains('Yesterday').should('exist').click()
cy.get('[data-attr=interval-filter] .LemonButton__content').should('contain', 'hour')
})
it('Can set a custom rolling date range', () => {
cy.get('[data-attr=date-filter]').click()
cy.get('[data-attr=rolling-date-range-input]').type('{selectall}5{enter}')
cy.get('[data-attr=rolling-date-range-date-options-selector]').click()
cy.get('.RollingDateRangeFilter__popover > div').contains('days').should('exist').click()
cy.get('.RollingDateRangeFilter__label').should('contain', 'In the last').click()
// Test that the button shows the correct formatted range
cy.get('[data-attr=date-filter]').get('.LemonButton__content').contains('Last 5 days').should('exist')
})
})