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/collectorList-telegraf): sort telegrafs based on buckets #15510

Merged
merged 10 commits into from
Oct 22, 2019
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
1. [13940](https://github.com/influxdata/influxdb/pull/15443): Create Label Overlay UI will disable the submit button and return a UI error if the name field is empty
1. [15452](https://github.com/influxdata/influxdb/pull/15452): Log error as info message on unauthorized API call attempts
1. [15504](https://github.com/influxdata/influxdb/pull/15504): Ensure members&owners eps 404 when /org resource does not exist
1. [15510](https://github.com/influxdata/influxdb/pull/15510): UI/Telegraf sort functionality fixed

## v2.0.0-alpha.18 [2019-09-26]

Expand Down
142 changes: 98 additions & 44 deletions ui/cypress/e2e/collectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ describe('Collectors', () => {
.click()
})

cy.getByTestID('resource-card')
.should('have.length', 1)
.and('contain', newConfig)
cy.fixture('user').then(({bucket}) => {
cy.getByTestID('resource-card')
.should('have.length', 1)
.and('contain', newConfig)
.and('contain', bucket)
})
})

it('can update configuration name', () => {
Expand All @@ -58,7 +61,9 @@ describe('Collectors', () => {
const description = 'Config Description'

cy.get('@org').then(({id}: Organization) => {
cy.createTelegraf(telegrafConfigName, description, id)
cy.fixture('user').then(({bucket}) => {
cy.createTelegraf(telegrafConfigName, description, id, bucket)
})
})

cy.getByTestID('collector-card--name')
Expand All @@ -81,8 +86,12 @@ describe('Collectors', () => {
const telegrafConfigName = 'New Config'
const description = 'Config Description'
cy.get('@org').then(({id}: Organization) => {
cy.createTelegraf(telegrafConfigName, description, id)
cy.fixture('user').then(({bucket}) => {
cy.createTelegraf(telegrafConfigName, description, id, bucket)
})
})

cy.reload()
})

it('can delete a telegraf config', () => {
Expand Down Expand Up @@ -114,56 +123,101 @@ 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'

cy.get('@org').then(({id}: Organization) => {
cy.createTelegraf(firstTelegraf, description, id)
cy.createTelegraf(secondTelegraf, description, id)
cy.createTelegraf(thirdTelegraf, description, id)
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)
})
asalem1 marked this conversation as resolved.
Show resolved Hide resolved
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('resource-card').should('have.length', 1)
cy.getByTestID('resource-card').should('contain', firstTelegraf)

cy.getByTestID('search-widget')
.clear()
.type(secondTelegraf)
cy.getByTestID('search-widget')
.clear()
.type(secondTelegraf)

cy.getByTestID('resource-card').should('have.length', 1)
cy.getByTestID('resource-card').should('contain', 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('search-widget')
.clear()
.type(thirdTelegraf)

cy.getByTestID('resource-card').should('have.length', 1)
cy.getByTestID('resource-card').should('contain', 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('search-widget')
.clear()
.type('should have no results')

cy.getByTestID('resource-card').should('have.length', 0)
cy.getByTestID('empty-state').should('exist')
cy.getByTestID('resource-card').should('have.length', 0)
cy.getByTestID('empty-state').should('exist')

cy.getByTestID('search-widget')
.clear()
.type('test')
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)
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', () => {
cy.getByTestID('bucket-name').should('have.length', 3)
cy.getByTestID('bucket-sorter').click()

bucketz.sort()
cy.getByTestID('bucket-name')
.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])
})
})
})
// sort by name test here
it('can sort telegraf configs by name', () => {
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])
})
.then(() => {
cy.getByTestID('name-sorter').click()
telegrafs.reverse()
})
.then(() => {
cy.getByTestID('collector-card--name').each((val, index) => {
expect(val.text()).to.include(telegrafs[index])
})
})
})
})
})
})
6 changes: 1 addition & 5 deletions ui/cypress/e2e/labels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ describe('labels', () => {
cy.getByTestID('label-card').should('have.length', 2)
})

describe('label destruction', () => {
describe.skip('label destruction', () => {
const labelName = 'Modus (目录)'
const labelDescription =
'(\u03945) Per modum intelligo substantiae affectiones sive id quod in alio est, per quod etiam concipitur.'
Expand All @@ -426,10 +426,6 @@ describe('labels', () => {
description: labelDescription,
color: '#CCAA88',
})
cy.createLabel(labelName, id, {
description: labelDescription,
color: '#CCAA88',
})
})
})

Expand Down
17 changes: 15 additions & 2 deletions ui/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ export const createScraper = (
export const createTelegraf = (
name?: string,
description?: string,
orgID?: string
orgID?: string,
bucket?: string
): Cypress.Chainable<Cypress.Response> => {
return cy.request({
method: 'POST',
Expand All @@ -278,7 +279,19 @@ export const createTelegraf = (
name,
description,
agent: {collectionInterval: 10000},
plugins: [],
plugins: [
{
name: 'influxdb_v2',
type: 'output',
comment: 'string',
config: {
urls: ['string'],
token: 'string',
organization: 'string',
bucket,
},
},
],
orgID,
},
})
Expand Down
3 changes: 2 additions & 1 deletion ui/cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"lib": ["es2017", "dom"],
"types": ["cypress", "mocha", "node"],
"jsx": "react",
"allowSyntheticDefaultImports": true
"allowSyntheticDefaultImports": true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Yaaaas

"resolveJsonModule": true
},
"include": ["**/*.ts"]
}
4 changes: 3 additions & 1 deletion ui/src/telegrafs/components/CollectorCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ class CollectorRow extends PureComponent<Props & WithRouterProps> {
}
labels={this.labels}
metaData={[
<>Bucket: {bucket}</>,
<span key={`bucket-key--${collector.id}`} data-testid="bucket-name">
Bucket: {bucket}
</span>,
<>
<Link
to={`/orgs/${org.id}/load-data/telegrafs/${
Expand Down
6 changes: 4 additions & 2 deletions ui/src/telegrafs/components/CollectorList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {SortTypes, getSortedResources} from 'src/shared/utils/sort'
//Utils
import {getDeep} from 'src/utils/wrappers'

type SortKey = keyof Telegraf | 'bucket'
type SortKey = keyof Telegraf | 'plugins.0.config.bucket'

interface Props {
collectors: Telegraf[]
Expand Down Expand Up @@ -46,12 +46,14 @@ export default class CollectorList extends PureComponent<Props> {
sort={sortKey === this.headerKeys[0] ? sortDirection : Sort.None}
name="Name"
onClick={onClickColumn}
testID="name-sorter"
/>
<ResourceList.Sorter
name="Bucket"
sortKey={this.headerKeys[1]}
sort={sortKey === this.headerKeys[1] ? sortDirection : Sort.None}
onClick={onClickColumn}
testID="bucket-sorter"
/>
</ResourceList.Header>
<ResourceList.Body emptyState={emptyState}>
Expand All @@ -63,7 +65,7 @@ export default class CollectorList extends PureComponent<Props> {
}

private get headerKeys(): SortKey[] {
return ['name', 'bucket']
return ['name', 'plugins.0.config.bucket']
}

public get collectorsList(): JSX.Element[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ exports[`CollectorList rendering renders 1`] = `
name="Name"
sort="none"
sortKey="name"
testID="name-sorter"
/>
<ResourceListSorter
name="Bucket"
sort="none"
sortKey="bucket"
sortKey="plugins.0.config.bucket"
testID="bucket-sorter"
/>
</ResourceListHeader>
<ResourceListBody
Expand Down