0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 09:16:49 +01:00
posthog/cypress/e2e/dashboard-shared.cy.ts
Paul D'Ambra 597144ddf3
chore(ci): switch some workflows entirely to depot (#21187)
* chore(ci): switch some workflows entirely to depot

* yolo
2024-03-28 09:16:14 +00:00

69 lines
2.5 KiB
TypeScript

import { dashboards } from '../productAnalytics'
describe('Shared dashboard', () => {
beforeEach(() => {
cy.intercept('GET', /api\/projects\/\d+\/insights\/\?.*/).as('loadInsightList')
cy.intercept('PATCH', /api\/projects\/\d+\/insights\/\d+\/.*/).as('patchInsight')
cy.intercept('POST', /\/api\/projects\/\d+\/dashboards/).as('createDashboard')
cy.useSubscriptionStatus('unsubscribed')
cy.clickNavMenu('dashboards')
})
it('Dashboard sharing can be enabled', () => {
dashboards.createDashboardFromDefaultTemplate('to be shared')
cy.get('.InsightCard').should('exist')
cy.get('[data-attr=dashboard-share-button]').click()
cy.get('[data-attr=sharing-switch]').click({ force: true })
cy.contains('Embed dashboard').should('be.visible')
cy.get('[data-attr=copy-code-button]').click()
cy.window()
.its('navigator.clipboard')
.then((c) => c.readText())
.should('contain', '<iframe')
cy.window()
.its('navigator.clipboard')
.then((c) => c.readText())
.should('contain', '/embedded/')
cy.contains('Copy public link').should('be.visible')
cy.get('[data-attr=sharing-link-button]').click()
cy.window()
.its('navigator.clipboard')
.then((c) => c.readText())
.should('contain', '/shared/')
})
it('Insights load when cache is empty', () => {
cy.get('h1').should('contain', 'Dashboards')
dashboards.createDashboardFromDefaultTemplate('Foobar 3001')
cy.get('[data-attr=dashboard-share-button]').click()
cy.get('[data-attr=sharing-switch]').click({ force: true })
cy.contains('Copy public link').should('be.visible')
cy.get('[data-attr=sharing-link-button]').click()
cy.window()
.its('navigator.clipboard')
.then((clipboard) => {
cy.wrap(clipboard.readText()).as('clipboardText')
})
cy.task('resetInsightCache')
cy.window().then(async (win) => {
const text = await win.navigator.clipboard.readText()
cy.visit(text)
})
cy.get('.InsightCard').should('have.length', 6)
// Make sure no element with text "There are no matching events for this query" exists
// TODO this was failing, it shouldn't be but YOLO
// cy.get('.insight-empty-state').should('not.exist')
})
})