0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 00:46:45 +01:00
posthog/cypress/e2e/insights-navigation.cy.ts

84 lines
3.1 KiB
TypeScript
Raw Normal View History

import { urls } from 'scenes/urls'
import { insight } from '../productAnalytics'
import { randomString } from '../support/random'
const hogQLQuery = `select event,
count()
from events
group by event,
properties.$browser,
person.properties.email
order by count() desc
limit 2`
// For tests related to trends please check trendsElements.js
describe('Insights', () => {
beforeEach(() => {
cy.visit(urls.insightNew())
})
describe('navigation', () => {
it('can save and load and edit a SQL insight', () => {
insight.newInsight('SQL')
const insightName = randomString('SQL insight')
insight.editName(insightName)
insight.save()
cy.visit(urls.savedInsights())
cy.contains('.Link', insightName).click()
cy.get('[data-attr="hogql-query-editor"]').should('not.exist')
cy.get('tr.DataVizRow').should('have.length.gte', 2)
cy.get('[data-attr="insight-edit-button"]').click()
insight.clickTab('RETENTION')
cy.get('[data-attr="insight-save-button"]').click()
cy.get('.RetentionContainer canvas').should('exist')
cy.get('.RetentionTable__Tab').should('have.length', 66)
})
it('can open a new SQL insight and navigate to a different one, then back to SQL, and back again', () => {
/**
* This is here as a regression test. We had a bug where navigating to a new query based insight,
* then clicking on the trends tab, then on SQL, and again on trends would mean that the trends
* tab would be selected, but no data loaded for it 🤷
*/
insight.newInsight('SQL')
cy.get('[data-attr="hogql-query-editor"]').should('exist')
insight.updateQueryEditorText(hogQLQuery, 'hogql-query-editor')
cy.get('.DataVizRow').should('have.length.gte', 2)
insight.clickTab('TRENDS')
cy.get('.TrendsInsight canvas').should('exist')
cy.get('tr').should('have.length.gte', 2)
cy.contains('tr', 'No insight results').should('not.exist')
insight.clickTab('SQL')
cy.get('[data-attr="hogql-query-editor"]').should('exist')
insight.updateQueryEditorText(hogQLQuery, 'hogql-query-editor')
cy.get('.DataVizRow').should('have.length.gte', 2)
insight.clickTab('TRENDS')
cy.get('.TrendsInsight canvas').should('exist')
cy.get('tr').should('have.length.gte', 2)
cy.contains('tr', 'No insight results').should('not.exist')
})
it('can open event explorer as an insight', () => {
feat: live events feed (#22302) * initial commit * initial commit * fix up some types * Add team id * add client side filters * check live events in onboarding * add eventsource * clean up live table logic * add event source module * Delete eventsManagementDescribers.tsx * update event source usage * Update liveEventsTableLogic.ts * Update UI snapshots for `chromium` (2) * add team live events token * Delete liveEventsTableLogic.ts * Update types.ts * switch to use window event source * improvements / feature flags * cleanup * update the live event host * Update UI snapshots for `chromium` (2) * remove event source lib * fix up event source types * Clean up live events view * Delete eventsManagement.ts * Update SDKs.tsx * improve live event typing * add better loading for the table * update the live events table columns * add last batch timestamp check * add toast for error * rename events management to activity * Hookup proper team id * Update start * Fix types * Update some tests * Put SDKs back with no live event changes * Update verifiedDomainsLogic.test.ts.snap * Update verifiedDomainsLogic.test.ts.snap * Update UI snapshots for `chromium` (2) * Update query snapshots * Update query snapshots * Update UI snapshots for `chromium` (2) * Update UI snapshots for `chromium` (2) * Update query snapshots * Update UI snapshots for `chromium` (2) * Update query snapshots * Update UI snapshots for `chromium` (2) * Update query snapshots * Update UI snapshots for `chromium` (2) * Use `preserveParams()` in redirect from old URL * Clean up UI and refactor tabs * Update E2E tests * Update UI snapshots for `chromium` (2) * Don't hide "Reload" when live events available * Remove unused import * Update UI snapshots for `chromium` (2) * Improve local batching reliability * Make console error clearer * Clarify directory structure * Update UI snapshots for `chromium` (2) * Jot down source of `EventSource` type * Remove unused scene code * Update UI snapshots for `chromium` (2) * Update UI snapshots for `chromium` (2) * Update a11.cy.ts * Update UI snapshots for `chromium` (2) * Update UI snapshots for `chromium` (2) * Update UI snapshots for `chromium` (2) * Remove any effects for users with flag off * Update UI snapshots for `chromium` (1) * Update UI snapshots for `chromium` (1) * Update UI snapshots for `chromium` (2) --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Michael Matloka <michal@matloka.com> Co-authored-by: Michael Matloka <dev@twixes.com>
2024-06-04 13:33:42 +02:00
cy.clickNavMenu('activity')
cy.get('[data-attr="open-json-editor-button"]').click()
cy.get('[data-attr="insight-json-tab"]').should('exist')
})
it('does not show the json tab usually', () => {
cy.clickNavMenu('savedinsights')
cy.get('[data-attr="insight-json-tab"]').should('not.exist')
})
})
})