diff --git a/ui/cypress/e2e/collectors.test.ts b/ui/cypress/e2e/collectors.test.ts index 4783cccf9a0..d3527bc8a73 100644 --- a/ui/cypress/e2e/collectors.test.ts +++ b/ui/cypress/e2e/collectors.test.ts @@ -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', () => { @@ -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]) }) }) }) @@ -223,7 +204,7 @@ 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() @@ -231,7 +212,7 @@ describe('Collectors', () => { }) .then(() => { cy.getByTestID('collector-card--name').each((val, index) => { - expect(val.text()).to.equal(telegrafs[index]) + expect(val.text()).to.include(telegrafs[index]) }) }) })