Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): Update numeric Input components to pass NaN where appropriat… #15797

Merged
merged 1 commit into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions ui/cypress/e2e/explorer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,150 @@ describe('DataExplorer', () => {
})
})

describe('numeric input validation when changing bin sizes in Heat Maps', () => {
beforeEach(() => {
cy.getByTestID('page-header--right').within(() => {
cy.getByTestID('dropdown')
.click()
.then(() => {
cy.get('#heatmap')
.click()
.then(() => {
cy.getByTestID('cog-cell--button').click()
})
})
})
})
it('should put input field in error status when "10" gets one character deleted and becomes "1"', () => {
cy.get('.view-options').within(() => {
cy.getByTestID('grid--column').within(() => {
cy.getByTestID('input-field')
.first()
.click()
.type('{backspace}')
.getByTestID('input-field--error')
.should('have.length', 1)
})
})
})
it('should put input field in error status when "10" gets all characters deleted and becomes empty', () => {
cy.get('.view-options').within(() => {
cy.getByTestID('grid--column').within(() => {
cy.getByTestID('input-field')
.first()
.click()
.type('{backspace}{backspace}')
.getByTestID('input-field--error')
.should('have.length', 1)
})
})
})
it('should keep input field in error status when "10" becomes "4"', () => {
cy.get('.view-options').within(() => {
cy.getByTestID('grid--column').within(() => {
cy.getByTestID('input-field')
.first()
.click()
.type('{backspace}{backspace}4')
.getByTestID('input-field--error')
.should('have.length', 1)
})
})
})
it('should keep input field in error status when non-numeric characters are typed', () => {
cy.get('.view-options').within(() => {
cy.getByTestID('grid--column').within(() => {
cy.getByTestID('input-field')
.first()
.click()
.type('{backspace}{backspace}abcdefg')
.getByTestID('input-field--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('input-field')
.first()
.click()
.type('{backspace}{backspace}5')
.getByTestID('input-field--error')
.should('have.length', 0)
})
})
})
})

describe('numeric input validation when changing number of decimal places in Single Stat', () => {
beforeEach(() => {
cy.getByTestID('page-header--right').within(() => {
cy.getByTestID('dropdown')
.click()
.then(() => {
cy.get('#single-stat')
.click()
.then(() => {
cy.getByTestID('cog-cell--button').click()
})
})
})
})
it('should allow "2" to be deleted to temporarily become a text input field in error status', () => {
cy.get('.view-options').within(() => {
cy.getByTestID('auto-input--input').within(() => {
cy.getByTestID('input-field')
.click()
.type('{backspace}')
.invoke('attr', 'type')
.should('equal', 'text')
.getByTestID('input-field--error')
.should('have.length', 1)
})
})
})
it('should allow "2" to be deleted to become a blank input field in error status', () => {
cy.get('.view-options').within(() => {
cy.getByTestID('auto-input--input').within(() => {
cy.getByTestID('input-field')
.click()
.type('{backspace}')
.invoke('val')
.should('equal', '')
.getByTestID('input-field--error')
.should('have.length', 1)
})
})
})
it('should allow "2" to be deleted to temporarily become a text input field but does NOT allow text input and remains in error status', () => {
cy.get('.view-options').within(() => {
cy.getByTestID('auto-input--input').within(() => {
cy.getByTestID('input-field')
.click()
.type('{backspace}abcdefg')
.invoke('val')
.should('equal', '')
.getByTestID('input-field--error')
.should('have.length', 1)
})
})
})
it('should allow "2" to be deleted and then allow numeric input to get out of error status', () => {
cy.get('.view-options').within(() => {
cy.getByTestID('auto-input--input').within(() => {
cy.getByTestID('input-field')
.click()
.type('{backspace}3')
.invoke('val')
.should('equal', '3')
.getByTestID('input-field--error')
.should('have.length', 0)
})
})
})
})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

describe('select time range to query', () => {
it('can select different time ranges', () => {
// find initial value
Expand Down
228 changes: 228 additions & 0 deletions ui/cypress/e2e/notificationRules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,234 @@ describe('NotificationRules', () => {
})
})

describe('numeric input validation in Theshold Checks', () => {
beforeEach(() => {
cy.getByTestID('page-contents').within(() => {
cy.getByTestID('dropdown')
.click()
.then(() => {
cy.getByTestID('create-threshold-check').click()
})
})
})
describe('when threshold is above', () => {
it('should allow "20" to be deleted to temporarily become a text input field in error status', () => {
cy.getByTestID('checkeo--header alerting-tab')
.click()
.then(() => {
cy.getByTestID('add-threshold-condition-CRIT')
.click()
.then(() => {
cy.getByTestID('builder-conditions').within(() => {
cy.getByTestID('panel').within(() => {
cy.getByTestID('input-field')
.click()
.type('{backspace}{backspace}')
.invoke('attr', 'type')
.should('equal', 'text')
.getByTestID('input-field--error')
.should('have.length', 1)
})
})
})
})
})
it('should allow "20" to be deleted to become a blank input field in error status', () => {
cy.getByTestID('checkeo--header alerting-tab')
.click()
.then(() => {
cy.getByTestID('add-threshold-condition-CRIT')
.click()
.then(() => {
cy.getByTestID('builder-conditions').within(() => {
cy.getByTestID('panel').within(() => {
cy.getByTestID('input-field')
.click()
.type('{backspace}{backspace}')
.invoke('val')
.should('equal', '')
.getByTestID('input-field--error')
.should('have.length', 1)
})
})
})
})
})
it('should allow "20" to be deleted to temporarily become a text input field but does NOT allow text input and remains in error status', () => {
cy.getByTestID('checkeo--header alerting-tab')
.click()
.then(() => {
cy.getByTestID('add-threshold-condition-CRIT')
.click()
.then(() => {
cy.getByTestID('builder-conditions').within(() => {
cy.getByTestID('panel').within(() => {
cy.getByTestID('input-field')
.click()
.type('{backspace}{backspace}somerange')
.invoke('val')
.should('equal', '')
.getByTestID('input-field--error')
.should('have.length', 1)
})
})
})
})
})
it('should allow "20" to be deleted and then allow numeric input to get out of error status', () => {
cy.getByTestID('checkeo--header alerting-tab')
.click()
.then(() => {
cy.getByTestID('add-threshold-condition-CRIT')
.click()
.then(() => {
cy.getByTestID('builder-conditions').within(() => {
cy.getByTestID('panel').within(() => {
cy.getByTestID('input-field')
.click()
.type('{backspace}{backspace}9')
.invoke('val')
.should('equal', '9')
.getByTestID('input-field--error')
.should('have.length', 0)
})
})
})
})
})
})
describe('when threshold is inside range', () => {
it('should allow "20" to be deleted to temporarily become a text input field in error status', () => {
cy.getByTestID('checkeo--header alerting-tab')
.click()
.then(() => {
cy.getByTestID('add-threshold-condition-CRIT')
.click()
.then(() => {
cy.getByTestID('builder-conditions').within(() => {
cy.getByTestID('panel').within(() => {
cy.getByTestID('dropdown--button')
.click()
.then(() => {
cy.get(
'.cf-dropdown-item--children:contains("is inside range")'
)
.click()
.then(() => {
cy.getByTestID('input-field')
.first()
.click()
.type('{backspace}{backspace}')
.invoke('attr', 'type')
.should('equal', 'text')
.getByTestID('input-field--error')
.should('have.length', 1)
})
})
})
})
})
})
})
it('should allow "20" to be deleted to become a blank input field in error status', () => {
cy.getByTestID('checkeo--header alerting-tab')
.click()
.then(() => {
cy.getByTestID('add-threshold-condition-CRIT')
.click()
.then(() => {
cy.getByTestID('builder-conditions').within(() => {
cy.getByTestID('panel').within(() => {
cy.getByTestID('dropdown--button')
.click()
.then(() => {
cy.get(
'.cf-dropdown-item--children:contains("is inside range")'
)
.click()
.then(() => {
cy.getByTestID('input-field')
.first()
.click()
.type('{backspace}{backspace}')
.invoke('val')
.should('equal', '')
.getByTestID('input-field--error')
.should('have.length', 1)
})
})
})
})
})
})
})
it('should allow "20" to be deleted to temporarily become a text input field but does NOT allow text input and remains in error status', () => {
cy.getByTestID('checkeo--header alerting-tab')
.click()
.then(() => {
cy.getByTestID('add-threshold-condition-CRIT')
.click()
.then(() => {
cy.getByTestID('builder-conditions').within(() => {
cy.getByTestID('panel').within(() => {
cy.getByTestID('dropdown--button')
.click()
.then(() => {
cy.get(
'.cf-dropdown-item--children:contains("is inside range")'
)
.click()
.then(() => {
cy.getByTestID('input-field')
.first()
.click()
.type('{backspace}{backspace}hhhhhhhhhhhh')
.invoke('val')
.should('equal', '')
.getByTestID('input-field--error')
.should('have.length', 1)
})
})
})
})
})
})
})
it('should allow "20" to be deleted and then allow numeric input to get out of error status', () => {
cy.getByTestID('checkeo--header alerting-tab')
.click()
.then(() => {
cy.getByTestID('add-threshold-condition-CRIT')
.click()
.then(() => {
cy.getByTestID('builder-conditions').within(() => {
cy.getByTestID('panel').within(() => {
cy.getByTestID('dropdown--button')
.click()
.then(() => {
cy.get(
'.cf-dropdown-item--children:contains("is inside range")'
)
.click()
.then(() => {
cy.getByTestID('input-field')
.first()
.click()
.type('{backspace}{backspace}7')
.invoke('val')
.should('equal', '7')
.getByTestID('input-field--error')
.should('have.length', 0)
})
})
})
})
})
})
})
})
})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

// TODO(desa): this needs to be skipped until https://github.com/influxdata/influxdb/issues/14799
it.skip('can create a notification rule', () => {
const ruleName = 'my-new-rule'
Expand Down
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"webpack-merge": "^4.2.1"
},
"dependencies": {
"@influxdata/clockface": "1.0.4",
"@influxdata/clockface": "1.0.5",
"@influxdata/flux-parser": "^0.3.0",
"@influxdata/giraffe": "0.16.4",
"@influxdata/influx": "0.5.5",
Expand Down
Loading