Skip to content

Commit 7745be4

Browse files
authored
fix: allow Band plot to work prior to user interaction with options (#3865)
1 parent 1e5c4c9 commit 7745be4

File tree

12 files changed

+320
-85
lines changed

12 files changed

+320
-85
lines changed

cypress/e2e/shared/explorerVisualizations.test.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Organization} from '../../../src/types'
22
import {points, makeGraphSnapshot} from '../../support/commands'
3+
34
const VIS_TYPES = [
45
'band',
56
// 'check',
@@ -15,6 +16,7 @@ const VIS_TYPES = [
1516
'table',
1617
]
1718
const NUM_POINTS = 360
19+
1820
describe('visualizations', () => {
1921
beforeEach(() => {
2022
cy.flush()
@@ -29,6 +31,7 @@ describe('visualizations', () => {
2931
cy.writeData(points(NUM_POINTS))
3032
cy.getByTestID('time-machine--bottom')
3133
})
34+
3235
describe('empty states', () => {
3336
it('shows a message if no queries have been created', () => {
3437
cy.getByTestID('empty-graph--no-queries').should('exist')
@@ -130,7 +133,7 @@ describe('visualizations', () => {
130133

131134
// cycle through all the visualizations of the data
132135
VIS_TYPES.forEach(type => {
133-
if (type !== 'mosaic' && type !== 'band') {
136+
if (type !== 'mosaic') {
134137
// mosaic graph is behind feature flag
135138
cy.getByTestID('view-type--dropdown').click()
136139
cy.getByTestID(`view-type--${type}`).click()
@@ -372,4 +375,45 @@ describe('visualizations', () => {
372375
})
373376
})
374377
})
378+
379+
describe('Band plot behaves correctly', () => {
380+
it('can find its main column before adjusting view options', () => {
381+
cy.get<string>('@defaultBucketListSelector').then(
382+
(defaultBucketListSelector: string) => {
383+
const AGGREGATE_FUNCTION = 'last'
384+
385+
cy.getByTestID('query-builder').should('exist')
386+
// build the query to return data from beforeEach
387+
cy.getByTestID('selector-list _monitoring').should('be.visible')
388+
cy.getByTestID('selector-list _monitoring').click()
389+
390+
cy.getByTestID(defaultBucketListSelector).should('be.visible')
391+
cy.getByTestID(defaultBucketListSelector).click()
392+
393+
cy.getByTestID('selector-list m').should('be.visible')
394+
cy.getByTestID('selector-list m').clickAttached()
395+
396+
cy.getByTestID('selector-list v').should('be.visible')
397+
cy.getByTestID('selector-list v').clickAttached()
398+
399+
cy.getByTestID('selector-list tv1').clickAttached()
400+
401+
cy.getByTestID(`selector-list ${AGGREGATE_FUNCTION}`)
402+
.scrollIntoView()
403+
.should('be.visible')
404+
.click()
405+
406+
cy.getByTestID('view-type--dropdown').click()
407+
cy.getByTestID(`view-type--band`).click()
408+
cy.getByTestID('time-machine-submit-button').click()
409+
cy.getByTestID(`vis-graphic--band`).should('exist')
410+
411+
cy.get('button.cf-button[title="Customize"').click()
412+
cy.getByTestID('dropdown--button-main-column').within(() => {
413+
cy.get('.cf-dropdown--selected').contains(AGGREGATE_FUNCTION)
414+
})
415+
}
416+
)
417+
})
418+
})
375419
})

cypress/e2e/shared/flows.test.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,4 +547,77 @@ describe('Flows', () => {
547547
})
548548
})
549549
})
550+
551+
it('can create a Band plot without crashing', () => {
552+
const newBucketName = 'lets goooo'
553+
const now = Date.now()
554+
cy.get<Organization>('@org').then(({id, name}: Organization) => {
555+
cy.createBucket(id, name, newBucketName)
556+
})
557+
cy.writeData(
558+
[
559+
`test,container_name=cool dopeness=12 ${now - 1000}000000`,
560+
`test,container_name=beans dopeness=18 ${now - 1200}000000`,
561+
`test,container_name=cool dopeness=14 ${now - 1400}000000`,
562+
`test,container_name=beans dopeness=10 ${now - 1600}000000`,
563+
],
564+
newBucketName
565+
)
566+
567+
cy.getByTestID('preset-new')
568+
.first()
569+
.click()
570+
cy.getByTestID('time-machine-submit-button').should('be.visible')
571+
572+
cy.getByTestID('page-title')
573+
.first()
574+
.click()
575+
cy.getByTestID('renamable-page-title--input').type(
576+
'I am not afraid of Band Plot {enter}'
577+
)
578+
579+
// select our bucket
580+
cy.getByTestID('bucket-selector').within(() => {
581+
cy.getByTestID('selector-list lets goooo').click()
582+
})
583+
584+
// select measurement and field
585+
cy.getByTestID('builder-card')
586+
.eq(0)
587+
.within(() => {
588+
cy.getByTestID(`selector-list test`).click()
589+
})
590+
cy.getByTestID('builder-card')
591+
.eq(1)
592+
.within(() => {
593+
cy.getByTestID(`selector-list dopeness`).click()
594+
})
595+
596+
cy.get('input.flow-panel--title-input')
597+
.eq(1)
598+
.should('have.value', 'Validate the Data')
599+
cy.getByTestID('sidebar-button')
600+
.eq(1)
601+
.click()
602+
603+
cy.get('button.cf-dropdown-item[title="Delete"]')
604+
.should('be.visible')
605+
.click()
606+
607+
cy.get('input.flow-panel--title-input')
608+
.eq(1)
609+
.should('have.value', 'Visualize the Result')
610+
611+
cy.getByTestID('view-type--dropdown').click()
612+
cy.getByTestID('view-type--band').click()
613+
cy.get(
614+
'.flow-panel--persistent-control > button.cf-button[title="Run"'
615+
).click()
616+
cy.getByTestID(`vis-graphic--band`).should('exist')
617+
618+
cy.get('button.cf-button[title="Configure Visualization"]').click()
619+
cy.getByTestID('dropdown--button-main-column').within(() => {
620+
cy.get('.cf-dropdown--selected').contains('_result')
621+
})
622+
})
550623
})

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@
156156
},
157157
"dependencies": {
158158
"@docsearch/react": "^3.0.0-alpha.37",
159-
"@influxdata/clockface": "^3.2.1",
159+
"@influxdata/clockface": "^3.3.1",
160160
"@influxdata/flux-lsp-browser": "^0.8.5",
161-
"@influxdata/giraffe": "^2.24.1",
161+
"@influxdata/giraffe": "^2.24.3",
162162
"@influxdata/influxdb-templates": "0.9.0",
163163
"@influxdata/react-custom-scrollbars": "4.3.8",
164164
"abortcontroller-polyfill": "^1.3.0",

src/style/chronograf.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
@import 'src/writeData/components/AddPluginToConfiguration.scss';
144144
@import 'src/authorizations/components/customApiTokenOverlay.scss';
145145
@import 'src/flows/components/header/VersionBullet.scss';
146+
@import 'src/visualization/styles/Band.scss';
146147

147148
// External
148149
@import '../../node_modules/@influxdata/react-custom-scrollbars/dist/styles.css';

src/views/helpers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export function defaultBandViewProperties() {
164164
},
165165
hoverDimension: 'auto' as LineHoverDimension,
166166
upperColumn: '',
167-
mainColumn: DEFAULT_AGGREGATE_FUNCTION,
167+
mainColumn: '',
168168
lowerColumn: '',
169169
}
170170
}

src/visualization/styles/Band.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.view-options--band-column-dropdown-error {
2+
margin: $cf-marg-a;
3+
color: $cf-input-border--error;
4+
}

src/visualization/types/Band/icon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22

33
const icon = (
4-
<div className="vis-graphic" data-testid="vis-graphic--band-chart">
4+
<div className="vis-graphic" data-testid="vis-graphic--band">
55
<svg
66
id="Band Chart"
77
x="0px"

0 commit comments

Comments
 (0)