Skip to content

Commit

Permalink
chore: longer timeout on insight and dashboard cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Dec 26, 2024
1 parent 34a4f6b commit 5ba0e6a
Show file tree
Hide file tree
Showing 13 changed files with 1,035 additions and 913 deletions.
93 changes: 51 additions & 42 deletions cypress/e2e/dashboard-deletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,69 @@ import { urls } from 'scenes/urls'
import { dashboard, dashboards, insight, savedInsights } from '../productAnalytics'
import { randomString } from '../support/random'

describe('deleting dashboards', () => {
it('can delete dashboard without deleting the insights', () => {
cy.visit(urls.savedInsights()) // get insights list into turbo mode
cy.clickNavMenu('dashboards')
// cypress does have three args, but jest/valid-describe-callback doesn't know

const dashboardName = randomString('dashboard-')
const insightName = randomString('insight-')
describe(
'deleting dashboards',
{
// default is 4000
defaultCommandTimeout: 12000,
},
() => {
it('can delete dashboard without deleting the insights', () => {
cy.visit(urls.savedInsights()) // get insights list into turbo mode
cy.clickNavMenu('dashboards')

dashboards.createAndGoToEmptyDashboard(dashboardName)
dashboard.addInsightToEmptyDashboard(insightName)
const dashboardName = randomString('dashboard-')
const insightName = randomString('insight-')

cy.get('[data-attr="dashboard-three-dots-options-menu"]').click()
cy.get('button').contains('Delete dashboard').click()
cy.get('[data-attr="dashboard-delete-submit"]').click()
dashboards.createAndGoToEmptyDashboard(dashboardName)
dashboard.addInsightToEmptyDashboard(insightName)

savedInsights.checkInsightIsInListView(insightName)
})
cy.get('[data-attr="dashboard-three-dots-options-menu"]').click()
cy.get('button').contains('Delete dashboard').click()
cy.get('[data-attr="dashboard-delete-submit"]').click()

// TODO: this test works locally, just not in CI
it.skip('can delete dashboard and delete the insights', () => {
cy.visit(urls.savedInsights()) // get insights list into turbo mode
cy.clickNavMenu('dashboards')
savedInsights.checkInsightIsInListView(insightName)
})

const dashboardName = randomString('dashboard-')
const dashboardToKeepName = randomString('dashboard-to-keep')
const insightName = randomString('insight-')
const insightToKeepName = randomString('insight-to-keep-')
// TODO: this test works locally, just not in CI
it.skip('can delete dashboard and delete the insights', () => {
cy.visit(urls.savedInsights()) // get insights list into turbo mode
cy.clickNavMenu('dashboards')

dashboards.createAndGoToEmptyDashboard(dashboardName)
dashboard.addInsightToEmptyDashboard(insightName)
const dashboardName = randomString('dashboard-')
const dashboardToKeepName = randomString('dashboard-to-keep')
const insightName = randomString('insight-')
const insightToKeepName = randomString('insight-to-keep-')

cy.clickNavMenu('dashboards')
dashboards.createAndGoToEmptyDashboard(dashboardName)
dashboard.addInsightToEmptyDashboard(insightName)

dashboards.createAndGoToEmptyDashboard(dashboardToKeepName)
dashboard.addInsightToEmptyDashboard(insightToKeepName)
cy.clickNavMenu('dashboards')

cy.visit(urls.savedInsights())
cy.wait('@loadInsightList').then(() => {
cy.get('.saved-insights tr a').should('be.visible')
dashboards.createAndGoToEmptyDashboard(dashboardToKeepName)
dashboard.addInsightToEmptyDashboard(insightToKeepName)

// load the named insight
cy.contains('.saved-insights tr', insightToKeepName).within(() => {
cy.get('.Link').click()
})
cy.visit(urls.savedInsights())
cy.wait('@loadInsightList').then(() => {
cy.get('.saved-insights tr a').should('be.visible')

insight.addInsightToDashboard(dashboardName, { visitAfterAdding: true })
// load the named insight
cy.contains('.saved-insights tr', insightToKeepName).within(() => {
cy.get('.Link').click()
})

cy.get('[data-attr="dashboard-three-dots-options-menu"]').click()
cy.get('button').contains('Delete dashboard').click()
cy.contains('span.LemonCheckbox', "Delete this dashboard's insights").click()
cy.get('[data-attr="dashboard-delete-submit"]').click()
insight.addInsightToDashboard(dashboardName, { visitAfterAdding: true })

savedInsights.checkInsightIsInListView(insightToKeepName)
savedInsights.checkInsightIsNotInListView(insightName)
cy.get('[data-attr="dashboard-three-dots-options-menu"]').click()
cy.get('button').contains('Delete dashboard').click()
cy.contains('span.LemonCheckbox', "Delete this dashboard's insights").click()
cy.get('[data-attr="dashboard-delete-submit"]').click()

savedInsights.checkInsightIsInListView(insightToKeepName)
savedInsights.checkInsightIsNotInListView(insightName)
})
})
})
})
}
)
193 changes: 101 additions & 92 deletions cypress/e2e/dashboard-duplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,111 +3,120 @@ import { urls } from 'scenes/urls'
import { dashboard, dashboards, duplicateDashboardFromMenu, savedInsights } from '../productAnalytics'
import { randomString } from '../support/random'

describe('duplicating dashboards', () => {
let dashboardName, insightName, expectedCopiedDashboardName, expectedCopiedInsightName
// cypress does have three args, but jest/valid-describe-callback doesn't know

beforeEach(() => {
cy.intercept('POST', /\/api\/environments\/\d+\/dashboards/).as('createDashboard')
describe(
'duplicating dashboards',
{
// default is 4000
defaultCommandTimeout: 12000,
},
() => {
let dashboardName, insightName, expectedCopiedDashboardName, expectedCopiedInsightName

dashboardName = randomString('dashboard-')
expectedCopiedDashboardName = `${dashboardName} (Copy)`
beforeEach(() => {
cy.intercept('POST', /\/api\/environments\/\d+\/dashboards/).as('createDashboard')

insightName = randomString('insight-')
expectedCopiedInsightName = `${insightName} (Copy)`
dashboardName = randomString('dashboard-')
expectedCopiedDashboardName = `${dashboardName} (Copy)`

cy.visit(urls.savedInsights()) // get insights list into turbo mode
cy.clickNavMenu('dashboards')
insightName = randomString('insight-')
expectedCopiedInsightName = `${insightName} (Copy)`

dashboards.createAndGoToEmptyDashboard(dashboardName)
dashboard.addInsightToEmptyDashboard(insightName)

cy.contains('h4', insightName).click() // get insight into turbo mode
})

describe('from the dashboard list', () => {
it('can duplicate a dashboard without duplicating insights', () => {
cy.visit(urls.savedInsights()) // get insights list into turbo mode
cy.clickNavMenu('dashboards')
cy.get('[placeholder="Search for dashboards"]').type(dashboardName)

cy.contains('[data-attr="dashboards-table"] tr', dashboardName).within(() => {
cy.get('[data-attr="more-button"]').click()
})
duplicateDashboardFromMenu()
cy.get('[data-attr="top-bar-name"] .EditableField__display').should(
'have.text',
expectedCopiedDashboardName
)

cy.wait('@createDashboard').then(() => {
cy.get('.CardMeta h4').should('have.text', insightName).should('not.have.text', '(Copy)')
cy.contains('h4', insightName).click()
// this works when actually using the site, but not in Cypress
// cy.get('[data-attr="save-to-dashboard-button"] .LemonBadge').should('have.text', '2')
})
})
dashboards.createAndGoToEmptyDashboard(dashboardName)
dashboard.addInsightToEmptyDashboard(insightName)

it('can duplicate a dashboard and duplicate insights', () => {
cy.clickNavMenu('dashboards')
cy.get('[placeholder="Search for dashboards"]').type(dashboardName)
cy.contains('h4', insightName).click() // get insight into turbo mode
})

cy.contains('[data-attr="dashboards-table"] tr', dashboardName).within(() => {
cy.get('[data-attr="more-button"]').click()
})
duplicateDashboardFromMenu(true)
cy.get('[data-attr="top-bar-name"] .EditableField__display').should(
'have.text',
expectedCopiedDashboardName
)

cy.wait('@createDashboard').then(() => {
cy.contains('h4', expectedCopiedInsightName).click()
cy.get('[data-attr="save-to-dashboard-button"] .LemonBadge').should('have.text', '1')
describe('from the dashboard list', () => {
it('can duplicate a dashboard without duplicating insights', () => {
cy.clickNavMenu('dashboards')
cy.get('[placeholder="Search for dashboards"]').type(dashboardName)

cy.contains('[data-attr="dashboards-table"] tr', dashboardName).within(() => {
cy.get('[data-attr="more-button"]').click()
})
duplicateDashboardFromMenu()
cy.get('[data-attr="top-bar-name"] .EditableField__display').should(
'have.text',
expectedCopiedDashboardName
)

cy.wait('@createDashboard').then(() => {
cy.get('.CardMeta h4').should('have.text', insightName).should('not.have.text', '(Copy)')
cy.contains('h4', insightName).click()
// this works when actually using the site, but not in Cypress
// cy.get('[data-attr="save-to-dashboard-button"] .LemonBadge').should('have.text', '2')
})
})

savedInsights.checkInsightIsInListView(insightName)
savedInsights.checkInsightIsInListView(expectedCopiedInsightName)
it('can duplicate a dashboard and duplicate insights', () => {
cy.clickNavMenu('dashboards')
cy.get('[placeholder="Search for dashboards"]').type(dashboardName)

cy.contains('[data-attr="dashboards-table"] tr', dashboardName).within(() => {
cy.get('[data-attr="more-button"]').click()
})
duplicateDashboardFromMenu(true)
cy.get('[data-attr="top-bar-name"] .EditableField__display').should(
'have.text',
expectedCopiedDashboardName
)

cy.wait('@createDashboard').then(() => {
cy.contains('h4', expectedCopiedInsightName).click()
cy.get('[data-attr="save-to-dashboard-button"] .LemonBadge').should('have.text', '1')
})

savedInsights.checkInsightIsInListView(insightName)
savedInsights.checkInsightIsInListView(expectedCopiedInsightName)
})
})
})

describe('from the dashboard', () => {
it('can duplicate a dashboard without duplicating insights', () => {
cy.clickNavMenu('dashboards')
dashboards.visitDashboard(dashboardName)

cy.get('[data-attr="dashboard-three-dots-options-menu"]').click()
duplicateDashboardFromMenu()
cy.get('[data-attr="top-bar-name"] .EditableField__display').should(
'have.text',
expectedCopiedDashboardName
)

cy.wait('@createDashboard').then(() => {
cy.get('.CardMeta h4').should('have.text', insightName).should('not.have.text', '(Copy)')
cy.contains('h4', insightName).click()
// this works when actually using the site, but not in Cypress
// cy.get('[data-attr="save-to-dashboard-button"] .LemonBadge').should('have.text', '2')
describe('from the dashboard', () => {
it('can duplicate a dashboard without duplicating insights', () => {
cy.clickNavMenu('dashboards')
dashboards.visitDashboard(dashboardName)

cy.get('[data-attr="dashboard-three-dots-options-menu"]').click()
duplicateDashboardFromMenu()
cy.get('[data-attr="top-bar-name"] .EditableField__display').should(
'have.text',
expectedCopiedDashboardName
)

cy.wait('@createDashboard').then(() => {
cy.get('.CardMeta h4').should('have.text', insightName).should('not.have.text', '(Copy)')
cy.contains('h4', insightName).click()
// this works when actually using the site, but not in Cypress
// cy.get('[data-attr="save-to-dashboard-button"] .LemonBadge').should('have.text', '2')
})
savedInsights.checkInsightIsInListView(insightName)
savedInsights.checkInsightIsNotInListView(expectedCopiedInsightName)
})
savedInsights.checkInsightIsInListView(insightName)
savedInsights.checkInsightIsNotInListView(expectedCopiedInsightName)
})
it('can duplicate a dashboard and duplicate insights', () => {
cy.clickNavMenu('dashboards')
dashboards.visitDashboard(dashboardName)

cy.get('[data-attr="dashboard-three-dots-options-menu"]').click()
duplicateDashboardFromMenu(true)
cy.get('[data-attr="top-bar-name"] .EditableField__display').should(
'have.text',
expectedCopiedDashboardName
)

cy.wait('@createDashboard').then(() => {
cy.contains('h4', expectedCopiedInsightName).click()
cy.get('[data-attr="save-to-dashboard-button"] .LemonBadge').should('have.text', '1')
it('can duplicate a dashboard and duplicate insights', () => {
cy.clickNavMenu('dashboards')
dashboards.visitDashboard(dashboardName)

cy.get('[data-attr="dashboard-three-dots-options-menu"]').click()
duplicateDashboardFromMenu(true)
cy.get('[data-attr="top-bar-name"] .EditableField__display').should(
'have.text',
expectedCopiedDashboardName
)

cy.wait('@createDashboard').then(() => {
cy.contains('h4', expectedCopiedInsightName).click()
cy.get('[data-attr="save-to-dashboard-button"] .LemonBadge').should('have.text', '1')
})

savedInsights.checkInsightIsInListView(insightName)
savedInsights.checkInsightIsInListView(expectedCopiedInsightName)
})

savedInsights.checkInsightIsInListView(insightName)
savedInsights.checkInsightIsInListView(expectedCopiedInsightName)
})
})
})
}
)
Loading

0 comments on commit 5ba0e6a

Please sign in to comment.