2021-11-25 15:39:49 +01:00
|
|
|
import { urls } from 'scenes/urls'
|
|
|
|
|
2021-04-06 00:46:15 +02:00
|
|
|
// For tests related to trends please check trendsElements.js
|
|
|
|
describe('Insights', () => {
|
|
|
|
beforeEach(() => {
|
2021-11-25 15:39:49 +01:00
|
|
|
cy.visit(urls.insightNew())
|
2021-04-06 00:46:15 +02:00
|
|
|
})
|
|
|
|
|
2021-11-23 10:56:48 +01:00
|
|
|
it('Create new insight and save copy', () => {
|
2022-02-18 19:56:07 +01:00
|
|
|
cy.visit('/saved_insights/') // Should work with trailing slash just like without it
|
2021-11-23 10:56:48 +01:00
|
|
|
cy.get('[data-attr=saved-insights-new-insight-dropdown]').click()
|
|
|
|
cy.get('[data-attr-insight-type="TRENDS"').click()
|
|
|
|
|
|
|
|
// apply filter
|
2022-05-25 04:56:38 +02:00
|
|
|
cy.get('[data-attr=trends-filters-add-filter-group]').click()
|
|
|
|
cy.get('[data-attr=property-select-toggle-0]').click()
|
2021-11-23 10:56:48 +01:00
|
|
|
cy.get('[data-attr=taxonomic-filter-searchfield]').click()
|
2022-03-23 14:30:22 +01:00
|
|
|
cy.get('[data-attr=expand-list-event_properties]').click()
|
2021-11-23 10:56:48 +01:00
|
|
|
cy.get('[data-attr=prop-filter-event_properties-1]').click({ force: true })
|
|
|
|
cy.get('[data-attr=prop-val]').click()
|
|
|
|
cy.get('[data-attr=prop-val-0]').click({ force: true })
|
|
|
|
|
|
|
|
// Save
|
|
|
|
cy.get('[data-attr="insight-save-button"]').click()
|
|
|
|
cy.get('[data-attr="insight-edit-button"]').click()
|
|
|
|
|
2021-12-07 10:58:28 +01:00
|
|
|
// Breadcrumbs work
|
2021-12-14 15:34:01 +01:00
|
|
|
cy.get('[data-attr=breadcrumb-0]').should('contain', 'Hogflix')
|
|
|
|
cy.get('[data-attr=breadcrumb-1]').should('contain', 'Hogflix Demo App')
|
2021-12-07 10:58:28 +01:00
|
|
|
cy.get('[data-attr=breadcrumb-2]').should('have.text', 'Insights')
|
2022-01-13 19:56:08 +01:00
|
|
|
cy.get('[data-attr=breadcrumb-3]').should('not.have.text', '')
|
2021-12-07 10:58:28 +01:00
|
|
|
|
2021-11-23 10:56:48 +01:00
|
|
|
// Save and continue editing
|
|
|
|
cy.get('[data-attr="insight-save-dropdown"]').click()
|
2022-03-22 11:25:10 +01:00
|
|
|
cy.get('[data-attr="add-action-event-button"]').click()
|
|
|
|
cy.get('[data-attr="insight-save-dropdown"]').click()
|
2021-11-23 10:56:48 +01:00
|
|
|
cy.get('[data-attr="insight-save-and-continue"]').click()
|
|
|
|
cy.get('[data-attr="add-action-event-button"]').should('exist')
|
|
|
|
|
|
|
|
// Add another graph series, and save as new insight
|
|
|
|
cy.get('[data-attr="add-action-event-button"]').click()
|
|
|
|
cy.get('[data-attr="insight-save-dropdown"]').click()
|
|
|
|
cy.get('[data-attr="insight-save-as-new-insight"]').click()
|
|
|
|
|
|
|
|
cy.get('.ant-modal .ant-btn-primary').click()
|
2022-03-11 15:06:23 +01:00
|
|
|
cy.get('[data-attr="insight-name"]').should('contain', 'Pageview count (copy)')
|
2021-11-23 10:56:48 +01:00
|
|
|
// Check we're in edit mode
|
|
|
|
cy.get('[data-attr="insight-save-button"]').should('exist')
|
|
|
|
})
|
|
|
|
|
2022-06-07 12:33:08 +02:00
|
|
|
describe('unsaved insights confirmation', () => {
|
|
|
|
it('can move away from an unchanged new insight without confirm()', () => {
|
|
|
|
cy.get('[data-attr="menu-item-insight"]').click()
|
|
|
|
cy.log('Navigate away')
|
|
|
|
cy.get('[data-attr="menu-item-featureflags"]').click()
|
|
|
|
cy.log('We should be on the Feature Flags page now')
|
|
|
|
cy.url().should('include', '/feature_flags')
|
2022-05-27 16:10:05 +02:00
|
|
|
})
|
|
|
|
|
2022-06-07 12:33:08 +02:00
|
|
|
it('Can navigate away from unchanged saved insight without confirm()', () => {
|
|
|
|
cy.get('[data-attr="menu-item-insight"]').click()
|
|
|
|
cy.log('Add series')
|
|
|
|
cy.get('[data-attr=add-action-event-button]').click()
|
|
|
|
cy.log('Save')
|
|
|
|
cy.get('[data-attr="insight-save-button"]').click()
|
|
|
|
cy.wait(200)
|
|
|
|
cy.log('Navigate away')
|
|
|
|
cy.get('[data-attr="menu-item-annotations"]').click()
|
|
|
|
cy.log('We should be on the Annotations page now')
|
|
|
|
cy.url().should('include', '/annotations')
|
|
|
|
})
|
2022-05-27 16:10:05 +02:00
|
|
|
|
2022-06-07 12:33:08 +02:00
|
|
|
it('Can keep editing changed new insight after navigating away with confirm() rejection (case 1)', () => {
|
|
|
|
cy.on('window:confirm', () => {
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.get('[data-attr="menu-item-insight"]').click()
|
|
|
|
cy.log('Add series')
|
|
|
|
cy.get('[data-attr=add-action-event-button]').click()
|
|
|
|
cy.log('Navigate away')
|
|
|
|
cy.get('[data-attr="menu-item-featureflags"]').click()
|
|
|
|
cy.log('Save button should still be here because case 1 rejects confirm()')
|
|
|
|
cy.get('[data-attr="insight-save-button"]').should('exist')
|
|
|
|
})
|
2022-05-27 16:10:05 +02:00
|
|
|
|
2022-06-07 12:33:08 +02:00
|
|
|
it('Can navigate away from changed new insight with confirm() acceptance (case 2)', () => {
|
|
|
|
cy.on('window:confirm', () => {
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
cy.get('[data-attr="menu-item-insight"]').click()
|
|
|
|
cy.log('Add series')
|
|
|
|
cy.get('[data-attr=add-action-event-button]').click()
|
|
|
|
cy.log('Navigate away')
|
|
|
|
cy.get('[data-attr="menu-item-featureflags"]').click()
|
|
|
|
cy.url().should('include', '/feature_flags')
|
|
|
|
})
|
2022-05-27 16:10:05 +02:00
|
|
|
})
|
|
|
|
|
2021-08-02 18:44:44 +02:00
|
|
|
it('Shows not found error with invalid short URL', () => {
|
|
|
|
cy.visit('/i/i_dont_exist')
|
2022-03-11 15:06:23 +01:00
|
|
|
cy.location('pathname').should('eq', '/insights/i_dont_exist')
|
2022-02-02 12:29:59 +01:00
|
|
|
cy.get('.ant-skeleton-title').should('exist')
|
2021-08-02 18:44:44 +02:00
|
|
|
})
|
|
|
|
|
2021-04-06 00:46:15 +02:00
|
|
|
it('Stickiness graph', () => {
|
2021-05-07 04:26:42 +02:00
|
|
|
cy.get('.ant-tabs-tab').contains('Stickiness').click()
|
2021-04-06 00:46:15 +02:00
|
|
|
cy.get('[data-attr=add-action-event-button]').click()
|
|
|
|
cy.get('[data-attr=trend-element-subject-1]').should('exist')
|
|
|
|
cy.get('[data-attr=trend-line-graph]').should('exist')
|
|
|
|
cy.get('[data-attr=add-breakdown-button]').should('not.exist') // Can't do breakdown on this graph
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Lifecycle graph', () => {
|
2021-05-26 14:51:30 +02:00
|
|
|
cy.get('[data-attr=trend-line-graph]').should('exist') // Wait until components are loaded
|
2022-03-31 15:26:15 +02:00
|
|
|
cy.get('.ant-tabs-tab').contains('Lifecycle').click()
|
2021-05-26 14:51:30 +02:00
|
|
|
cy.get('h4').contains('Lifecycle Toggles').should('exist')
|
2021-04-06 00:46:15 +02:00
|
|
|
cy.get('[data-attr=trend-line-graph]').should('exist')
|
|
|
|
cy.get('[data-attr=add-breakdown-button]').should('not.exist') // Can't do breakdown on this graph
|
|
|
|
cy.get('[data-attr=add-action-event-button]').should('not.exist') // Can't add multiple series
|
|
|
|
})
|
2021-04-08 22:40:29 +02:00
|
|
|
|
|
|
|
it('Loads default filters correctly', () => {
|
2022-02-18 19:56:07 +01:00
|
|
|
// Test that default params are set correctly even if the app doesn't start on insights
|
|
|
|
cy.visit('/events/') // Should work with trailing slash just like without it
|
2021-04-08 22:40:29 +02:00
|
|
|
cy.reload()
|
|
|
|
|
2021-11-25 15:39:49 +01:00
|
|
|
cy.clickNavMenu('insight')
|
2021-04-20 21:45:49 +02:00
|
|
|
cy.get('[data-attr=trend-element-subject-0] span').should('contain', 'Pageview')
|
2021-04-08 22:40:29 +02:00
|
|
|
cy.get('[data-attr=trend-line-graph]').should('exist')
|
|
|
|
cy.contains('Add graph series').click()
|
|
|
|
cy.get('[data-attr=trend-element-subject-1]').should('exist')
|
|
|
|
cy.get('[data-attr=trend-line-graph]').should('exist')
|
|
|
|
})
|
2021-08-12 23:55:11 +02:00
|
|
|
|
2022-02-14 15:05:18 +01:00
|
|
|
it('Cannot see tags or description (non-FOSS feature)', () => {
|
2021-08-12 23:55:11 +02:00
|
|
|
cy.get('.insight-description').should('not.exist')
|
|
|
|
cy.get('[data-attr=insight-tags]').should('not.exist')
|
|
|
|
})
|
2021-04-06 00:46:15 +02:00
|
|
|
})
|