Skip to content

Commit

Permalink
feat(autoAgg): Add cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ebb-tide committed Jul 28, 2020
1 parent 0904f64 commit 3fcd8e7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
38 changes: 38 additions & 0 deletions ui/cypress/e2e/queryBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,44 @@ describe('The Query Builder', () => {
cy.contains('Basic Ole Dashboard').should('exist')
})

it('when it creates a query, the query has an aggregate window, clicking around aggregate window selections work', () => {
cy.get('@org').then((org: Organization) => {
cy.visit(`orgs/${org.id}/data-explorer`)
})

cy.contains('mem').click('right') // users sometimes click in random spots
cy.contains('active').click('bottomLeft')

cy.getByTestID('empty-graph--no-queries').should('exist')

cy.contains('Submit').click()

cy.get('.giraffe-plot').should('exist')

cy.getByTestID('switch-to-script-editor').click()

cy.contains(
'|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: true)'
).should('exist')

cy.getByTestID('switch-to-query-builder').click()
cy.getByTestID('custom-window-period').click()

cy.getByTestID('custom-window-period').click()
cy.getByTestID('duration-input--error').should('not.exist')
cy.getByTestID('duration-input').type('not a duration')
cy.getByTestID('duration-input--error').should('exist')

cy.getByTestID('auto-window-period').click()

cy.getByTestID('duration-input--error').should('not.exist')
cy.getByTestID('toggle').click()
cy.getByTestID('switch-to-script-editor').click()
cy.contains(
'|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)'
).should('exist')
})

it('can create a bucket from the buckets list', () => {
cy.get('@org').then((org: Organization) => {
cy.visit(`orgs/${org.id}/data-explorer`)
Expand Down
10 changes: 7 additions & 3 deletions ui/src/timeMachine/components/WindowPeriod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ComponentStatus,
ComponentSize,
} from '@influxdata/clockface'
import DurationInput from 'src/shared/components/DurationInput'

// Actions
import {
Expand All @@ -24,12 +25,13 @@ import {
} from 'src/timeMachine/selectors'

// Constants
import {DURATIONS} from 'src/timeMachine/constants/queryBuilder'
import {
DURATIONS,
AGG_WINDOW_AUTO,
} from 'src/timeMachine/constants/queryBuilder'

// Types
import {AppState} from 'src/types'
import DurationInput from 'src/shared/components/DurationInput'
import {AGG_WINDOW_AUTO} from '../constants/queryBuilder'

type ReduxProps = ConnectedProps<typeof connector>
type Props = ReduxProps
Expand Down Expand Up @@ -76,6 +78,7 @@ const WindowPeriod: FunctionComponent<Props> = ({
<SelectGroup.Option
name="custom"
id="custom-window-period"
testID="custom-window-period"
active={!isAutoWindowPeriod}
value="custom"
onClick={onSetWindowPeriodSelectionMode}
Expand All @@ -86,6 +89,7 @@ const WindowPeriod: FunctionComponent<Props> = ({
<SelectGroup.Option
name="auto"
id="auto-window-period"
testID="auto-window-period"
active={isAutoWindowPeriod}
value="auto"
onClick={onSetWindowPeriodSelectionMode}
Expand Down

0 comments on commit 3fcd8e7

Please sign in to comment.