diff --git a/cypress/e2e/shared/explorer.queries.graphs.test.ts b/cypress/e2e/shared/explorer.queries.graphs.test.ts index eaa94aafbe..59fcd7bc63 100644 --- a/cypress/e2e/shared/explorer.queries.graphs.test.ts +++ b/cypress/e2e/shared/explorer.queries.graphs.test.ts @@ -1,32 +1,34 @@ import {Organization} from '../../../src/types' +const featureFlags = { + showOldDataExplorerInNewIOx: true, + showTasksInNewIOx: true, + showVariablesInNewIOx: true, + schemaComposition: true, // Double check that the new schemaComposition flag does not interfere. +} + +const DEFAULT_DELAY_MS = 1000 + describe('writing queries and making graphs using Data Explorer', () => { let route: string beforeEach(() => { cy.flush().then(() => cy.signin().then(() => - cy - .setFeatureFlags({ - showOldDataExplorerInNewIOx: true, - showTasksInNewIOx: true, - showVariablesInNewIOx: true, - schemaComposition: true, // Double check that the new schemaComposition flag does not interfere. - }) - .then(() => { - // cy.wait($time) is necessary to consistently ensure sufficient time for the feature flag override. - // The flag reset happens via redux, (it's not a network request), so we can't cy.wait($intercepted_route). - cy.wait(1200) - cy.get('@org').then(({id}: Organization) => { - cy.createMapVariable(id) - cy.fixture('routes').then(({orgs, explorer}) => { - route = `${orgs}/${id}${explorer}` - cy.visit(route) - cy.getByTestID('tree-nav').should('be.visible') - cy.switchToDataExplorer('old') - }) + cy.setFeatureFlags(featureFlags).then(() => { + // cy.wait($time) is necessary to consistently ensure sufficient time for the feature flag override. + // The flag reset happens via redux, (it's not a network request), so we can't cy.wait($intercepted_route). + cy.wait(1200) + cy.get('@org').then(({id}: Organization) => { + cy.createMapVariable(id) + cy.fixture('routes').then(({orgs, explorer}) => { + route = `${orgs}/${id}${explorer}` + cy.visit(route) + cy.getByTestID('tree-nav').should('be.visible') + cy.switchToDataExplorer('old') }) }) + }) ) ) }) @@ -34,84 +36,100 @@ describe('writing queries and making graphs using Data Explorer', () => { describe('numeric input in graphs', () => { describe('numeric input using custom bin sizes in Histograms', () => { beforeEach(() => { - cy.getByTestID('view-type--dropdown').click() - cy.getByTestID(`view-type--histogram`).click() - cy.getByTestID('cog-cell--button').click() + cy.getByTestID('view-type--dropdown').click().wait(DEFAULT_DELAY_MS) + cy.getByTestID(`view-type--histogram`).click().wait(DEFAULT_DELAY_MS) + cy.getByTestID('cog-cell--button').click().wait(DEFAULT_DELAY_MS) }) it('should put input field in error status and stay in error status when input is invalid or empty', () => { - cy.get('.view-options').within(() => { - cy.getByTestID('auto-input').within(() => { - cy.getByTestID('input-field').clear() - cy.getByTestID('auto-input--custom').should( - 'have.class', - 'cf-select-group--option__active' - ) - cy.getByTestID('input-field--error').should('have.length', 1) - cy.getByTestID('input-field').type('adfuiopbvmc') - cy.getByTestID('input-field--error').should('have.length', 1) + cy.get('.view-options') + .first() + .within(() => { + cy.getByTestID('auto-input') + .first() + .within(() => { + cy.getByTestID('input-field').clear() + cy.getByTestID('auto-input--custom').should( + 'have.class', + 'cf-select-group--option__active' + ) + cy.getByTestID('input-field--error').should('have.length', 1) + cy.getByTestID('input-field').type('adfuiopbvmc') + cy.getByTestID('input-field--error').should('have.length', 1) + }) }) - }) }) it('should not have the input field in error status when input becomes valid', () => { - cy.get('.view-options').within(() => { - cy.getByTestID('auto-input').within(() => { - cy.getByTestID('input-field').clear().type('3') - cy.getByTestID('input-field--error').should('have.length', 0) + cy.get('.view-options') + .first() + .within(() => { + cy.getByTestID('auto-input') + .first() + .within(() => { + cy.getByTestID('input-field').clear().type('3') + cy.getByTestID('input-field--error').should('have.length', 0) + }) }) - }) }) }) describe('numeric input validation when changing bin sizes in Heat Maps', () => { beforeEach(() => { - cy.getByTestID('view-type--dropdown').click() - cy.getByTestID(`view-type--heatmap`).click() - cy.getByTestID('cog-cell--button').click() + cy.getByTestID('view-type--dropdown').click().wait(DEFAULT_DELAY_MS) + cy.getByTestID(`view-type--heatmap`).click().wait(DEFAULT_DELAY_MS) + cy.getByTestID('cog-cell--button').click().wait(DEFAULT_DELAY_MS) }) it('should put input field in error status and stay in error status when input is invalid or empty', () => { - cy.get('.view-options').within(() => { - cy.getByTestID('grid--column').within(() => { - cy.getByTestID('bin-size-input') - .clear() - .getByTestID('bin-size-input--error') - .should('have.length', 1) - cy.getByTestID('bin-size-input') - .type('{backspace}') - .getByTestID('bin-size-input--error') - .should('have.length', 1) - cy.getByTestID('bin-size-input') - .type('4') - .getByTestID('bin-size-input--error') - .should('have.length', 1) - cy.getByTestID('bin-size-input') - .type('{backspace}abcdefg') - .getByTestID('bin-size-input--error') - .should('have.length', 1) + cy.get('.view-options') + .first() + .within(() => { + cy.getByTestID('grid--column') + .first() + .within(() => { + cy.getByTestID('bin-size-input') + .clear() + .getByTestID('bin-size-input--error') + .should('have.length', 1) + cy.getByTestID('bin-size-input') + .type('{backspace}') + .getByTestID('bin-size-input--error') + .should('have.length', 1) + cy.getByTestID('bin-size-input') + .type('4') + .getByTestID('bin-size-input--error') + .should('have.length', 1) + cy.getByTestID('bin-size-input') + .type('{backspace}abcdefg') + .getByTestID('bin-size-input--error') + .should('have.length', 1) + }) }) - }) }) it('should not have input field in error status when "10" becomes valid input such as "5"', () => { - cy.get('.view-options').within(() => { - cy.getByTestID('grid--column').within(() => { - cy.getByTestID('bin-size-input') - .clear() - .type('5') - .getByTestID('bin-size-input--error') - .should('have.length', 0) + cy.get('.view-options') + .first() + .within(() => { + cy.getByTestID('grid--column') + .first() + .within(() => { + cy.getByTestID('bin-size-input') + .clear() + .type('5') + .getByTestID('bin-size-input--error') + .should('have.length', 0) + }) }) - }) }) }) describe('numeric input validation when changing number of decimal places in Single Stat', () => { beforeEach(() => { - cy.getByTestID('view-type--dropdown').click() - cy.getByTestID(`view-type--single-stat`).click() - cy.getByTestID('cog-cell--button').click() + cy.getByTestID('view-type--dropdown').click().wait(DEFAULT_DELAY_MS) + cy.getByTestID(`view-type--single-stat`).click().wait(DEFAULT_DELAY_MS) + cy.getByTestID('cog-cell--button').click().wait(DEFAULT_DELAY_MS) }) it('should put input field in error status and stay in error status when input is invalid or empty', () => { @@ -143,24 +161,31 @@ describe('writing queries and making graphs using Data Explorer', () => { }) it('should not have input field in error status when "2" becomes valid input such as "11"', () => { - cy.get('.view-options').within(() => { - cy.getByTestID('auto-input--input').within(() => { - cy.getByTestID('input-field') - .click() - .type('{backspace}11') - .invoke('val') - .should('equal', '11') - .getByTestID('input-field--error') - .should('have.length', 0) + cy.get('.view-options') + .first() + .within(() => { + cy.getByTestID('auto-input--input') + .first() + .within(() => { + cy.getByTestID('input-field') + .click() + .type('{backspace}11') + .invoke('val') + .should('equal', '11') + .getByTestID('input-field--error') + .should('have.length', 0) + }) }) - }) }) }) }) describe('raw script editing', () => { beforeEach(() => { - cy.getByTestID('switch-to-script-editor').should('be.visible').click() + cy.getByTestID('switch-to-script-editor') + .should('be.visible') + .click() + .wait(1000) }) it('shows the proper query button state', () => { @@ -177,13 +202,15 @@ describe('writing queries and making graphs using Data Explorer', () => { }) it('shows the empty state when the query returns no results', () => { - cy.getByTestID('time-machine--bottom').within(() => { - cy.getByTestID('flux-editor').should('be.visible') - .monacoType(`from(bucket: "defbuck") + cy.getByTestID('time-machine--bottom') + .first() + .within(() => { + cy.getByTestID('flux-editor').should('be.visible') + .monacoType(`from(bucket: "defbuck") |> range(start: -10s) |> filter(fn: (r) => r._measurement == "no exist")`) - cy.getByTestID('time-machine-submit-button').click() - }) + cy.getByTestID('time-machine-submit-button').click() + }) cy.getByTestID('empty-graph--no-results').should('exist') }) @@ -303,7 +330,7 @@ describe('writing queries and making graphs using Data Explorer', () => { cy.get('@org').then(({id, name}) => { cy.createBucket(id, name, 'newBucket') }) - cy.reload() + cy.setFeatureFlags(featureFlags) cy.get('@defaultBucketListSelector').then( (defaultBucketListSelector: string) => { cy.getByTestID(defaultBucketListSelector).should('be.visible') diff --git a/cypress/e2e/shared/simpleTable.test.ts b/cypress/e2e/shared/simpleTable.test.ts index 318d7565c6..0c3a041fed 100644 --- a/cypress/e2e/shared/simpleTable.test.ts +++ b/cypress/e2e/shared/simpleTable.test.ts @@ -1,6 +1,10 @@ import {Organization} from '../../../src/types' import {points} from '../../support/commands' +const featureFlags = { + showOldDataExplorerInNewIOx: true, +} + describe('simple table interactions', () => { const simpleSmall = 'simple-small' const simpleLarge = 'simple-large' @@ -8,9 +12,7 @@ describe('simple table interactions', () => { beforeEach(() => { cy.flush() cy.signin() - cy.setFeatureFlags({ - showOldDataExplorerInNewIOx: true, - }).then(() => + cy.setFeatureFlags(featureFlags).then(() => cy.get('@org').then(({id: orgID}: Organization) => { cy.fixture('routes').then(({orgs, explorer}) => { cy.visit(`${orgs}/${orgID}${explorer}`) @@ -23,7 +25,7 @@ describe('simple table interactions', () => { cy.writeData(points(30), simpleSmall) cy.createBucket(orgID, name, simpleOverflow) cy.writeData(points(31), simpleOverflow) - cy.reload() + cy.setFeatureFlags(featureFlags) }) ) }) diff --git a/cypress/e2e/shared/tasks-searching.test.ts b/cypress/e2e/shared/tasks-searching.test.ts index e33c5a4a60..2902c7b326 100644 --- a/cypress/e2e/shared/tasks-searching.test.ts +++ b/cypress/e2e/shared/tasks-searching.test.ts @@ -3,6 +3,8 @@ import {Organization} from '../../../src/types' const isIOxOrg = Boolean(Cypress.env('useIox')) const isTSMOrg = !isIOxOrg +const DEFAULT_DELAY_MS = 1500 + const setupTest = (shouldShowTasks: boolean = true) => { cy.flush() cy.signin() @@ -79,13 +81,13 @@ describe('When tasks already exist', () => { // Add a label cy.getByTestID('task-card').within(() => { - cy.getByTestID('inline-labels--add').click() + cy.getByTestID('inline-labels--add').click().wait(DEFAULT_DELAY_MS) }) const labelName = 'l1' cy.getByTestID('inline-labels--popover--contents').type(labelName) - cy.getByTestID('inline-labels--create-new').click() - cy.getByTestID('create-label-form--submit').click() + cy.getByTestID('inline-labels--create-new').click().wait(DEFAULT_DELAY_MS) + cy.getByTestID('create-label-form--submit').click().wait(DEFAULT_DELAY_MS) // Delete the label cy.getByTestID(`label--pill--delete ${labelName}`).click({force: true}) @@ -114,18 +116,22 @@ describe('When tasks already exist', () => { const firstLabel = 'very important task' const secondLabel = 'mission critical' - cy.get('button.cf-button[title="Add labels"]').click() + cy.get('button.cf-button[title="Add labels"]') + .click() + .wait(DEFAULT_DELAY_MS) cy.getByTestID('inline-labels--popover--dialog').should('be.visible') cy.getByTestID('inline-labels--popover-field').type(`${firstLabel}{enter}`) cy.getByTestID('overlay--container').should('be.visible') - cy.getByTestID('create-label-form--submit').click() + cy.getByTestID('create-label-form--submit').click().wait(DEFAULT_DELAY_MS) cy.getByTestID('overlay--container').should('not.exist') - cy.get('button.cf-button[title="Add labels"]').click() + cy.get('button.cf-button[title="Add labels"]') + .click() + .wait(DEFAULT_DELAY_MS) cy.getByTestID('inline-labels--popover--dialog').should('be.visible') cy.getByTestID('inline-labels--popover-field').type(`${secondLabel}{enter}`) cy.getByTestID('overlay--container').should('be.visible') - cy.getByTestID('create-label-form--submit').click() + cy.getByTestID('create-label-form--submit').click().wait(DEFAULT_DELAY_MS) // ensure the two labels are present before cloning cy.getByTestID('overlay--container').should('not.exist') @@ -133,8 +139,8 @@ describe('When tasks already exist', () => { cy.getByTestID(`label--pill ${secondLabel}`).should('be.visible') // clone the task - cy.getByTestID('context-menu-task').click() - cy.getByTestID('context-clone-task').click() + cy.getByTestID('context-menu-task').click().wait(DEFAULT_DELAY_MS) + cy.getByTestID('context-clone-task').click().wait(DEFAULT_DELAY_MS) cy.getByTestID('task-card--slide-toggle').should('have.length', 2) cy.getByTestID(`label--pill ${firstLabel}`).should('have.length', 2) cy.getByTestID(`label--pill ${secondLabel}`).should('have.length', 2) @@ -143,7 +149,10 @@ describe('When tasks already exist', () => { cy.getByTestID('task-card--slide-toggle') .eq(0) .should('have.class', 'active') - cy.getByTestID('task-card--slide-toggle').eq(0).click() + cy.getByTestID('task-card--slide-toggle') + .eq(0) + .click() + .wait(DEFAULT_DELAY_MS) // only the clone should be active cy.getByTestID('task-card--slide-toggle') @@ -155,7 +164,7 @@ describe('When tasks already exist', () => { // clone a task const cloneNamePrefix = '🦄ask (cloned at ' cy.getByTestID('task-card').then(() => { - cy.getByTestID('context-menu-task').click() + cy.getByTestID('context-menu-task').click().wait(DEFAULT_DELAY_MS) cy.getByTestID('context-clone-task').click().type('{esc}') }) @@ -198,7 +207,7 @@ describe('When tasks already exist', () => { cy.getByTestID('task-form-offset-input').focus().clear().type('10m') cy.getByTestID('task-form-offset-input').should('have.value', '10m') - cy.getByTestID('task-save-btn').click() + cy.getByTestID('task-save-btn').click().wait(DEFAULT_DELAY_MS) // assert changed task name cy.getByTestID('task-card--name').contains('Copy task test') diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 145362a835..8f22230354 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -911,8 +911,14 @@ export const clearSqlScriptSession = () => { } export const selectScriptBucket = (bucketName: string) => { - cy.getByTestID('bucket-selector--dropdown-button').click() - cy.getByTestID(`bucket-selector--dropdown--${bucketName}`).click() + const MENU_WAIT_DELAY_MS = 1000 + + cy.getByTestID('bucket-selector--dropdown-button') + .click() + .wait(MENU_WAIT_DELAY_MS) + cy.getByTestID(`bucket-selector--dropdown--${bucketName}`) + .click() + .wait(MENU_WAIT_DELAY_MS) cy.getByTestID('bucket-selector--dropdown-button').should( 'contain', bucketName @@ -1510,7 +1516,7 @@ export const setFeatureFlagsNoNav = (flags: FlagMap): Cypress.Chainable => { }).as('setFeatureFlagsResponse') }) - return cy.wait(0) + return cy.wait(1000) } export const createTaskFromEmpty = (