0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-30 19:41:46 +01:00
posthog/cypress/integration/dashboard.js

125 lines
5.5 KiB
JavaScript
Raw Normal View History

describe('Dashboard', () => {
beforeEach(() => {
cy.get('[data-attr=menu-item-dashboards]').click().click()
cy.location('pathname').should('include', '/dashboard')
})
it('Dashboards loaded', () => {
cy.get('h1').should('contain', 'Dashboards')
})
it('Cannot see tags or description (non-FOSS feature)', () => {
cy.get('h1').should('contain', 'Dashboards')
cy.get('th.ant-table-cell').contains('Description').should('not.exist')
cy.get('th.ant-table-cell').contains('Tags').should('not.exist')
cy.get('[data-attr=dashboard-name]').contains('My App Dashboard').click()
cy.get('[data-attr=dashboard-item-0]').should('exist')
cy.get('.dashboard-description').should('not.exist')
cy.get('[data-attr=dashboard-tags]').should('not.exist')
})
it('Pinned dashboards on menu', () => {
cy.get('[data-attr=menu-item-events]').click() // to make sure the dashboards menu item is not the active one
cy.get('[data-attr=menu-item-dashboards]').trigger('mouseover') // hover over dashboards menu item
cy.get('.pinned-dashboards').should('be.visible')
cy.get('[data-attr=menu-item-dashboard-0]').should('be.visible')
})
it('Share dashboard', () => {
2021-03-03 16:17:43 +01:00
cy.get('[data-attr=dashboard-name]').contains('My App Dashboard').click()
cy.get('[data-attr=dashboard-item-0]').should('exist')
cy.get('[data-attr=dashboard-share-button]').click()
cy.get('[data-attr=share-dashboard-switch]').click()
cy.get('[data-attr=share-dashboard-link]')
.invoke('val')
.then((link) => {
cy.wait(200)
cy.visit(link)
wip: support test_ api key (#4206) * wip: support test_ api key * Renamed test_environment property to * Added Prod/Test switch to determine which environment to show data for * moved environment toggle behind feature flag * corrected key name to standard $ names * Moved hidden filters to PropertyKeyInfo for improved clarity * fix typing * proposed UI * Renamed to ; Changed to a string and added environment const types: production, test; Moved into a hidden filter along with environment types for the frontend; Corrected tests to use environment constants; is no longer set by default but only when test_ is supplied in the apiKey or is manually supplied; Moved environment to navigationLogic; * Added filter for test environments so that when it's enabled all test environments are filtered out * Remove component if feature flag for test-environment is enabled * adjust style of tooltip * adjust UI based on @corywatilo's input * implemented toggle functionality * Made Environments an enum for clarity * Moved environment constants to constants.py for consistency * Moved Environments into constants for consistency * Using parameter destructuring for better syntax * Make sure type is set as a string * Removed test filters * Created _clean_token to ensure test_ is removed from all the places * Bug fixes for adding filter property so that it work properly * Show test account filter * ensure token isn't None so that mypy checks pass * Corrected css selector syntax * removed quote since it's not needed * Corrected cypress test by excluding featureFlag usage on shared dashboard scene * Fixed test * corrected syntax style issues Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com> Co-authored-by: Buddy Williams <buddy@Buddys-MacBook-Pro.local>
2021-05-21 17:34:07 +02:00
cy.get('[data-attr=dashboard-item-title]').should('contain', 'Daily Active Users')
})
})
it('Create an empty dashboard', () => {
cy.get('[data-attr="new-dashboard"]').click()
cy.get('[data-attr=dashboard-name-input]').clear().type('New Dashboard')
cy.get('button').contains('Create').click()
cy.contains('New Dashboard').should('exist')
cy.get('.empty-state').should('exist')
})
it('Create dashboard from a template', () => {
cy.get('[data-attr="new-dashboard"]').click()
cy.get('[data-attr=dashboard-name-input]').clear().type('XDefault')
cy.get('[data-attr=copy-from-template]').click()
cy.get('[data-attr=dashboard-select-default-app]').click()
cy.get('button').contains('Create').click()
cy.contains('XDefault').should('exist')
cy.get('.dashboard-item').its('length').should('be.gte', 2)
})
it('Click on a dashboard item dropdown and view graph', () => {
cy.get('[data-attr=dashboard-name]').contains('Web Analytics').click()
cy.get('[data-attr=dashboard-item-0-dropdown]').click()
cy.get('[data-attr=dashboard-item-0-dropdown-view]').click()
cy.location('pathname').should('include', '/insights')
})
it('Rename dashboard item', () => {
cy.get('[data-attr=dashboard-name]').contains('Web Analytics').click()
cy.get('[data-attr=dashboard-item-0-dropdown]').click()
cy.get('[data-attr="dashboard-item-0-dropdown-rename"]').click({ force: true })
cy.get('[data-attr=modal-prompt]').clear().type('Test Name')
cy.contains('OK').click()
cy.contains('Test Name').should('exist')
})
it('Color dashboard item', () => {
cy.get('[data-attr=dashboard-name]').contains('Web Analytics').click()
cy.get('[data-attr=dashboard-item-0-dropdown]').click()
cy.get('[data-attr="dashboard-item-0-dropdown-color"]').trigger('mouseover')
cy.get('[data-attr="dashboard-item-0-dropdown-color-1"]').click({ force: true })
cy.get('[data-attr="dashboard-item-0"]').should(
'have.css',
'background',
'rgb(38, 98, 166) none repeat scroll 0% 0% / auto padding-box border-box'
) //hard coded to the blue that's set
})
it('Copy dashboard item', () => {
cy.get('[data-attr=dashboard-name]').contains('Web Analytics').click()
cy.get('[data-attr=dashboard-item-0-dropdown]').click()
cy.get('[data-attr="dashboard-item-0-dropdown-copy"]').trigger('mouseover')
cy.get('[data-attr="dashboard-item-0-dropdown-copy-0"]').click({ force: true })
cy.get('[data-attr=success-toast]').should('exist')
})
it('Duplicate dashboard item', () => {
cy.get('[data-attr=dashboard-name]').contains('Web Analytics').click()
cy.get('[data-attr=dashboard-item-0-dropdown]').click()
cy.get('[data-attr="dashboard-item-0-dropdown-duplicate"]').click({ force: true })
cy.get('[data-attr=success-toast]').should('exist')
})
it('Move dashboard item', () => {
cy.get('[data-attr=dashboard-name]').contains('Web Analytics').click()
cy.get('[data-attr=dashboard-item-0-dropdown]').click()
cy.get('[data-attr="dashboard-item-0-dropdown-move"]').trigger('mouseover')
cy.get('[data-attr="dashboard-item-0-dropdown-move-0"]').click({ force: true })
cy.get('[data-attr=success-toast]').should('exist')
})
it('Opens dashboard item in insights', () => {
cy.get('[data-attr=dashboard-name]').contains('My App Dashboard').click()
cy.get('[data-attr=dashboard-item-0] .dashboard-item-title a').click()
cy.location('pathname').should('include', '/insights')
cy.get('[data-attr=math-selector-0]').contains('Unique users').should('exist')
cy.get('[data-attr=trend-line-graph]').should('exist')
})
})