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

feat(ui): adding the ability to view just the output section #15674

Merged
merged 25 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
4 changes: 4 additions & 0 deletions ui/cypress/e2e/checks.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {Organization} from '../../src/types'

// a generous commitment to delivering this page in a loaded state
const PAGE_LOAD_SLA = 10000
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this just unbreaks the test locally for me

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense, gives it more time to load


const measurement = 'my_meas'
const field = 'my_field'
describe('Checks', () => {
Expand All @@ -18,6 +21,7 @@ describe('Checks', () => {
cy.visit(`${orgs}/${id}${alerting}`)
})
})
cy.get('[data-testid="resource-list--body"]', {timeout: PAGE_LOAD_SLA})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wait for a test agnostic load event to signal that the tests are ready to run

})

it('can validate a threshold check', () => {
Expand Down
286 changes: 152 additions & 134 deletions ui/cypress/e2e/collectors.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {Organization} from '../../src/types'

// a generous commitment to delivering this page in a loaded state
const PAGE_LOAD_SLA = 10000

describe('Collectors', () => {
beforeEach(() => {
cy.flush()
Expand All @@ -14,48 +17,38 @@ describe('Collectors', () => {
cy.visit(`${orgs}/${id}/load-data/telegrafs`)
})
})

cy.get('[data-testid="resource-list--body"]', {timeout: PAGE_LOAD_SLA})
})

describe('from the org view', () => {
it('can create a telegraf config', () => {
const newConfig = 'New Config'
const configDescription = 'This is a new config testing'

cy.getByTestID('table-row')
.should('have.length', 0)
.then(() => {
cy.contains('Create Configuration')
cy.getByTestID('table-row').should('have.length', 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i just moved this test outside of the then

cy.contains('Create Configuration').click()
cy.getByTestID('overlay--container').within(() => {
cy.getByTestID('telegraf-plugins--System').click()
cy.getByTestID('next').click()
cy.getByInputName('name')
.clear()
.type(newConfig)
cy.getByInputName('description')
.clear()
.type(configDescription)
cy.get('.cf-button')
.contains('Create and Verify')
.click()
cy.getByTestID('streaming').within(() => {
cy.get('.cf-button')
.contains('Listen for Data')
.click()
.then(() => {
cy.getByTestID('overlay--container').within(() => {
cy.getByTestID('telegraf-plugins--System')
.click()
.then(() => {
cy.getByTestID('next')
.click()
.then(() => {
cy.getByInputName('name')
.clear()
.type(newConfig)
cy.getByInputName('description')
.clear()
.type(configDescription)
cy.get('.cf-button')
.contains('Create and Verify')
.click()
cy.getByTestID('streaming').within(() => {
cy.get('.cf-button')
.contains('Listen for Data')
.click()
})
cy.get('.cf-button')
.contains('Finish')
.click()
})
})
})
})
})
cy.get('.cf-button')
.contains('Finish')
.click()
})

cy.fixture('user').then(({bucket}) => {
cy.getByTestID('resource-card')
Expand All @@ -65,6 +58,54 @@ describe('Collectors', () => {
})
})

it('allows the user to view just the output', () => {
const bucketz = ['MO_buckets', 'EZ_buckets', 'Bucky']
const [firstBucket, secondBucket, thirdBucket] = bucketz

cy.get<Organization>('@org').then(({id, name}: Organization) => {
cy.createBucket(id, name, firstBucket)
cy.createBucket(id, name, secondBucket)
cy.createBucket(id, name, thirdBucket)
})

cy.reload()
cy.get('[data-testid="resource-list--body"]', {timeout: PAGE_LOAD_SLA})

cy.getByTestID('button--output-only').click()
cy.getByTestID('overlay--container')
.should('be.visible')
.within(() => {
const buckets = bucketz.slice(0).sort((a, b) => {
const _a = a.toLowerCase()
const _b = b.toLowerCase()
return _a > _b ? 1 : _a < _b ? -1 : 0
})

cy.get('code').should($el => {
const text = $el.text()

expect(text.includes('[[outputs.influxdb_v2]]')).to.be.true
//expect a default sort to be applied
expect(text.includes(`bucket = "${buckets[0]}"`)).to.be.true
})

cy.getByTestID('bucket-dropdown').within(() => {
cy.getByTestID('bucket-dropdown--button').click()
cy.getByTestID('dropdown-item')
.eq(2)
.click()
})

cy.get('code').should($el => {
const text = $el.text()

// NOTE: this index is off because there is a default
// defbuck bucket in there (alex)
expect(text.includes(`bucket = "${buckets[1]}"`)).to.be.true
})
})
})

describe('when a config already exists', () => {
beforeEach(() => {
const telegrafConfigName = 'New Config'
Expand All @@ -76,6 +117,7 @@ describe('Collectors', () => {
})

cy.reload()
cy.get('[data-testid="resource-list--body"]', {timeout: PAGE_LOAD_SLA})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

always gotta wait for that page to be ready 😬

})

it('can update configuration name and delete a configuration', () => {
Expand All @@ -84,36 +126,23 @@ describe('Collectors', () => {
cy.getByTestID('collector-card--name')
.first()
.trigger('mouseover')
.then(() => {
cy.getByTestID('collector-card--name-button')
.first()
.click()
.then(() => {
cy.getByTestID('collector-card--input')
.type(newConfigName)
.type('{enter}')
.then(() => {
cy.getByTestID('collector-card--name').should(
'contain',
newConfigName
)
})
})
})
cy.getByTestID('collector-card--name-button')
.first()
.click()
cy.getByTestID('collector-card--input')
.type(newConfigName)
.type('{enter}')
cy.getByTestID('collector-card--name').should('contain', newConfigName)

cy.getByTestID('resource-card').should('have.length', 1)

cy.getByTestID('context-menu')
.last()
.click()
.then(() => {
cy.getByTestID('context-menu-item')
.last()
.click()
.then(() => {
cy.getByTestID('empty-state').should('exist')
})
})
cy.getByTestID('context-menu-item')
.last()
.click()
cy.getByTestID('empty-state').should('exist')
})

it('can view setup instructions for a config', () => {
Expand Down Expand Up @@ -144,111 +173,100 @@ describe('Collectors', () => {
cy.createTelegraf(thirdTelegraf, description, id, thirdBucket)
})
cy.reload()
cy.get('[data-testid="resource-list--body"]', {timeout: PAGE_LOAD_SLA})
})
// filter by name
it('can filter telegraf configs and sort by bucket and name', () => {
// fixes https://github.com/influxdata/influxdb/issues/15246
cy.getByTestID('search-widget').type(firstTelegraf)
cy.getByTestID('resource-card').should('have.length', 1)
cy.getByTestID('resource-card').should('contain', firstTelegraf)

cy.getByTestID('search-widget')
.type(firstTelegraf)
.then(() => {
cy.getByTestID('resource-card').should('have.length', 1)
cy.getByTestID('resource-card').should('contain', firstTelegraf)
.clear()
.type(secondTelegraf)
cy.getByTestID('resource-card').should('have.length', 1)
cy.getByTestID('resource-card').should('contain', secondTelegraf)

cy.getByTestID('search-widget')
.clear()
.type(secondTelegraf)
.then(() => {
cy.getByTestID('resource-card').should('have.length', 1)
cy.getByTestID('resource-card').should(
'contain',
secondTelegraf
)

cy.getByTestID('search-widget')
.clear()
.type(thirdTelegraf)
.then(() => {
cy.getByTestID('resource-card').should('have.length', 1)
cy.getByTestID('resource-card').should(
'contain',
thirdTelegraf
)

cy.getByTestID('search-widget')
.clear()
.type('should have no results')
.then(() => {
cy.getByTestID('resource-card').should('have.length', 0)
cy.getByTestID('empty-state').should('exist')

cy.getByTestID('search-widget')
.clear()
.type('a')
.then(() => {
cy.getByTestID('resource-card').should(
'have.length',
2
)
cy.getByTestID('resource-card').should(
'contain',
firstTelegraf
)
cy.getByTestID('resource-card').should(
'contain',
secondTelegraf
)
cy.getByTestID('resource-card').should(
'not.contain',
thirdTelegraf
)
})
})
})
})
})
cy.getByTestID('search-widget')
.clear()
.type(thirdTelegraf)
cy.getByTestID('resource-card').should('have.length', 1)
cy.getByTestID('resource-card').should('contain', thirdTelegraf)

cy.getByTestID('search-widget')
.clear()
.type('should have no results')
cy.getByTestID('resource-card').should('have.length', 0)
cy.getByTestID('empty-state').should('exist')

cy.getByTestID('search-widget')
.clear()
.type('a')
cy.getByTestID('resource-card').should('have.length', 2)
cy.getByTestID('resource-card').should('contain', firstTelegraf)
cy.getByTestID('resource-card').should('contain', secondTelegraf)
cy.getByTestID('resource-card').should('not.contain', thirdTelegraf)

// sort by buckets test here
cy.reload() // clear out filtering state from the previous test
cy.get('[data-testid="resource-list--body"]', {timeout: PAGE_LOAD_SLA})

cy.getByTestID('bucket-sorter')
.click()
.then(() => {
bucketz.sort()
// NOTE: this then is just here to let me scope this variable (alex)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

or else it's mutation falls outside of the magic promise chain

const testBucket = bucketz.slice(0).sort()
cy.getByTestID('bucket-name')
.should('have.length', 3)
.each((val, index) => {
const text = val.text()
expect(text).to.include(bucketz[index])
})
.then(() => {
cy.getByTestID('bucket-sorter').click()
bucketz.reverse()
cy.getByTestID('bucket-name').each((val, index) => {
const text = val.text()
expect(text).to.include(bucketz[index])
})
expect(text).to.include(testBucket[index])
})
})

cy.getByTestID('bucket-sorter')
.click()
.then(() => {
// NOTE: this then is just here to let me scope this variable (alex)
const testBucket = bucketz
.slice(0)
.sort()
.reverse()
cy.getByTestID('bucket-name').each((val, index) => {
const text = val.text()
expect(text).to.include(testBucket[index])
})
})

// sort by name test here
cy.reload() // clear out sorting state from previous test
cy.get('[data-testid="resource-list--body"]', {timeout: PAGE_LOAD_SLA})

cy.getByTestID('collector-card--name').should('have.length', 3)

// test to see if telegrafs are initially sorted by name
telegrafs.sort()

cy.getByTestID('collector-card--name')
.each((val, index) => {
expect(val.text()).to.include(telegrafs[index])
cy.wait(0).then(() => {
// NOTE: this then is just here to let me scope this variable (alex)
const teletubbies = telegrafs.slice(0).sort()
cy.getByTestID('collector-card--name').each((val, index) => {
expect(val.text()).to.include(teletubbies[index])
})
})

cy.getByTestID('name-sorter')
.click()
.then(() => {
telegrafs.reverse()
cy.getByTestID('name-sorter')
.click()
.then(() => {
cy.getByTestID('collector-card--name').each((val, index) => {
expect(val.text()).to.include(telegrafs[index])
})
})
// NOTE: this then is just here to let me scope this variable (alex)
const teletubbies = telegrafs
.slice(0)
.sort()
.reverse()
cy.getByTestID('collector-card--name').each((val, index) => {
expect(val.text()).to.include(teletubbies[index])
})
})
})
})
Expand Down
Loading