Skip to content

Commit

Permalink
fix(ui/collectors): updated filter test to utilize beforeEach functio…
Browse files Browse the repository at this point in the history
…nality
  • Loading branch information
asalem1 committed Oct 21, 2019
1 parent 3f9c25d commit 8bbab27
Showing 1 changed file with 45 additions and 64 deletions.
109 changes: 45 additions & 64 deletions ui/cypress/e2e/collectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,78 +121,59 @@ describe('Collectors', () => {
})
})

it('can filter telegraf configs correctly', () => {
// fixes issue #15246:
// https://github.com/influxdata/influxdb/issues/15246
const firstTelegraf = 'test1'
const secondTelegraf = 'test2'
const thirdTelegraf = 'unicorn'
const description = 'Config Description'
const secondBucket = 'bucket2'

cy.get('@org').then(({id}: Organization) => {
cy.fixture('user').then(({bucket}) => {
cy.createTelegraf(firstTelegraf, description, id, bucket)
cy.createTelegraf(secondTelegraf, description, id, bucket)
cy.createTelegraf(thirdTelegraf, description, id, secondBucket)
describe('sorting & filtering', () => {
const telegrafs = ['bad', 'apple', 'cookie']
const bucketz = ['MO_buckets', 'EZ_buckets', 'Bucky']
const [firstTelegraf, secondTelegraf, thirdTelegraf] = telegrafs
beforeEach(() => {
const description = 'Config Description'
const [firstBucket, secondBucket, thirdBucket] = bucketz
cy.get('@org').then(({id}: Organization) => {
cy.createTelegraf(firstTelegraf, description, id, firstBucket)
cy.createTelegraf(secondTelegraf, description, id, secondBucket)
cy.createTelegraf(thirdTelegraf, description, id, thirdBucket)
})
cy.reload()
})
// filter by name
it('can filter telegraf configs correctly', () => {
// fixes issue #15246:
// https://github.com/influxdata/influxdb/issues/15246

cy.reload()

cy.getByTestID('search-widget').type(firstTelegraf)
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')
.clear()
.type(secondTelegraf)

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

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

cy.getByTestID('resource-card').should('have.length', 1)
cy.getByTestID('resource-card')
.should('contain', thirdTelegraf)
.and('contain', secondBucket)
cy.getByTestID('search-widget')
.clear()
.type(secondTelegraf)

cy.getByTestID('search-widget')
.clear()
.type('should have no results')
cy.getByTestID('resource-card').should('have.length', 1)
cy.getByTestID('resource-card').should('contain', secondTelegraf)

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

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

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('should have no results')

describe('sorting', () => {
const telegrafs = ['b', 'a', 'c']
const bucketz = ['MO_buckets', 'EZ_buckets', 'Bucky']
beforeEach(() => {
const [firstTelegraf, secondTelegraf, thirdTelegraf] = telegrafs
const description = 'Config Description'
const [firstBucket, secondBucket, thirdBucket] = bucketz
cy.getByTestID('resource-card').should('have.length', 0)
cy.getByTestID('empty-state').should('exist')

cy.get('@org').then(({id}: Organization) => {
cy.createTelegraf(firstTelegraf, description, id, firstBucket)
cy.createTelegraf(secondTelegraf, description, id, secondBucket)
cy.createTelegraf(thirdTelegraf, description, id, thirdBucket)
})
cy.getByTestID('search-widget')
.clear()
.type('a')

cy.reload()
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
it('can sort telegraf configs by bucket', () => {
Expand All @@ -203,14 +184,14 @@ describe('Collectors', () => {
cy.getByTestID('bucket-name')
.each((val, index) => {
const text = val.text()
expect(text).to.equal(`Bucket: ${bucketz[index]}`)
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.equal(`Bucket: ${bucketz[index]}`)
expect(text).to.include(bucketz[index])
})
})
})
Expand All @@ -223,15 +204,15 @@ describe('Collectors', () => {

cy.getByTestID('collector-card--name')
.each((val, index) => {
expect(val.text()).to.equal(telegrafs[index])
expect(val.text()).to.include(telegrafs[index])
})
.then(() => {
cy.getByTestID('name-sorter').click()
telegrafs.reverse()
})
.then(() => {
cy.getByTestID('collector-card--name').each((val, index) => {
expect(val.text()).to.equal(telegrafs[index])
expect(val.text()).to.include(telegrafs[index])
})
})
})
Expand Down

0 comments on commit 8bbab27

Please sign in to comment.